简体   繁体   English

R plot 华宇装 model 同原系列

[英]In R plot arima fitted model with the original series

I was using GRETL.我正在使用GRETL。 There, when I do the forecasting for the validation of the arima model, I will get the fitted series in blue line and the original series in red line.在那里,当我对 arima model 的验证进行预测时,我将得到蓝线的拟合序列和红线的原始序列。 Later, I switched to R and here I could not find any command to do the same.后来,我切换到 R ,在这里我找不到任何命令来做同样的事情。 I am using Arima model from forecast package.我正在使用来自预测 package 的 Arima model。

details,细节,

In GRETL I use to do model->time series -> arima -> forecast.在 GRETL 中,我使用模型 -> 时间序列 -> arima -> 预测。 It will automatically print the fitted and the original series.它将自动打印适合的系列和原始系列。 Any idea to do the same on R?任何想法在 R 上做同样的事情?

This question is fairly open ended, but here is a very, very basic answer.这个问题是相当开放的,但这是一个非常非常基本的答案。 Starting directly from one of the examples provided in the help files for Arima in the forecast package:直接从forecast package 中Arima的帮助文件中提供的示例之一开始:

fit <- Arima(WWWusage,order=c(3,1,0))

You say you want the original series in red and the fitted series in blue:你说你想要红色的原始系列和蓝色的拟合系列:

plot(fit$x,col="red")
lines(fitted(fit),col="blue")

which produces a plot that looks something like this:它产生一个看起来像这样的 plot:

有马

For basic questions like this, I suggest you spend some quality time here becoming familiar with some of R's basic functionality.对于这样的基本问题,我建议您在这里花一些时间熟悉 R 的一些基本功能。

The differences you are finding are because the arima() function is different from the Arima() function.您发现的差异是因为arima() function 与Arima() function 不同。 The former is contained in the basis stats package, the lattercomes from the package forecast and includes the fitted() function to predict over the observed values.前者包含在基础stats package 中,后者来自 package forecast并包括fitted() function 预测观察值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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