Búsqueda y selección de parámetros
a <- VARselect(uschange[,c(2,5)],lag.max=15,type="const")
a$selection
## AIC(n) HQ(n) SC(n) FPE(n)
## 8 1 1 8
Se obtiene un estimado automático de los mejores parametros para la
creación del modelo VAR. (8 y 1),
Datos del modelo por variable seleccionada
- Consumo
summary(modelo1,equation="Consumption")
## Warning in summary.varest(modelo1, equation = "Consumption"):
## Invalid variable name(s) supplied, using first variable.
##
## VAR Estimation Results:
## =========================
## Endogenous variables: Income, Unemployment
## Deterministic variables: const
## Sample size: 182
## Log Likelihood: -262.292
## Roots of the characteristic polynomial:
## 0.7776 0.7776 0.7661 0.7661 0.7488 0.7488 0.672 0.672 0.6364 0.5646
## Call:
## VAR(y = uschange[, c(2, 5)], p = 5, type = c("const"))
##
##
## Estimation results for equation Income:
## =======================================
## Income = Income.l1 + Unemployment.l1 + Income.l2 + Unemployment.l2 + Income.l3 + Unemployment.l3 + Income.l4 + Unemployment.l4 + Income.l5 + Unemployment.l5 + const
##
## Estimate Std. Error t value Pr(>|t|)
## Income.l1 -0.13069 0.07628 -1.713 0.08848 .
## Unemployment.l1 -0.47812 0.22736 -2.103 0.03693 *
## Income.l2 0.08289 0.07790 1.064 0.28883
## Unemployment.l2 0.39251 0.23868 1.644 0.10191
## Income.l3 0.03524 0.07602 0.464 0.64351
## Unemployment.l3 -0.65814 0.24414 -2.696 0.00773 **
## Income.l4 -0.09359 0.07556 -1.239 0.21717
## Unemployment.l4 -0.14117 0.24531 -0.575 0.56571
## Income.l5 -0.12761 0.07471 -1.708 0.08944 .
## Unemployment.l5 0.39764 0.22214 1.790 0.07522 .
## const 0.87038 0.14889 5.846 2.49e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 0.8936 on 171 degrees of freedom
## Multiple R-Squared: 0.1347, Adjusted R-squared: 0.08413
## F-statistic: 2.663 on 10 and 171 DF, p-value: 0.004781
##
##
##
## Covariance matrix of residuals:
## Income Unemployment
## Income 0.7985 -0.05280
## Unemployment -0.0528 0.09033
##
## Correlation matrix of residuals:
## Income Unemployment
## Income 1.0000 -0.1966
## Unemployment -0.1966 1.0000
- Ingreso
summary(modelo1,equation="Income")
##
## VAR Estimation Results:
## =========================
## Endogenous variables: Income, Unemployment
## Deterministic variables: const
## Sample size: 182
## Log Likelihood: -262.292
## Roots of the characteristic polynomial:
## 0.7776 0.7776 0.7661 0.7661 0.7488 0.7488 0.672 0.672 0.6364 0.5646
## Call:
## VAR(y = uschange[, c(2, 5)], p = 5, type = c("const"))
##
##
## Estimation results for equation Income:
## =======================================
## Income = Income.l1 + Unemployment.l1 + Income.l2 + Unemployment.l2 + Income.l3 + Unemployment.l3 + Income.l4 + Unemployment.l4 + Income.l5 + Unemployment.l5 + const
##
## Estimate Std. Error t value Pr(>|t|)
## Income.l1 -0.13069 0.07628 -1.713 0.08848 .
## Unemployment.l1 -0.47812 0.22736 -2.103 0.03693 *
## Income.l2 0.08289 0.07790 1.064 0.28883
## Unemployment.l2 0.39251 0.23868 1.644 0.10191
## Income.l3 0.03524 0.07602 0.464 0.64351
## Unemployment.l3 -0.65814 0.24414 -2.696 0.00773 **
## Income.l4 -0.09359 0.07556 -1.239 0.21717
## Unemployment.l4 -0.14117 0.24531 -0.575 0.56571
## Income.l5 -0.12761 0.07471 -1.708 0.08944 .
## Unemployment.l5 0.39764 0.22214 1.790 0.07522 .
## const 0.87038 0.14889 5.846 2.49e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 0.8936 on 171 degrees of freedom
## Multiple R-Squared: 0.1347, Adjusted R-squared: 0.08413
## F-statistic: 2.663 on 10 and 171 DF, p-value: 0.004781
##
##
##
## Covariance matrix of residuals:
## Income Unemployment
## Income 0.7985 -0.05280
## Unemployment -0.0528 0.09033
##
## Correlation matrix of residuals:
## Income Unemployment
## Income 1.0000 -0.1966
## Unemployment -0.1966 1.0000
Validación del modelo
Prueba de Autocorrelación
#>PortManteu Test > 0.05 Autocorrelación
serial.test(modelo1, lags.pt=11, type="PT.asymptotic")
##
## Portmanteau Test (asymptotic)
##
## data: Residuals of VAR object modelo1
## Chi-squared = 35.653, df = 24, p-value = 0.05929
Con esta prueba se obtuvo un p-value de 0.05929 > 0.05, lo cual
indica que existe autocorrelación.
Prueba de estacionariedad
#Raíz unitaria < 1
roots(modelo1)
## [1] 0.7775660 0.7775660 0.7660914 0.7660914 0.7488061 0.7488061 0.6720236
## [8] 0.6720236 0.6364359 0.5646411
Ya que los valores obtenidos no son mayores a 1, se confirma que el
modelo creado es estacionario.
Prueba de Jarque Bera (Normalidad)
normality.test(modelo1, multivariate.only=FALSE)
## $Income
##
## JB-Test (univariate)
##
## data: Residual of Income equation
## Chi-squared = 195.51, df = 2, p-value < 2.2e-16
##
##
## $Unemployment
##
## JB-Test (univariate)
##
## data: Residual of Unemployment equation
## Chi-squared = 33.197, df = 2, p-value = 6.184e-08
##
##
## $JB
##
## JB-Test (multivariate)
##
## data: Residuals of VAR object modelo1
## Chi-squared = 216.79, df = 4, p-value < 2.2e-16
##
##
## $Skewness
##
## Skewness only (multivariate)
##
## data: Residuals of VAR object modelo1
## Chi-squared = 7.8916, df = 2, p-value = 0.01934
##
##
## $Kurtosis
##
## Kurtosis only (multivariate)
##
## data: Residuals of VAR object modelo1
## Chi-squared = 208.9, df = 2, p-value < 2.2e-16
Con esta prueba se obtuvo un p-value de 2.2e-16 < 0.05, lo cual
indica que existe normalidad en el comportamiento de los residuos del
modelo.
Prueba de Heteroscedasticidad
arch<-arch.test(modelo1, lags.multi = 12, multivariate.only = FALSE)
arch
## $Income
##
## ARCH test (univariate)
##
## data: Residual of Income equation
## Chi-squared = 11.621, df = 16, p-value = 0.7697
##
##
## $Unemployment
##
## ARCH test (univariate)
##
## data: Residual of Unemployment equation
## Chi-squared = 21.391, df = 16, p-value = 0.164
##
##
##
## ARCH (multivariate)
##
## data: Residuals of VAR object modelo1
## Chi-squared = 121.69, df = 108, p-value = 0.1737
Con esta prueba se obtiene un p-value menor a 0.05, lo que significa
que no hay heteroscedasticidad en el modelo. Además, este resultado
confirma que la varianza de los residuos del modelo es constante.
Prueba de choques estructurales
stab<-stability(modelo1, type = "OLS-CUSUM")
par(mar=c(1,1,1,1))
Gráficas de OLS-CUSUM
plot(stab)

