The stl function in the stats package decomposes a time series into seasonal, trend, and remainder:
stl
stats
sstl <- stl(ts(rnorm(100), frequency=12), "period") plot(sstl)
The seasonality is a regular pattern, how can I continue this pattern for the next 50 data points?
You could extract the unique values of the seasonal component and then use rep_len to create a vector of length 150 as follows
rep_len
rep_len(unique(sstl$time.series[, "seasonal"]), length.out = 150)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.