# Fitting and forecasting a multivariate time series model (VAR) in R

I have some quarterly time series data for accumulated total public expenses and the total budget that I want to forecast. I also have subsets of the total public expenses, eg. health expenses and health budget. My data looks like this (though, there are in fact 18 subsets):

> ts_data
TotalExpenses TotalBudget HealthExpenses EducationExpenses AdministrationExpenses HealthBudget EducationBudget AdministrationBudget
2009 Q1      52411.62    53176.66       1310.350          9948.443               7374.134     1511.097        9921.829             6744.288
...
2018 Q1      57629.81    61523.61       1848.972         10483.658               7892.594     2146.616       11046.709             8059.006
2018 Q2     122115.71   123047.21       4108.965         22429.270              16409.275     4293.232       22093.418            16118.013
2018 Q3     184652.91   184570.82       6087.974         32854.125              25155.109     6439.848       33140.128            24177.019
2018 Q4     245856.70   246094.43       8564.202         44725.026              31954.242     8586.464       44186.837            32236.025
2019 Q1      59957.03    62980.76       1941.414         10736.668               8099.793     2207.865       11131.948             8256.064
2019 Q2     123841.60   125961.52       4145.150         22609.336              16569.918     4415.731       22263.896            16512.127
2019 Q3     189282.65   188942.27       6148.431         33651.516              24236.661     6623.596       33395.845            24768.191
2019 Q4            NA   251923.03             NA                NA                     NA     8831.462       44527.793            33024.254


My final goal is to forecast Total Expenses in 2019Q4 as precisely as possible.

As expected, there is a strong relationship between the budgets and the actual expenses as can be seen in the graph. The same applies to (most of) the subsets My idea was to use all the subsets of the total expenses as endogenous variables in a VAR (Vector Autoregession) model and all the subsets of the budget as exogenous regressors. Then forecast the endogenous variabel and add them all together to obtain a forecast of the total expenses. The problem is, however, is that when I fit the model it seems like a get a lot of spurious correlation. I set up my model as follows

endovar <- cbind(ts_data[,"TotalExpenses"],ts_data[,"HealthExpenses"],ts_data[,"EducationExpenses"],ts_data[,"AdministrationExpenses"])
trainendo <- window(endovar,start = c(2009,1), end = c(2019,3))
trainexo <- window(exovar,start = c(2009,1), end = c(2019,3))
testexo <- window(exovar,start = c(2019,4), end = c(2019,4))
VARselect(trainendo, season = 4, exogen = trainexo)
VAR_fit <- VAR(trainendo, season = 4, exogen = trainexo, type = c("none"))


First, I am unsure whether it is a problem that my series are not stationary or if it is enough that I include the season option when fitting the model?

Second, if we look at the estimation results for administration expenses, it depends heavily on health expenses and budget, but not so much on administration budget, which I find highly unlikely. I guess it is because of spurious correlation.

> summary(VAR_fit)

VAR Estimation Results:
=========================
Endogenous variables: ts_data....TotalExpenses.., ts_data....HealthExpenses.., ts_data....EducationExpenses.., ts_data....AdministrationExpenses..
Deterministic variables: none
Sample size: 42
Log Likelihood: -1157.028
Roots of the characteristic polynomial:
1.031 0.4474 0.4474 0.009918
Call:
VAR(y = trainendo, type = c("none"), season = 4L, exogen = trainexo)
…
Estimation results for equation ts_data....AdministrationExpenses..:
====================================================================
ts_data....AdministrationExpenses.. = ts_data....TotalExpenses...l1 + ts_data....HealthExpenses...l1 + ts_data....EducationExpenses...l1 + ts_data....AdministrationExpenses...l1 + sd1 + sd2 + sd3 + ts_data....TotalBudget.. + ts_data....HealthBudget.. + ts_data....EducationBudget.. + ts_data....AdministrationBudget..

Estimate Std. Error t value Pr(>|t|)
ts_data....TotalExpenses...l1           1.497e-02  4.374e-02   0.342 0.734447
ts_data....HealthExpenses...l1         -1.127e+00  3.998e-01  -2.818 0.008334 **
ts_data....EducationExpenses...l1      -6.930e-02  1.139e-01  -0.608 0.547347
ts_data....AdministrationExpenses...l1  3.940e-01  2.495e-01   1.579 0.124566
sd1                                    -2.502e+03  3.642e+03  -0.687 0.497277
sd2                                     1.299e+03  1.707e+02   7.609 1.40e-08 ***
sd3                                     1.097e+03  1.687e+02   6.501 2.98e-07 ***
ts_data....TotalBudget..               -8.695e-02  3.650e-02  -2.382 0.023518 *
ts_data....HealthBudget..               1.316e+00  3.116e-01   4.223 0.000196 ***
ts_data....EducationBudget..            5.037e-01  1.687e-01   2.986 0.005481 **
ts_data....AdministrationBudget..       5.006e-01  1.523e-01   3.287 0.002521 **
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 269.4 on 31 degrees of freedom
Multiple R-Squared: 0.9999, Adjusted R-squared: 0.9998
F-statistic: 2.191e+04 on 11 and 31 DF,  p-value: < 2.2e-16


I know that there are probably hundreds of things that I am doing wrong, but I hope you can help by pointing me in the right direction and give me some ideas to how I should approach this problem. For example:

• Is VAR the right choice of model or should I be looking at a VEC model or something else
• Should I drop the accumulated data (though I think I would lose some valuable information if I did, because of the strong link between expenses and budget)
• Can I include TotalExpenses as well as subsets of TotalExpenses as endogenous variables at the same time?

Thank you! I hope my questions make a little bit of sense.