我在石油天然气行业工作。
我一直试图建立一个具有协变量的ts预测模型,模型R代码如下:
#Getting R libraries:
library(readxl)
library(ggplot2)
library(forecast)
library(timeSeries)
library(tseries)
library(MTS)
#Create a time series object:
myts <- ts(dataset, start = c(2005,1), end = c(2019,12), frequency = 12)
#Illustrate out of sample forecasting with covariates, splitting the data:
train <- window(myts, end = c(2018,12))
test <- window(myts, start = c(2019,1))
#Fitting the time series forecasting model:
covariates <- c("Income","Prices","Sites","Vehicles")
fit <- auto.arima(train[,"Volumes"], xreg = train[,covariates])
#Forecasting from test data:
mytsfcast <- forecast(fit, h = 6*12, xreg = test[,covariates])
autoplot(mytsfcast)然而,我一直试图预测零售额12,24,36,等等几个月后。该模型只生成以下结果:
模型拟合结果:
请告知我如何才能使我的模型预测到end = c(2019,12)。我漏掉了什么?
发布于 2020-01-13 16:01:38
我一直无法复制空白模型的拟合结果。但是,我知道预测函数只能预测到已知的xreg输入。例如,您的测试周期从1/2019开始,到12/2019 (12期)结束,但是您试图预测72期。尝试将预测函数中的h参数设置为12,并查看是否得到相同的结果。
为了在过去解决这个问题,我预测了未来的xreg系列(在您的例子中,四个xreg变量中的每一个都会增加60个周期)。然后,您将需要将这60个句点添加到每个变量的测试集的末尾。
https://datascience.stackexchange.com/questions/66405
复制相似问题