4 added 15 characters in body; edited tags; edited title
source | link

R: Best practice to testof testing for serial correlation in VAR residuals in R?

I want to examine the residuals of a VAR and apply the LM test for serial correlation (autocorrelation) like in (like herethis) blog post by Dave Giles. In my test, I first examine the optimum lag length for two time series with an intercept and trend and go from here:

VAR <- VAR(data.frame(data[1],data[2]),p=2, type="both")
VARselect(VAR),lag.max = 12, type="both")

$selection
AIC(n)  HQ(n)  SC(n) FPE(n) 
    4      1      1      2 

Now, like in the example of the link above, I want to check which of the proposed lags has the lowest likelihood of serial correlation in the VAR. Following works with serial.test, that (I assume) obviously automatically selects the residuals from a VAR.

Now I discovered following testing methods:

  1. serial.test() from the vars package - Apparently a Portmanteau Test (asymptotic) statistics for every defined VAR:

    serial.test(VAR)

or Breusch-Godfrey LM test:

serial.test(VAR, type="BG")
  1. Box.test() from base - Can perform the Ljung-Box text, but only for one column ([,1]):

    Box.test(residuals(VAR), type = c("Ljung-Box"))

does not work. It returns "x is not a vector or univariate time series". Apparently, Box.test does not work with VAR? It apparently only works with residuals(VAR)[,1], i.e. selecting one column of the residuals.

  1. dwtest() from the lmtest package - performs the Durbin-Watson test:

    dwtest(residuals(VAR)[,1] ~ residuals(VAR)[,2])

  2. bgtest() from the lmtest package - performs the Breusch-Godfrey zest:

    bgtest(res_data[,1] ~ res_data[,2])

Questions:

  • Do I approach the test correctly (especially, not selecting a lag after the VAR was defined with a lag already)?
  • What would you recommend to do?
  • Can you confirm that Box.test()Box.test() does not work with VAR?

Thank you!

R: Best practice to test for serial correlation in R?

I want to examine the residuals of a VAR and apply the LM test for serial correlation (autocorrelation) (like here). In my test, I first examine the optimum lag length for two time series with an intercept and trend and go from here:

VAR <- VAR(data.frame(data[1],data[2]),p=2, type="both")
VARselect(VAR),lag.max = 12, type="both")

$selection
AIC(n)  HQ(n)  SC(n) FPE(n) 
    4      1      1      2 

Now, like in the example of the link above, I want to check which of the proposed lags has the lowest likelihood of serial correlation in the VAR. Following works with serial.test, that (I assume) obviously automatically selects the residuals from a VAR.

Now I discovered following testing methods:

  1. serial.test() from the vars package - Apparently a Portmanteau Test (asymptotic) statistics for every defined VAR:

    serial.test(VAR)

or Breusch-Godfrey LM test:

serial.test(VAR, type="BG")
  1. Box.test() from base - Can perform the Ljung-Box text, but only for one column ([,1]):

    Box.test(residuals(VAR), type = c("Ljung-Box"))

does not work. It returns "x is not a vector or univariate time series". Apparently, Box.test does not work with VAR? It apparently only works with residuals(VAR)[,1], i.e. selecting one column of the residuals.

  1. dwtest() from the lmtest package - performs the Durbin-Watson test:

    dwtest(residuals(VAR)[,1] ~ residuals(VAR)[,2])

  2. bgtest() from the lmtest package - performs the Breusch-Godfrey zest:

    bgtest(res_data[,1] ~ res_data[,2])

Questions:

  • Do I approach the test correctly (especially, not selecting a lag after the VAR was defined with a lag already)?
  • What would you recommend to do?
  • Can you confirm that Box.test() does not work with VAR?

Thank you!

Best practice of testing for serial correlation in VAR residuals in R

I want to examine the residuals of a VAR and apply the LM test for serial correlation (autocorrelation) like in (this) blog post by Dave Giles. In my test, I first examine the optimum lag length for two time series with an intercept and trend and go from here:

VAR <- VAR(data.frame(data[1],data[2]),p=2, type="both")
VARselect(VAR),lag.max = 12, type="both")

$selection
AIC(n)  HQ(n)  SC(n) FPE(n) 
    4      1      1      2 

Now, like in the example of the link above, I want to check which of the proposed lags has the lowest likelihood of serial correlation in the VAR. Following works with serial.test, that (I assume) obviously automatically selects the residuals from a VAR.

Now I discovered following testing methods:

  1. serial.test() from the vars package - Apparently a Portmanteau Test (asymptotic) statistics for every defined VAR:

    serial.test(VAR)

or Breusch-Godfrey LM test:

serial.test(VAR, type="BG")
  1. Box.test() from base - Can perform the Ljung-Box text, but only for one column ([,1]):

    Box.test(residuals(VAR), type = c("Ljung-Box"))

does not work. It returns "x is not a vector or univariate time series". Apparently, Box.test does not work with VAR? It apparently only works with residuals(VAR)[,1], i.e. selecting one column of the residuals.

  1. dwtest() from the lmtest package - performs the Durbin-Watson test:

    dwtest(residuals(VAR)[,1] ~ residuals(VAR)[,2])

  2. bgtest() from the lmtest package - performs the Breusch-Godfrey zest:

    bgtest(res_data[,1] ~ res_data[,2])

Questions:

  • Do I approach the test correctly (especially, not selecting a lag after the VAR was defined with a lag already)?
  • What would you recommend to do?
  • Can you confirm that Box.test() does not work with VAR?
3 edited tags
| link
2 added 116 characters in body
source | link

