robjhyndman / forecast

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

Make Biasadjust TRUE if specified at modelling stage #326

Closed robjhyndman closed 7 years ago

robjhyndman commented 8 years ago

e.g.,

fit <- auto.arima(AirPassengers,lambda=0,biasadj=TRUE)
forecast(fit)

It would be better if the latter automatically set biasadj=TRUE if it has been specified earlier. This probably requires adding a biasadj component to an Arima object.

mitchelloharawild commented 8 years ago

Arima() currently doesn't accept a biasadj term as it does not output fitted values. Should the object returned from Arima() be made consistent with the object returned from auto.arima()?

robjhyndman commented 8 years ago

Actually I think auto.arima does not return fitted values (and ignores the biasadj term) if stepwise=TRUE. It would be better if both Arima and auto.arima returned fitted values, and both returned the biasadj term for use by forecast.Arima. Similarly, any other modelling function where biasadj is passed should return it for use in forecast.xxx().

mitchelloharawild commented 8 years ago

I figured that the stepwise condition causing different output (existence of fitted values) was weird.

Do you foresee any issues adding an biasadj attribute to the lambda variable?

lambda <- 0.5
attributes(lambda) <- list(biasadj = TRUE)
robjhyndman commented 8 years ago

That should work ok. You might need to strip the attribute inside BoxCox and InvBoxCox so it doesn't get attached to anything else.

mitchelloharawild commented 8 years ago

Didn't seem to cause problems in those functions, but I'll double check.

mitchelloharawild commented 7 years ago

Whilst updating the code for this, I was thinking, maybe InvBoxCox() should be given the biasadj parameter, and InvBoxCoxf() should be merged into InvBoxCox?

There's a lot of duplicated code around use of biasadj in every forecasting function, which this should drastically cut down on.

robjhyndman commented 7 years ago

Yes, that makes sense.

mitchelloharawild commented 7 years ago

Added in #411