使用 ARIMA 模型估算缺失值 [英] Imputing missing values using ARIMA model

查看:30
本文介绍了使用 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 提供样本内的一步预测.做你想做的事情的正确"方法是通过卡尔曼平滑器.使用缺失部分的前向和后向预测的平均值可以获得对大多数目的来说足够好的粗略近似值.像这样:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