使用ARIMA模型估算缺失值 [英] Imputing missing values using ARIMA model
本文介绍了使用ARIMA模型估算缺失值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用R中的ARIMA模型来估算时间序列中的缺失值.我尝试了这段代码,但没有成功.
I am trying to impute missing values in a time series with an ARIMA model in R. I tried this code but no success.
x <- AirPassengers
x[90:100] <- NA
fit <- auto.arima(x)
fitted(fit)[90:100] ## this is giving me NAs
plot(x)
lines(fitted(fit), col="red")
拟合的模型未估算缺失值.关于如何做到这一点的任何想法?
The fitted model is not imputing the missing values. Any idea on how this is done?
推荐答案
fitted
提供了样本内一步式预测.做您想要的事的正确"方法是通过Kalman平滑器.使用缺失部分的前向和后向预测的平均值,可以获得对大多数目的都足够好的粗略近似值.像这样:
fitted
gives in-sample one-step forecasts. The "right" way to do what you want is via a Kalman smoother. A rough approximation good enough for most purposes is obtained using the average of the forward and backward forecasts for the missing section. Like this:
x <- AirPassengers
x[90:100] <- NA
fit <- auto.arima(x)
fit1 <- forecast(Arima(AirPassengers[1:89],model=fit),h=10)
fit2 <- forecast(Arima(rev(AirPassengers[101:144]), model=fit), h=10)
plot(x)
lines(ts(0.5*c(fit1$mean+rev(fit2$mean)),
start=time(AirPassengers)[90],freq=12), col="red")
这篇关于使用ARIMA模型估算缺失值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文