For context, my long term goal is to study fire impacts and fire recovery from monthly NDVI series. Before doing that 'd like to remove any long term trend from the data, e.g. due to climate.
I am using STL decomposition to estimate the trend, using the R function feasts::STL().
My question can be partitioned into two parts:
- How to chose an appropriate window for loess smoothing, when using it to detrend noisy timeseries with a seasonal pattern?
- How can the window length be controlled in
feasts::STS()? (though I am open for othertidyversesolutions as well)
This is my code, with df being a tsibble object
df %>% model(STL(evi_filled ~ season(period = 12, window = Inf))) %>%
components() %>%
autoplot()
and this is the result:
It clearly did the job but I feel this is not reasonable. What I think is happening is that it takes only the first year to estimate the seasonality and all the variability is captured by the trend, which looks very squiqqly. I'd rather have a larger window for estimating the trend.
I thus ask it to use more data to estimate seasonality:
df %>% model(STL(evi_filled ~ season(period = 12*10, window = Inf))) %>% components() %>% autoplot()
This looks more like what I had in mind, but it also feels a bit hacky, and the way the seasonality exhibits a regular pattern trips me out. So ultimately my question is: Is this a correct implementation of both the statistical method and the R function?

