Se determina un par de valores numericos que se adapten en el medio
de la prueba de causalidad de Granger.
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
library(fpp2)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## ── Attaching packages ────────────────────────────────────────────── fpp2 2.5 ──
## ✔ ggplot2 3.4.1 ✔ fma 2.5
## ✔ forecast 8.21 ✔ expsmooth 2.3
##
library(TSA)
## Registered S3 methods overwritten by 'TSA':
## method from
## fitted.Arima forecast
## plot.Arima forecast
##
## Attaching package: 'TSA'
## The following objects are masked from 'package:stats':
##
## acf, arima
## The following object is masked from 'package:utils':
##
## tar
series <- uschange
autoplot(uschange[,c(3,5)])

a <- VARselect(uschange[,1:2], lag.max=15,type="const")
a$selection
## AIC(n) HQ(n) SC(n) FPE(n)
## 5 1 1 5
modelo1<-VAR(uschange[,c(3,5)],p=10,type=c("const"))
GrangerIncome <-causality(modelo1, cause = 'Production')
GrangerIncome
## $Granger
##
## Granger causality H0: Production do not Granger-cause Unemployment
##
## data: VAR object modelo1
## F-Test = 2.346, df1 = 10, df2 = 312, p-value = 0.0111
##
##
## $Instant
##
## H0: No instantaneous causality between: Production and Unemployment
##
## data: VAR object modelo1
## Chi-squared = 59.945, df = 1, p-value = 9.77e-15
GrangerConsumptions <-causality(modelo1, cause = 'Unemployment')
GrangerConsumptions
## $Granger
##
## Granger causality H0: Unemployment do not Granger-cause Production
##
## data: VAR object modelo1
## F-Test = 3.0085, df1 = 10, df2 = 312, p-value = 0.001207
##
##
## $Instant
##
## H0: No instantaneous causality between: Unemployment and Production
##
## data: VAR object modelo1
## Chi-squared = 59.945, df = 1, p-value = 9.77e-15