简体   繁体   中英

Possible bug with arima.errors on transformed series (R forecast package)

It appears that arima.errors() ignores any Box-Cox transformation that may have been included in the model. Here's a quick example.

library(forecast)
set.seed(1)
xreg <- ts(4 + rnorm(150))
transformed <- 2 + 0.4 * xreg + arima.sim(list(ar=0.6, ma=c(-0.2, 0.3)), n=150, 
    n.start=50)
y <- InvBoxCox(transformed, lambda=0.5)
fit <- auto.arima(y, xreg=xreg, lambda=0.5, stepwise=F, approx=F)

In particular, it seems like this should yield a time series of 0s:

InvBoxCox(BoxCox(y, lambda=0.5) - (coef(fit)['xreg'] * xreg + coef(fit)['intercept']),
    lambda=0.5) - arima.errors(fit)

but this shouldn't:

y - (coef(fit)['xreg'] * xreg + coef(fit)['intercept']) - arima.errors(fit)

Am I missing something, or is this a bug?

This is a bug, now fixed on the github version at http://github.com/robjhyndman/forecast/ .

Note that the following will yield a time series of 0s:

BoxCox(y, lambda=0.5) - (coef(fit)['xreg'] * xreg + coef(fit)['intercept'])
 - arima.errors(fit)

That is, arima.errors is on the transformed scale, not the original scale.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM