3
$\begingroup$

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:

  1. How to chose an appropriate window for loess smoothing, when using it to detrend noisy timeseries with a seasonal pattern?
  2. How can the window length be controlled in feasts::STS()? (though I am open for other tidyverse solutions 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:

Time series decomposition plot with small window

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?

Time series decomposition plot with large window

$\endgroup$

1 Answer 1

3
$\begingroup$

There are extensive online resources that you should look at. Start with https://otexts.com/fpp3/stl.html

The feasts::STL() function is a wrapper to stats::stl(), so you should also read the help file for stats::stl().

By setting the window to be infinite, you are forcing a periodic seasonal component. It is estimated across the whole time series.

The default values usually work quite well. Try them before trying to choose values yourself.

$\endgroup$
1
  • $\begingroup$ Thanks, that's been very helpful! I adapted the code to df %>% model(STL(evi_filled ~ season(period = 12) + trend(window = 12*20))) %>% components() %>% autoplot() which looks a lot better $\endgroup$ Commented Jul 15 at 23:07

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.