robjhyndman / forecast

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

damping in ets() #920

Closed Alexej36 closed 1 year ago

Alexej36 commented 2 years ago

Hi,

a perhaps cosmetic issue, but one cannot pass 1 or 0 to the "damped" argument in the ets() function

set.seed(1)
my_ts <- rnorm(36,0,1)

# this works fine
forecast::forecast(ets(my_ts, model="AAN", damped = TRUE))
forecast::forecast(ets(my_ts, model="AAN", damped = FALSE))

# however this does not work
forecast::forecast(ets(my_ts, model="AAN", damped = 1))
forecast::forecast(ets(my_ts, model="AAN", damped = 0))

The last two lines generate

Error in if (damped) { : missing value where TRUE/FALSE needed

robjhyndman commented 2 years ago

Why do you want to? damped is a logical argument, so 0 and 1 are not correct inputs.

Alexej36 commented 2 years ago

Because TRUE/FALSE and 1/0 are often used interchangeably E.g. in auto.arima it works both ways:

set.seed(1)
my_ts <- rnorm(36,0,1) + (1:36)
auto.arima(my_ts, stationary = 1)
auto.arima(my_ts, stationary = TRUE)
robjhyndman commented 2 years ago

Just because it sometimes works doesn't mean we should always allow it.