Con la gráfica es posible observar que los valores no sobrepasan los
límites de tolerancia, por lo que tienen estabilidad.
Pruba de Granger (Causalidad)
Ingreso
GrangerIncome <-causality(modelo1, cause = 'Income')
GrangerIncome
## $Granger
##
## Granger causality H0: Income do not Granger-cause Unemployment
##
## data: VAR object modelo1
## F-Test = 2.8057, df1 = 5, df2 = 342, p-value = 0.01687
##
##
## $Instant
##
## H0: No instantaneous causality between: Income and Unemployment
##
## data: VAR object modelo1
## Chi-squared = 6.7734, df = 1, p-value = 0.009253
Se obtuvo un p-value de 0.01687 (menor a 0.05) por lo que se
determina que existe causalidad de la variable Income a la variable de
Unemployment.
Desempleo
GrangerIncome <-causality(modelo1, cause = 'Unemployment')
GrangerIncome
## $Granger
##
## Granger causality H0: Unemployment do not Granger-cause Income
##
## data: VAR object modelo1
## F-Test = 3.7264, df1 = 5, df2 = 342, p-value = 0.002681
##
##
## $Instant
##
## H0: No instantaneous causality between: Unemployment and Income
##
## data: VAR object modelo1
## Chi-squared = 6.7734, df = 1, p-value = 0.009253
Se obtuvo un p-value de 0.002681 (menor a 0.05) por lo que se
determina que existe causalidad de la variable Unemployment a la
variable Income.
Evaluación del modelo ante un impulso
Income
IncomeIRF <- irf(modelo1, impulse = "Unemployment", response="Income", n.ahead = 20, boot = T )
plot(IncomeIRF, ylab = "Income", main = "Shock desde Unemployment")

Unemployment
UnemploymentIRF <- irf(modelo1, impulse = "Income", response="Unemployment", n.ahead = 20, boot = T )
plot(IncomeIRF, ylab = "Unemployment", main = "Shock desde Income")

En ambas gráficas es posible observar que al recibir un shock en los
valores, en el largo plazo, las variables evaluadas vuelven a
correlacionarse.
Pronóstico
fore<-predict(modelo1, n.ahead = 10, ci=0.95)
fanchart(fore)

Gráfica del pronóstico
autoplot(forecast(modelo1))
