ARIMA预测不断收到错误数据'必须是矢量类型,是' NULL'

时间:2017-12-17 05:50:17

标签: r arima

我在将ARIMA安装到数据时遇到错误,数据'必须是矢量类型,是' NULL'。

mysql-connector-java-5.1.45-bin.jar
  

数组中的错误(x,c(length(x),1L),if(!is.null(names(x)))list(names(x),):     '数据'必须是矢量类型,是' NULL'

我根本不理解我做错了什么,如果有人看到这个问题,我将不胜感激。 谢谢 -MF

1 个答案:

答案 0 :(得分:2)

library(forecast)
foo <- read.table(file="data.csv", header=T, sep=",")
data <- ts(foo$Car,start = c(1990,1),frequency = 1)

# Use 'forecast' to get predition from the model estimated by 'auto.arima'
ARIMAfit1 <- auto.arima(log10(data), approximation=T, trace=FALSE, allowdrift=F)
summary(ARIMAfit1)
forecast(ARIMAfit1, h = 3)

#      Point Forecast    Lo 80    Hi 80     Lo 95    Hi 95
# 2017       1.415713 1.165870 1.665556 1.0336109 1.797815
# 2018       1.415713 1.128307 1.703119 0.9761635 1.855262
# 2019       1.415713 1.095115 1.736310 0.9254014 1.906024


# The same model estimated using 'arima'
# Here you can use 'predict'
ARIMAfit2 <- arima(log10(data), order=c(0,1,1))
summary(ARIMAfit2)
predict(ARIMAfit2, n.ahead=3)

# $pred
# Time Series:
# Start = 2017 
# End = 2019 
# Frequency = 1 
# [1] 1.415713 1.415713 1.415713
# $se
# Time Series:
# Start = 2017 
# End = 2019 
# Frequency = 1 
# [1] 0.1911677 0.2199090 0.2453055