px <- seq(as.POSIXct('1949-01-01'),
as.POSIXct('1960-12-01'), by = 'month')
d0 <- data.frame(px, y = AirPassengers)
head(d0)
## px y
## 1 1949-01-01 112
## 2 1949-02-01 118
## 3 1949-03-01 132
## 4 1949-04-01 129
## 5 1949-05-01 121
## 6 1949-06-01 135
library('forecast')
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
y <- d0$y
s <- mstl(x = msts(y, seasonal.period = 12),
s.window = 'periodic')
autoplot(s, main = '周期成分:時間変動なし')
s <- mstl(x = msts(y, seasonal.period = 12))
autoplot(s, main = '周期成分:時間変動あり')
月間であるため周期は12。