# Time Series Forecasting

I work in the Oil & Gas industry.

I have been trying to build a ts forecasting model with covariates, and the model R code is as follows:

#Getting R libraries:
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)


However, I have been trying to forecast the retail volume sales 12,24,36, etc months out. The model only generates the following result:

Model fit results:

Please may I ask that you kindly advise on how I can get my model to forecast beyond end = c(2019,12). I am missing something?

• Hi Stephen. Thanks for the reply. I doubt a smaller h parameter would work as I added the parameter only today. I will give it a try but a model with the xreg argument always ignores the h parameter. – Greaves Jan 13 at 16:18