# Vector Autoregression - How do we choose the correct value of p?

VARselect(uschange[,1:2], lag.max=8,
type="const")[["selection"]]
#> AIC(n)  HQ(n)  SC(n) FPE(n)
#>      5      1      1      5


The R output shows the lag length selected by each of the information criteria available in the vars package. There is a large discrepancy between the VAR(5) selected by the AIC and the VAR(1) selected by the BIC. This is not unusual. As a result we first fit a VAR(1), as selected by the BIC.

var1 <- VAR(uschange[,1:2], p=1, type="const")
serial.test(var1, lags.pt=10, type="PT.asymptotic")

Portmanteau Test (asymptotic)

data:  Residuals of VAR object var1
Chi-squared = 49.102, df = 36, p-value = 0.07144

var2 <- VAR(uschange[,1:2], p=2, type="const")
serial.test(var2, lags.pt=10, type="PT.asymptotic")

Portmanteau Test (asymptotic)

data:  Residuals of VAR object var2
Chi-squared = 47.741, df = 32, p-value = 0.03633


We test that the residuals are uncorrelated using a Portmanteau test. Both a VAR(1) and a VAR(2) have some residual serial correlation, and therefore we fit a VAR(3).

var3 <- VAR(uschange[,1:2], p=3, type="const")
serial.test(var3, lags.pt=10, type="PT.asymptotic")

Portmanteau Test (asymptotic)

data:  Residuals of VAR object var3
Chi-squared = 34, df = 28, p-value = 0.2


I am not understanding how and why VAR(3) is selected here. I understood that VAR(1) and VAR(2) have some residual correlation and VAR(3) does not have, so we choose VAR(3). But, I am not able to understand how the author determined here that VAR(3) does not have any residual correlation, while VAR(1) and VAR(2) have. Is there any standard way to choose the value?

• There are many conflicting ways of choosing statistical models (including VAR with its own peculiarities) which are appropriate depending on the goal of the analysis. Overall, I find them quite confusing. It would take me more time than I have to write a comprehensive answer, and even then I would probably not be satisfied with it. So I hope you can get someone else on your case. Also, p-value is not a particularly relevant tag for this question IMHO, but that is no big deal. – Richard Hardy Mar 26 at 18:47

The function serial.test performs a Portmanteau test on the residuals of the VAR to determine if they are serially correlated. Read the section on the Portmanteau test from the same source to understand this test.

In the example you quote, the output from:

var1 <- VAR(uschange[,1:2], p=1, type="const")
serial.test(var1, lags.pt=10, type="PT.asymptotic")
var2 <- VAR(uschange[,1:2], p=2, type="const")
serial.test(var2, lags.pt=10, type="PT.asymptotic")


is not shown but it would look like the output from running

var3 <- VAR(uschange[,1:2], p=3, type="const")
serial.test(var3, lags.pt=10, type="PT.asymptotic")


except that the p-values would be less than 0.05 and so the results would indicate rejecting the null hypothesis of no residual correlation.

• I have run similar serial.test. None of the value of p is higher than 0.05, which value of p should be chosen in this case. The p-values are below: var2: p-value = 0.001724 || var3: p-value = 0.0006012 || var4: p-value = 0.001473 || var5: p-value = 0.02089 || var6: p-value = 0.04144 || var7: p-value = 0.03206 || var8: p-value = 0.004582 || var9: p-value = 5.929e-05 – Ritesh Sinha Mar 26 at 18:42
• What sort of data are you using? There are multiple reasons why this could happen. It could happen that the true model has >10 lags, in which case you should just estimate the model with more lags and do the same test. But there are other possible explanations. Seasonal affects could cause auto-correlation regardless of how many lags you include. You should also check whether your data is non-stationary. – Matt P Mar 26 at 19:00
• This is the value I get when I run VARselect: AIC(n) - 10 HQ(n) - 2 SC(n) - 2 FPE(n) - 10. I have seasonality in the data. But, the lag will remove it, that's what I understand. Should I remove the seasonality from the data before doing a serial test? Or it should be removed before VARselect? – Ritesh Sinha Mar 26 at 20:00
• The lags do not handle seasonality, and if seasonality not adjusted for you will have autocorrelation of the residuals at your seasonal frequency. You should either remove seasonality before fitting the VAR or include seasonal dummy variables (which can be done with the season option in var()). – Matt P Mar 26 at 20:48
• Do I need to remove the trend as well from the data? – Ritesh Sinha Mar 26 at 21:35