How to do it...

In this recipe, we will work with multiple time series related to oil/gas in Argentina. The objective will be to model these series as a unique model, and then make predictions out of that model:

  1. As usual, we first load the data:
library(vars)  oilgas = read.csv("./fuel_series.csv")  colnames(oilgas)  = c("time_index","oil_processed","gasoil_prod","fueloil_prod","butane") joined_data = ts(oilgas[-1],start=c(1996,1),frequency=12)  
  1. Because the data is collected monthly, it is a good practice to set the lag number to 12 (this way, every month will be correlated to the same month in different years). But this is problematic in some ways, because it means that each equation will have 12 lags x 3 variables = 36 coefficients just ...

Get R Statistics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.