LABORATORIO 7

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

El P-valor de las dos variables del modelo son menores a 0.05 por lo cual son ideales para el modelo.

serial.test(modelo1, lags.pt=10, type="PT.asymptotic")
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object modelo1
## Chi-squared = 7.9607, df = 0, p-value < 2.2e-16

Se usa la prueba PortManteu y se identifica que el modelo no posee autocorrelación debido a que el p-valor menor a 0.05

roots(modelo1)
##  [1] 0.9173477 0.9074411 0.9074411 0.8857057 0.8857057 0.8839837 0.8839837
##  [8] 0.8821400 0.8821400 0.8801347 0.8801347 0.8778165 0.8778165 0.8752188
## [15] 0.8752188 0.8702727 0.8527066 0.8527066 0.3942062 0.3942062
normality.test(modelo1, multivariate.only=FALSE)
## $Production
## 
##  JB-Test (univariate)
## 
## data:  Residual of Production equation
## Chi-squared = 23.285, df = 2, p-value = 8.783e-06
## 
## 
## $Unemployment
## 
##  JB-Test (univariate)
## 
## data:  Residual of Unemployment equation
## Chi-squared = 20.166, df = 2, p-value = 4.178e-05
## 
## 
## $JB
## 
##  JB-Test (multivariate)
## 
## data:  Residuals of VAR object modelo1
## Chi-squared = 27.34, df = 4, p-value = 1.697e-05
## 
## 
## $Skewness
## 
##  Skewness only (multivariate)
## 
## data:  Residuals of VAR object modelo1
## Chi-squared = 6.1498, df = 2, p-value = 0.0462
## 
## 
## $Kurtosis
## 
##  Kurtosis only (multivariate)
## 
## data:  Residuals of VAR object modelo1
## Chi-squared = 21.19, df = 2, p-value = 2.504e-05

Las raíces unitarias son menores a 1.

stab<-stability(modelo1, type = "OLS-CUSUM")
par(mar=c(1,1,1,1))
plot(stab)

debido a su P-valor menor a 0.05 pasa la rueba de Jarque Bera.