I am looking to do time series forecasting with multiple variables. For example a data frame (df) of 4 different time series might look like this, where each column is its own time series:

    X1 X2 X3 X4
1   4 13  2 81
2  24 91 86 58
3  21 97 39  1    
4   1 56 79 55
5  63  6 91 79
6  66 96 95 81 

Let's say X1 is 'cost' and the other variables are things like temperature, volume, and #_of_people.

I would like to forecast 'cost' using the other 3 variables. I imagine using something like Vector Autoregressive Models (VAR) for Multivariate Time Series can be used to see how each variable impacts the other in each separate time series (one for each variable).

For example, using the vars package in r we can run forecasts against the 4 time series and plot the results:

var.2c <- VAR(df, p = 2, type = "const")
var.2c.prd <- predict(var.2c, n.ahead = 8, ci = 0.95)

enter image description here

As I understand it, 4 separate regression models were built, one for each variable, where all the other variables were considered for each one. In other words, 'cost' was forecasted, taking into consideration not just the 'cost' trends, but also the impact the other 3 variables (X2, X3, and X3) had on 'cost.'

My question is, say I wanted to take a date in the future, on the forecast of cost, and see what happens to that forecasted value when temperature is increased (X2). I am assuming I can just take the coefficients in the 'cost' regression model that was used to forecast 'cost' using VAR, and use them as you would normally. For example, if the coefficient says the 'cost' will increase by 5 dollars for every one unit increase in temperature (X2), then I could take the forecasted value at the date of interest and add the $5, to say that is what would happen to the forecasted value if X2 were to change.

Are my intuitions correct here or am I missing something? Are there better ways to run 'what-if' analyses on forecasted multivariate time series?

  • $\begingroup$ I’m typing on my mobile, so I’ll be very brief. I’d suggest you calculate the impulse response function using irf in vars $\endgroup$
    – Jonathan
    Nov 2, 2019 at 21:02


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.