I want to examine the residuals of a VAR and apply the LM test for serial correlation (autocorrelation) (like here). In my test, I first examine the optimum lag length for two time series with an intercept and trend and go from here:

VAR <- VAR(data.frame(data[1],data[2]),p=2, type="both")
VARselect(VAR),lag.max = 12, type="both")

$selection
AIC(n)  HQ(n)  SC(n) FPE(n) 
    4      1      1      2 

Now, like in the example of the link above, I want to check which of the proposed lags has the lowest likelihood of serial correlation in the VAR. Following works with serial.test, that (I assume) obviously automatically selects the residuals from a VAR.

Now I discovered following testing methods:

  1. serial.test() from the vars package - Apparently a Breusch-Godfrey LM test that returns the Portmanteau Test (asymptotic) statistics for every defined VAR.:

    serial.test(VAR)

  2. Boxserial.test(VAR) from base - Can perform the Ljung-Box text, but only for one column ([,1]):

    Box.test(residuals(VAR), type = c("Ljung-Box"))

or Breusch-Godfrey LM test:

serial.test(VAR, type="BG")
  1. Box.test() from base - Can perform the Ljung-Box text, but only for one column ([,1]):

    Box.test(residuals(VAR), type = c("Ljung-Box"))

does not work. It returns "x is not a vector or univariate time series". Apparently, Box.test does not work with VAR? It apparently only works with residuals(VAR)[,1]residuals(VAR)[,1], i.e. selecting one column of the residuals.

  1. dwtest() from the lmtest package - Can performperforms the Durbin-Watson Testtest:

    dwtest(residuals(VAR)[,1] ~ residuals(VAR)[,2])dwtest(residuals(VAR)[,1] ~ residuals(VAR)[,2])

  2. bgtest() from the lmtest package - Can performperforms the Breusch-Godfrey Testzest:

    bgtest(res_data[,1] ~ res_data[,2])bgtest(res_data[,1] ~ res_data[,2])

Questions:

  • Do I approach the test correctly (especially, not selecting a lag after the VAR was defined with a lag already)?
  • What would you recommend to do?
  • Can you confirm that Box.test() does not work with VAR?

Thank you!

I want to examine the residuals of a VAR and apply the LM test for serial correlation (autocorrelation) (like here). In my test, I first examine the optimum lag length for two time series with an intercept and trend and go from here:

VAR <- VAR(data.frame(data[1],data[2]),p=2, type="both")
VARselect(VAR),lag.max = 12, type="both")

$selection
AIC(n)  HQ(n)  SC(n) FPE(n) 
    4      1      1      2 

Now, like in the example of the link above, I want to check which of the proposed lags has the lowest likelihood of serial correlation in the VAR. Following works with serial.test, that (I assume) obviously automatically selects the residuals from a VAR.

Now I discovered following testing methods:

  1. serial.test() from the vars package - Apparently a Breusch-Godfrey LM test that returns the Portmanteau Test (asymptotic) statistics for every defined VAR.

    serial.test(VAR)

  2. Box.test() from base - Can perform the Ljung-Box text, but only for one column ([,1]):

    Box.test(residuals(VAR), type = c("Ljung-Box"))

does not work. It returns "x is not a vector or univariate time series". Apparently, Box.test does not work with VAR? It apparently only works with residuals(VAR)[,1], i.e. selecting one column of the residuals.

  1. dwtest() from the lmtest package - Can perform the Durbin-Watson Test:

    dwtest(residuals(VAR)[,1] ~ residuals(VAR)[,2])

  2. bgtest() from the lmtest package - Can perform the Breusch-Godfrey Test:

    bgtest(res_data[,1] ~ res_data[,2])

Questions:

  • Do I approach the test correctly?
  • What would you recommend to do?
  • Can you confirm that Box.test() does not work with VAR?

Thank you!

I want to examine the residuals of a VAR and apply the LM test for serial correlation (autocorrelation) (like here). In my test, I first examine the optimum lag length for two time series with an intercept and trend and go from here:

VAR <- VAR(data.frame(data[1],data[2]),p=2, type="both")
VARselect(VAR),lag.max = 12, type="both")

$selection
AIC(n)  HQ(n)  SC(n) FPE(n) 
    4      1      1      2 

Now, like in the example of the link above, I want to check which of the proposed lags has the lowest likelihood of serial correlation in the VAR. Following works with serial.test, that (I assume) obviously automatically selects the residuals from a VAR.

Now I discovered following testing methods:

  1. serial.test() from the vars package - Apparently a Portmanteau Test (asymptotic) statistics for every defined VAR:

    serial.test(VAR)

or Breusch-Godfrey LM test:

serial.test(VAR, type="BG")
  1. Box.test() from base - Can perform the Ljung-Box text, but only for one column ([,1]):

    Box.test(residuals(VAR), type = c("Ljung-Box"))

does not work. It returns "x is not a vector or univariate time series". Apparently, Box.test does not work with VAR? It apparently only works with residuals(VAR)[,1], i.e. selecting one column of the residuals.

  1. dwtest() from the lmtest package - performs the Durbin-Watson test:

    dwtest(residuals(VAR)[,1] ~ residuals(VAR)[,2])

  2. bgtest() from the lmtest package - performs the Breusch-Godfrey zest:

    bgtest(res_data[,1] ~ res_data[,2])

Questions:

  • Do I approach the test correctly (especially, not selecting a lag after the VAR was defined with a lag already)?
  • What would you recommend to do?
  • Can you confirm that Box.test() does not work with VAR?

Thank you!

1
source | link