splitting data into consecutive time intervals

Hi everyone,
I have as an example this time series data (boston) where I want to estimate and plot the trend component, the seasonal component, and the remainder (residual component). I did it like this:

install.packages("fma")
library(fma) 
plot(stl(boston[,1], s.window = "per"))
plot(stl(boston[,2], s.window = "per"))

Now I would like to split the data into two consecutive time intervals, where the second interval should contain about 1/4 of "boston".

The first interval will be used to estimate a model, and the second interval is used for prediction, which then can be compared to the data. For this purpose, I would like to visualize the first part of my time series with plot() , but enlarge the x-range in order to add a line for the second part later on. However, I am stuck here and don't know how to really proceed. Any help is appreciated.

I'm not familiar with the fma package. There will be more resources for the forecast package. For example, see the fpp2 text by Hyndman.

With ts objects and ets model objects You can use the window function on a time series object to separate it into a train and test set. Then you can fit a model and call forecast on the test set.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.