r-spatial / dtwSat

Time-Weighted Dynamic Time Warping for satellite image time series analysis

Home Page:https://www.victor-maus.com/dtwSat/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doubt regarding sign of alpha in logisticWeight function

micha-silver opened this issue · comments

There seems to be an inconsistency in the suggested sign of the alpha parameter to logisticWeight(). In the paper from 2016 [1], the example uses alpha = 0.1. Whereas in the later paper, from 2019 [2] the alpha value is stated as -0.1.

This code below, following the function definition in the 2019 paper, creates a graph similar to what is published in the papers, suggesting that alpha should be positive.

PlotLogisticWeight <- function(alpha, beta) {
  days_interval = seq(1, 200, 1)
  wt_logistic = 1 / (1+exp(-alpha*(days_interval-beta)))
  weight_df = data.frame("Weight" = wt_logistic, "Interval" = days_interval)
   ggplot(weight_df) +
     geom_line(aes(x=Interval, y=Weight))
}
alpha = 0.1
beta = 100
PlotLogisticWeight(alpha, beta)

Whereas the source of logisticWeight seems to use the alph parameter without a minus. So negative alpha parameter would be correct.

> logisticWeight
function (alpha, beta) 
{
    function(psi) 1/(1 + exp(alpha * (psi - beta)))
}

Can you clarify??

Thanks, Micha

[1] Victor Maus et al., “A Time-Weighted Dynamic Time Warping Method for Land-Use and Land-Cover Mapping,” IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing 9, no. 8 (August 2016): 3729–39, https://doi.org/10.1109/JSTARS.2016.2517118.

[2] Victor Maus et al., “DtwSat : Time-Weighted Dynamic Time Warping for Satellite Image Time Series Analysis in R,” Journal of Statistical Software 88, no. 5 (2019), https://doi.org/10.18637/jss.v088.i05.

While removing an obsolete parameter called theta I let an incorrect operator * instead of +. In the last commit, I fixed this issue and replace the way users declare a weight function. Now user should define which operations should be executed between the local DTW costs phi and the time weight psi. This adds more flexibility to the code. The functions logisticWeight and linearWeight are already adjusted to the modification. Previous TWDTW analyses using these two functions are not affected by the changes in the code. Other user-defined functions will need adjustment. The weight function should now receive two matrices as arguments instead of one, such as the examples below.

logisticWeight <- function(alpha, beta){
  function(phi, psi) phi + 1 / (1 + exp(alpha * (psi - beta )))
}

linearWeight <- function(a, b=0){
  function(phi, psi) phi + a*psi + b
}

Also closes #51