robjhyndman / anomalous-acm

Anomalous time series package for R (ACM)
119 stars 30 forks source link

Calculation of trend wrong for series without seasonality? #6

Closed cbergmeir closed 7 years ago

cbergmeir commented 7 years ago

In line 184 of tsmeasures.R, you have:

      trend0 <- fitted(mgcv::gam(contx ~ s(tt)))
      remainder <- contx - trend0
      deseason <- contx - trend0
v.adj <- var(trend0, na.rm = TRUE)

It seems to me that it needs to be: v.adj <- var(remainder, na.rm = TRUE)

instead. This would be in line with the seasonal case and with a slide deck that I read on the topic (http://robjhyndman.com/seminars/big-time-series/). Also, I was getting trends of 1 for series that don't seem to have a trend, and trend of 0 with series that seem to have one.

earowang commented 7 years ago

Thanks for pointing this out. Fixed now.