-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fitted values on re-fitted model seem to be affected by new data #798
Comments
+1 |
I get the same result in fable - why is the change in fitted values unexpected? |
Because a fitted value is a one-step forecast, and should not be affected by the following observation. |
MRE directly from It also seems to happen within ARIMA_Like, which updates the model based on data when computing the fit - will need to dig deeper into this later. # Create training and two sets of test data
training <- USAccDeaths[1:60]
test2 <- test <- USAccDeaths[61:72]
test2[12] <- test[12] + 2
fit <- stats::arima(log(training), order = c(0,1,0), seasonal = c(0,1,1))
refit1 <- stats::arima(log(test), order = c(0,1,0), seasonal = c(0,1,1), fixed = coef(fit))
refit2 <- stats::arima(log(test2), order = c(0,1,0), seasonal = c(0,1,1), fixed = coef(fit))
exp((log(test) - refit1$residuals)[10:12])
#> [1] 9270.875 9187.616 8740.719
exp((log(test2) - refit2$residuals)[10:12])
#> [1] 9270.875 9187.616 8740.807 Created on 2019-06-04 by the reprex package (v0.2.1) |
@robjhyndman @mitchelloharawild Looking at the code, this behavior actually makes sense. When you fit the model, it uses the Kalman filter from the stats::arima. This includes two steps: a forward pass (filtering) and a backward pass (smoothing). During the backward pass, the entire data set including future observations helps to refine the model estimates. Because of this, the fitted values can change once you add more data, even if the model parameters stay the same. This behavior is normal for the Kalman, and for sure it is not a bug. |
Created on 2019-05-01 by the reprex package (v0.2.1)
Why does the last fitted value change?
The text was updated successfully, but these errors were encountered: