R Under development (unstable) (2023-11-30 r85651 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > > > ###test causality > library(vars) Loading required package: MASS Loading required package: strucchange Loading required package: zoo Attaching package: 'zoo' The following objects are masked from 'package:base': as.Date, as.Date.numeric Loading required package: sandwich Loading required package: urca Loading required package: lmtest > data(Canada) > > myVar<-VAR(Canada, p=2, season=12) > > causality(myVar) $Granger Granger causality H0: e do not Granger-cause prod rw U data: VAR object myVar F-Test = 5.6938, df1 = 6, df2 = 248, p-value = 1.454e-05 $Instant H0: No instantaneous causality between: e and prod rw U data: VAR object myVar Chi-squared = 26.019, df = 3, p-value = 9.452e-06 Warning message: In causality(myVar) : Argument 'cause' has not been specified; using first variable in 'x$y' (e) as cause variable. > causality(myVar, cause="e") $Granger Granger causality H0: e do not Granger-cause prod rw U data: VAR object myVar F-Test = 5.6938, df1 = 6, df2 = 248, p-value = 1.454e-05 $Instant H0: No instantaneous causality between: e and prod rw U data: VAR object myVar Chi-squared = 26.019, df = 3, p-value = 9.452e-06 > causality(myVar, cause="prod") $Granger Granger causality H0: prod do not Granger-cause e rw U data: VAR object myVar F-Test = 2.4819, df1 = 6, df2 = 248, p-value = 0.02381 $Instant H0: No instantaneous causality between: prod and e rw U data: VAR object myVar Chi-squared = 0.29751, df = 3, p-value = 0.9605 > causality(myVar, cause="rw") $Granger Granger causality H0: rw do not Granger-cause e prod U data: VAR object myVar F-Test = 2.1694, df1 = 6, df2 = 248, p-value = 0.04653 $Instant H0: No instantaneous causality between: rw and e prod U data: VAR object myVar Chi-squared = 3.0925, df = 3, p-value = 0.3776 > causality(myVar, cause="U") $Granger Granger causality H0: U do not Granger-cause e prod rw data: VAR object myVar F-Test = 2.8427, df1 = 6, df2 = 248, p-value = 0.01076 $Instant H0: No instantaneous causality between: U and e prod rw data: VAR object myVar Chi-squared = 26.277, df = 3, p-value = 8.344e-06 > > causality(myVar, cause=c("e", "prod")) $Granger Granger causality H0: e prod do not Granger-cause rw U data: VAR object myVar F-Test = 6.1731, df1 = 8, df2 = 248, p-value = 2.868e-07 $Instant H0: No instantaneous causality between: e prod and rw U data: VAR object myVar Chi-squared = 26.265, df = 4, p-value = 2.798e-05 > causality(myVar, cause=c("prod","e")) $Granger Granger causality H0: e prod do not Granger-cause rw U data: VAR object myVar F-Test = 6.1731, df1 = 8, df2 = 248, p-value = 2.868e-07 $Instant H0: No instantaneous causality between: e prod and rw U data: VAR object myVar Chi-squared = 26.265, df = 4, p-value = 2.798e-05 > causality(myVar, cause=c("e", "prod","rw")) $Granger Granger causality H0: e prod rw do not Granger-cause U data: VAR object myVar F-Test = 8.2792, df1 = 6, df2 = 248, p-value = 3.496e-08 $Instant H0: No instantaneous causality between: e prod rw and U data: VAR object myVar Chi-squared = 26.277, df = 3, p-value = 8.344e-06 > > myVar2<-VAR(Canada, p=3, type="trend") > causality(myVar2, cause="e") $Granger Granger causality H0: e do not Granger-cause prod rw U data: VAR object myVar2 F-Test = 4.7587, df1 = 9, df2 = 272, p-value = 6.768e-06 $Instant H0: No instantaneous causality between: e and prod rw U data: VAR object myVar2 Chi-squared = 29.665, df = 3, p-value = 1.623e-06 > causality(myVar2, cause="prod") $Granger Granger causality H0: prod do not Granger-cause e rw U data: VAR object myVar2 F-Test = 2.3964, df1 = 9, df2 = 272, p-value = 0.01256 $Instant H0: No instantaneous causality between: prod and e rw U data: VAR object myVar2 Chi-squared = 1.3713, df = 3, p-value = 0.7123 > causality(myVar2, cause="rw") $Granger Granger causality H0: rw do not Granger-cause e prod U data: VAR object myVar2 F-Test = 2.221, df1 = 9, df2 = 272, p-value = 0.02101 $Instant H0: No instantaneous causality between: rw and e prod U data: VAR object myVar2 Chi-squared = 2.3541, df = 3, p-value = 0.5022 > causality(myVar2, cause="U") $Granger Granger causality H0: U do not Granger-cause e prod rw data: VAR object myVar2 F-Test = 2.129, df1 = 9, df2 = 272, p-value = 0.02738 $Instant H0: No instantaneous causality between: U and e prod rw data: VAR object myVar2 Chi-squared = 29.608, df = 3, p-value = 1.668e-06 > > causality(myVar2, cause=c("e", "prod")) $Granger Granger causality H0: e prod do not Granger-cause rw U data: VAR object myVar2 F-Test = 4.3402, df1 = 12, df2 = 272, p-value = 2.544e-06 $Instant H0: No instantaneous causality between: e prod and rw U data: VAR object myVar2 Chi-squared = 29.601, df = 4, p-value = 5.902e-06 > causality(myVar, cause=c("prod","e")) $Granger Granger causality H0: e prod do not Granger-cause rw U data: VAR object myVar F-Test = 6.1731, df1 = 8, df2 = 248, p-value = 2.868e-07 $Instant H0: No instantaneous causality between: e prod and rw U data: VAR object myVar Chi-squared = 26.265, df = 4, p-value = 2.798e-05 > causality(myVar, cause=c("e", "prod","rw")) $Granger Granger causality H0: e prod rw do not Granger-cause U data: VAR object myVar F-Test = 8.2792, df1 = 6, df2 = 248, p-value = 3.496e-08 $Instant H0: No instantaneous causality between: e prod rw and U data: VAR object myVar Chi-squared = 26.277, df = 3, p-value = 8.344e-06 > > myVar3<-VAR(Canada[,1:3], p=1, exogen=Canada[,4], type="none") Warning message: In VAR(Canada[, 1:3], p = 1, exogen = Canada[, 4], type = "none") : No column names supplied in exogen, using: exo1 , instead. > > causality(myVar3) $Granger Granger causality H0: e do not Granger-cause prod rw data: VAR object myVar3 F-Test = 8.0347, df1 = 2, df2 = 237, p-value = 0.0004205 $Instant H0: No instantaneous causality between: e and prod rw data: VAR object myVar3 Chi-squared = 11.261, df = 2, p-value = 0.003587 Warning message: In causality(myVar3) : Argument 'cause' has not been specified; using first variable in 'x$y' (e) as cause variable. > causality(myVar3, cause="e") $Granger Granger causality H0: e do not Granger-cause prod rw data: VAR object myVar3 F-Test = 8.0347, df1 = 2, df2 = 237, p-value = 0.0004205 $Instant H0: No instantaneous causality between: e and prod rw data: VAR object myVar3 Chi-squared = 11.261, df = 2, p-value = 0.003587 > causality(myVar3, cause="prod") $Granger Granger causality H0: prod do not Granger-cause e rw data: VAR object myVar3 F-Test = 13.585, df1 = 2, df2 = 237, p-value = 2.597e-06 $Instant H0: No instantaneous causality between: prod and e rw data: VAR object myVar3 Chi-squared = 4.8762, df = 2, p-value = 0.08732 > causality(myVar3, cause="rw") $Granger Granger causality H0: rw do not Granger-cause e prod data: VAR object myVar3 F-Test = 3.7897, df1 = 2, df2 = 237, p-value = 0.02399 $Instant H0: No instantaneous causality between: rw and e prod data: VAR object myVar3 Chi-squared = 8.1627, df = 2, p-value = 0.01689 > > causality(myVar3, cause=c("e", "prod")) $Granger Granger causality H0: e prod do not Granger-cause rw data: VAR object myVar3 F-Test = 33.769, df1 = 2, df2 = 237, p-value = 1.248e-13 $Instant H0: No instantaneous causality between: e prod and rw data: VAR object myVar3 Chi-squared = 8.1627, df = 2, p-value = 0.01689 > causality(myVar3, cause=c("prod","e")) $Granger Granger causality H0: e prod do not Granger-cause rw data: VAR object myVar3 F-Test = 33.769, df1 = 2, df2 = 237, p-value = 1.248e-13 $Instant H0: No instantaneous causality between: e prod and rw data: VAR object myVar3 Chi-squared = 8.1627, df = 2, p-value = 0.01689 > > > proc.time() user system elapsed 0.50 0.12 0.62