Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How to use the 'stl' function for seasonal decomposition on training data?

$
0
0

For a school project I have to do some coding in R and comment on the results found. Currently, I am a bit stuck here. Let me show my code first:

# Create time series object
tsTradeBalance <- ts(dfTrade$BalanceTotal, frequency=12, start=c(2007, 1))

tsTradeBalance.train  <- window(tsTradeBalance, end=c(2019, 1))
tsTradeBalance.test   <- window(tsTradeBalance, start=c(2019, 2))

# Start with the seasonal decomposition:
plot(stl(tsTradeBalance.train, s.window="periodic"))
stl(tsTradeBalance.train, s.window="periodic")

The idea is that I have a dataframe with trade balance data ranging from 2007-2019 November. I have a hold-out period of the last ten months (2019 February-November) and a training period for the period before. This can also be found in the code. The idea of the question is now that I have to estimate a seasonal decomposition model for the training data. After I have done this for the seasonal decomposition, I have to do the same for the Holt-Winters and multiplicate Holt-Winters model. The results should be put in a ggplot for comparison purposes. I have not used the stl function before, but I should use it in this question.

Could someone help me explain what I have to do? I don't really know what the s.window means, should I select here the test period?

Thanks in advance!


Viewing all articles
Browse latest Browse all 201839

Trending Articles