简体   繁体   English

R预测自动绘图或hchart

[英]R forecast autoplot or hchart

would like to do multiple arima time series plot for each - Cooked and market - as shown in the image below. 希望针对每个-煮熟的市场和市场-做多个Arima时间序列图,如下图所示。 Have tried both autoplot and hchart but both does not work. 尝试了自动绘图和hchart,但都无法正常工作。 Please advise and assist. 请指教和协助。 Any help would be very much appreciated. 任何帮助将不胜感激。

forecast1<-ts(lapply(arima, function(x) forecast(auto.arima(x), level=95)))

autoplot(forecast1)
hchart(forecast1)

数据:

I took the step of turning the data into a time series before using the forecast algorithm. 在使用预测算法之前,我采取了将数据转换为时间序列的步骤。 Then printing the chart is just a matter of using apply on the new list that is generated. 然后,打印图表只是在生成的新列表上使用Apply的问题。 Please see the code below. 请参见下面的代码。

Year <- seq(2012, 2018)
Cooked <- c(157.4, 157.2, 168.8, 192.3, 201.8, 233.4, 241.2)
Market <- c(51.7, 44.9, 49.5, 53.6, 57.2, 54.1, 53.5)
df <- as.data.frame(cbind(Year, Cooked, Market))
ts_df <- ts(df[, -1], start = 2012, frequency = 1)

library(forecast)
forecast1<-lapply(ts_df, function(x) forecast(auto.arima(x), level=95))

lapply(forecast1, function(x) autoplot(x))

I recommend in future questions, putting the data together in a similar script to help us help you. 我建议在以后的问题中,将数据放在一个类似的脚本中,以帮助我们为您提供帮助。

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

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