如何从R中的ar()方法模型获取拟合值 [英] How to get fitted values from ar() method model in R
本文介绍了如何从R中的ar()方法模型获取拟合值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从R
中的ar()
函数输出模型中检索拟合值.当使用Arima()
方法时,我使用fitted(model.object)
函数获取它们,但是找不到与ar()
等效的方法.
I want to retrieve the fitted values from an ar()
function output model in R
. When using Arima()
method, I get them using fitted(model.object)
function, but I cannot find its equivalent for ar()
.
推荐答案
它不存储拟合向量,但具有残差.使用ar
对象的残差从原始数据重构预测的示例:
It does not store a fitted vector but does have the residuals. An example of using the residuals from the ar
-object to reconstruct the predictions from the original data:
data(WWWusage)
arf <- ar(WWWusage)
str(arf)
#====================
List of 14
$ order : int 3
$ ar : num [1:3] 1.175 -0.0788 -0.1544
$ var.pred : num 117
$ x.mean : num 137
$ aic : Named num [1:21] 258.822 5.787 0.413 0 0.545 ...
..- attr(*, "names")= chr [1:21] "0" "1" "2" "3" ...
$ n.used : int 100
$ order.max : num 20
$ partialacf : num [1:20, 1, 1] 0.9602 -0.2666 -0.1544 -0.1202 -0.0715 ...
$ resid : Time-Series [1:100] from 1 to 100: NA NA NA -2.65 -4.19 ...
$ method : chr "Yule-Walker"
$ series : chr "WWWusage"
$ frequency : num 1
$ call : language ar(x = WWWusage)
$ asy.var.coef: num [1:3, 1:3] 0.01017 -0.01237 0.00271 -0.01237 0.02449 ...
- attr(*, "class")= chr "ar"
#===================
str(WWWusage)
# Time-Series [1:100] from 1 to 100: 88 84 85 85 84 85 83 85 88 89 ...
png(); plot(WWWusage)
lines(seq(WWWusage),WWWusage - arf$resid, col="red"); dev.off()
这篇关于如何从R中的ar()方法模型获取拟合值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文