在R中没有ARIMA模型的结果

时间:2018-06-05 23:55:29

标签: r rstudio data-mining forecasting arima

我是R的初学者,现在我正在研究一个小项目进行研究。

我每天都有空气质量数据集(no2,o3,...),我正在尝试预测这些值。

我正在做的是,我正在阅读2014年,2015年和2016年的价值,然后尝试预测2017年的价值(我有它们,所以我可以比较和评估模型的性能)。

不幸的是,我没有得到预测结果。

问题是:我的代码中是错误还是缺少参数?

有一段时间我以为日常价值观正在扼杀它,但我没有证据所以我继续说道。 该代码适用于航空旅客预测(月度值),但不适用于空气质量(每日价值)。

感谢您的帮助!

You can download my data Sets

#Read data files
Data14 <- read.csv2(file = "indices_QA_commune_IDF_2014.csv", header = TRUE, sep = ",", dec = ",")
Data15 <- read.csv2(file = "indices_QA_commune_IDF_2015.csv", header = TRUE, sep = ",", dec = ",")
Data16 <- read.csv2(file = "indices_QA_commune_IDF_2016.csv", header = TRUE, sep = ",", dec = ",")

#Merge all data into one frame
completeData <- rbind(Data14, Data15, Data16)

#Filter data, we choose "75" for Paris
DataParis <- subset(completeData, ninsee == 75)

#isolate no2 values and store them in a vector
DataParisNo2 <- DataParis[['no2']]

#create a time series from the vector
tsno2 <- ts(DataParisNo2, start=c(2014, 1), end=c(2016, 12), frequency=365)

#verify if we have a time series (sucess)
class(tsno2)

#let's plot our series
plot(tsno2)

#we plot the mean value
abline(reg=lm(tsno2~time(tsno2)))

#Now we use log to make the variance equal in every point
#and we use diff to have a constant mean value
#our time series is now stationary and we can proceed
plot(diff(log(tsno2)))

#we apply ARIMA model

arima <- auto.arima(tsno2)
arima

ggtsdiag(arima)

#we generate forecast
forecast <- forecast(arima, level = c(95), h = 240)
autoplot(forecast)

results for air quality forecast (current code)

results for air passengers forecast (same method, almost same code)

0 个答案:

没有答案