px <- seq(as.POSIXct("1949-01-01"),
as.POSIXct("1960-12-01"), by = "month")
d0 <- data.frame(px, y = AirPassengers)
library(DT)
datatable(d0)
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)
## Warning: パッケージ 'forecast' はバージョン 4.4.2 の R の下で造られました
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
s <- mstl(x = msts(d0$y, seasonal.period = 12),
s.window = "periodic")
autoplot(s, main = "周期成分:時間変動なし")

s <- mstl(x = msts(d0$y, seasonal.period = 12))
autoplot(s, main = "周期成分:時間変動あり")
