granger causality test?

Dear Friends,

I am stuck in the errors of using granger causality test.
Could you give me any solutions for this matter?

Thank you!

TG

library("vars")

data(Canada)
var.2c <- VAR(Canada, p = 2)
causality(var.2c, cause = "e")
#> Error in causality(var.2c, cause = "e") : 
#> Please provide an object of class 'varest', generated by 'var()'.

Are you sure this code reproduces your issue? I'm running your exact code and it is working as expected. Try restarting your R session ( Ctrl+Shift+F10) and running your code again.

library("vars")

data(Canada)

var.2c <- VAR(Canada, p = 2)
causality(var.2c, cause = "e")
#> $Granger
#> 
#>  Granger causality H0: e do not Granger-cause prod rw U
#> 
#> data:  VAR object var.2c
#> F-Test = 6.2768, df1 = 6, df2 = 292, p-value = 3.206e-06
#> 
#> 
#> $Instant
#> 
#>  H0: No instantaneous causality between: e and prod rw U
#> 
#> data:  VAR object var.2c
#> Chi-squared = 26.068, df = 3, p-value = 9.228e-06

Created on 2019-10-02 by the reprex package (v0.3.0)

Thank you very much for your very quick and kind reply.
I will try again as you mentioned. and I don't know why some time R does not run the correct codes successfully.

Best,

TG

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.