robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.1k stars 340 forks source link

ETS() Non Seasonal data error #937

Closed pstamolampros closed 1 year ago

pstamolampros commented 1 year ago

install.packages("forecast") library("forecast")

data(AirPassengers) AP <- AirPassengers

This will return an (M,Ad,M) model fit<- ets(AP)

same observations but will return (M,N,N) fit2<- ets(AP[1:144])

this return an error no seasonal data fit3 <- ets(AP[1:144], model="MAM")

robjhyndman commented 1 year ago

By subsetting the data in this way, it loses its time series attributes including the frequency, so ets() does not know it is seasonal data. The correct way to subset a time series without losing information is to use either subset(AP, end=144), or window(AP, end=c(1960,12)).

pstamolampros commented 1 year ago

Thank you for your reply and for sharing your great work

I do have another question about the qualified model from the automatic ets(). From the output below I understand that the MMM model is better based on the information criteria but the "ZZZ" selects the MAM. What Am I missing?

`> data(AirPassengers)

AP <- AirPassengers AP.train <- window(AP, end=c(1958,3)) AP.test <- window(AP, start=c(1958,4)) ets(AP.train , model="ZZZ") ETS(M,Ad,M)

Call: ets(y = AP.train, model = "ZZZ")

Smoothing parameters: alpha = 0.75 beta = 0.0233 gamma = 1e-04 phi = 0.98

Initial states: l = 120.3561 b = 1.7593 s = 0.9013 0.799 0.9181 1.06 1.2002 1.2147 1.1032 0.9775 0.9877 1.0297 0.8985 0.9101

sigma: 0.0371

 AIC     AICc      BIC 

1004.257 1011.692 1053.028

ets(AP.train , model="MMM") ETS(M,Md,M)

Call: ets(y = AP.train, model = "MMM")

Smoothing parameters: alpha = 0.7209 beta = 0.0134 gamma = 1e-04 phi = 0.9789

Initial states: l = 120.3501 b = 1.0134 s = 0.903 0.7993 0.919 1.0591 1.2002 1.2139 1.1036 0.9754 0.9858 1.0296 0.8998 0.9113

sigma: 0.037

 AIC     AICc      BIC 

1003.631 1011.065 1052.402 `

robjhyndman commented 1 year ago

The automatic search does not consider multiplicative trend models. See the allow.multiplicative.trend argument.