简体   繁体   English

如何用原始时间序列绘制Arima模型?

[英]How to plot Arima model with original time series?

I plot my original data set 我绘制了原始数据集

ggplot(piz, aes(Date, Price.Dollars.per.Thousand.Cubic.Feet)) + geom_line()

在此处输入图片说明

Later I have extracted one column and performed ARIMA modeling. 后来,我提取了一篇专栏文章,并进行了ARIMA建模。

fit1
Series: a1 
ARIMA(4,1,1) 
plot(forecast(fit,h=48))

My image 我的形象 在此处输入图片说明

If I go for autoplot solution 如果我寻求自动绘图解决方案

> a1=ts(a1)
> autoplot(a1) + forecast::autolayer(fit1)
Error in UseMethod("autolayer") : 
  no applicable method for 'autolayer' applied to an object of class "c('ARIMA', 'Arima')".

I am adding sample dataset 我正在添加样本数据集

Date     Price Dollars per Thousand Cubic Feet
Jan-2002    3.1
Feb-2002    2.86
Mar-2002    3.37
Apr-2002    3.8
May-2002    3.78
Jun-2002    3.61

How to plot them together? 如何将它们绘制在一起?

Try something like this: 尝试这样的事情:

  db<-data.frame(x=c(1:1000)+round(runif(1000,min = 5, max=100),0),
  date=seq(as.Date("2000/1/1"), by = "day", length.out = 1000))

  fit<-auto.arima(y = db$x)

  plot(fit$x~as.Date(db$date),col="red",type="l",xaxt = "n",)
  lines(fitted(fit)~as.Date(db$date),col="blue")
  axis(1, db$date, format(db$date, "%b %d"), cex.axis = .7)

在此处输入图片说明

With a sample of your data I could be more specific. 通过您的数据样本,我可以更具体一些。

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

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