0

this is my first post so sorry if this is clunky or not formatted well.

 period texas u3    national u3

1976    5.758333333 7.716666667

1977    5.333333333 7.066666667

1978    4.825   6.066666667

1979    4.308333333 5.833333333

1980    5.141666667 7.141666667

1981    5.291666667 7.6

1982    6.875   9.708333333

1983    7.916666667 9.616666667

1984    6.125   7.525

1985    7.033333333 7.191666667

1986    8.75    6.991666667

1987    8.441666667 6.191666667

1988    7.358333333 5.491666667

1989    6.658333333 5.266666667

1990    6.333333333 5.616666667

1991    6.908333333 6.816666667

1992    7.633333333 7.508333333

1993    7.158333333 6.9

1994    6.491666667 6.083333333

1995    6.066666667 5.608333333

1996    5.708333333 5.416666667

1997    5.308333333 4.95

1998    4.883333333 4.508333333

1999    4.666666667 4.216666667

2000    4.291666667 3.991666667

2001    4.941666667 4.733333333

2002    6.341666667 5.775

2003    6.683333333 5.991666667

2004    5.941666667 5.533333333

2005    5.408333333 5.066666667

2006    4.891666667 4.616666667

2007    4.291666667 4.616666667

2008    4.808333333 5.775

2009    7.558333333 9.266666667

2010    8.15    9.616666667

2011    7.758333333 8.95

2012    6.725   8.066666667

2013    6.283333333 7.375

2014    5.1 6.166666667

2015    4.45    5.291666667

2016    4.633333333 4.866666667

2017    4.258333333 4.35

2018    3.858333333 3.9

2019    ____    3.5114

2020    ____    3.477

2021    ____    3.7921

2022    ____    4.0433

2023    ____    4.1339

2024    ____    4.2269

2025    ____    4.2738

How can one use auto.arima in R with an external regressor to make a forecast but only plot the out-of-sample values? I believe the forecast values are correct but the years do not match up correctly. So if I have annual data from 1976-2018 and I forecast the dependent variable (column 2) (I want to forecast through 2025), it plots the "forecast" for the time period 2019-2068. Weirdly enough, the figures match up well with the sample data (the "forecast" for 2019 seems to be the model prediction for 1980 and so on, all the way through 2068 matching 2025.

I would like to be able to eliminate that and have it so "2062-2068" results are instead 2019-2025. I'll try and include a picture of the plot so it might be easier to visualize my plight.

Below is the R script:

#Download the CVS file, the dependent variable in the second column, xreg in the third, and years in the first. All columns have headers.

library(forecast)
library(DataCombine)
library(tseries)
library(MASS)
library(TSA)

ts(TXB102[,2], frequency = 1, start = c(1976, 1),end = c(2018, 1)) -> TXB102ts
ts(TXB102[,3], frequency = 1, start = c(1976, 1), end = c(2018,1)) -> TXB102xregtest
ts(TXB102[,3], frequency = 1, start = c(1976, 1), end = c(2025,1)) -> TXB102xreg

as.vector(t(TXB102ts)) -> y
as.vector(t(TXB102xregtest)) -> xregtest
as.vector(t(TXB102xreg)) -> xreg

y <- ts(y,frequency = 1, start = c(1976,1),end = c(2018,1))
xregtest <- ts(xregtest, frequency = 1, start = c(1976,1), end=c(2018,1))
xreg <- ts(xreg, frequency = 1, start = c(1976,1), end=c(2025,1))

summary(y)
plot(y)

ndiffs(y)

ARIMA <- auto.arima(y, trace = TRUE, stepwise = FALSE, approximation = FALSE, xreg=xregtest)

ARIMA

forecast(ARIMA,xreg=xreg)
plot(forecast(ARIMA,xreg=xreg))   

The following is a plot of what I get after running the script.

Plot

TLDR: How do I get the real out-of-sample forecast to plot for 2019-2025 as opposed to the in-sample model fit it is passing along as 2019-2068.

0 Answers0