Como primer paso se obtienen los datos y se puede visualizar la gráfica de la variable identificada como PCE
## [1] "Year" "Quarter" "tiempo" "DPI" "GDP" "PCE" "CP"
## [8] "DIVIDEND"
## [1] "tbl_df" "tbl" "data.frame"
Luego de esto se realiza una serie de tiempo con PCE y GDP que se puede visualizar en el siguiente gráfico.
Ahora evaluaremos la correlación entre estas variables, la cual podemos notar que es muy alta
## [1] 0.9991024
Por lo tanto generaremos un modelo y evaluaremos con varselect los valores de p que identificamos con 2
## AIC(n) HQ(n) SC(n) FPE(n)
## 2 2 2 2
Podemos proceder a analizar el resumen de resultados de estos modelos. AMbos muestran un r2 muy alto casi de 1. Tambien podemos evidenciar la matriz de covarianza y correlación que igual muestra valores altos.
##
## VAR Estimation Results:
## =========================
## Endogenous variables: GDP.ts, PCE.ts
## Deterministic variables: const
## Sample size: 134
## Log Likelihood: -1208.96
## Roots of the characteristic polynomial:
## 1.006 0.9007 0.2847 0.1399
## Call:
## VAR(y = datos1, p = 2)
##
##
## Estimation results for equation GDP.ts:
## =======================================
## GDP.ts = GDP.ts.l1 + PCE.ts.l1 + GDP.ts.l2 + PCE.ts.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## GDP.ts.l1 0.96042 0.11155 8.610 2.19e-14 ***
## PCE.ts.l1 0.74110 0.20287 3.653 0.000375 ***
## GDP.ts.l2 -0.07072 0.11018 -0.642 0.522110
## PCE.ts.l2 -0.57426 0.20649 -2.781 0.006231 **
## const 24.30575 11.28947 2.153 0.033183 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 34.35 on 129 degrees of freedom
## Multiple R-Squared: 0.9991, Adjusted R-squared: 0.999
## F-statistic: 3.438e+04 on 4 and 129 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation PCE.ts:
## =======================================
## PCE.ts = GDP.ts.l1 + PCE.ts.l1 + GDP.ts.l2 + PCE.ts.l2 + const
##
## Estimate Std. Error t value Pr(>|t|)
## GDP.ts.l1 0.05774 0.06454 0.895 0.373
## PCE.ts.l1 1.09123 0.11737 9.297 4.71e-16 ***
## GDP.ts.l2 -0.07105 0.06375 -1.115 0.267
## PCE.ts.l2 -0.06658 0.11947 -0.557 0.578
## const 6.63225 6.53169 1.015 0.312
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 19.87 on 129 degrees of freedom
## Multiple R-Squared: 0.9993, Adjusted R-squared: 0.9993
## F-statistic: 4.687e+04 on 4 and 129 DF, p-value: < 2.2e-16
##
##
##
## Covariance matrix of residuals:
## GDP.ts PCE.ts
## GDP.ts 1179.6 460.4
## PCE.ts 460.4 394.9
##
## Correlation matrix of residuals:
## GDP.ts PCE.ts
## GDP.ts 1.0000 0.6745
## PCE.ts 0.6745 1.0000
Procederemos a realizar una prueba a los residuos en donde evidenciamos que todos los p valor son menores a 0.01. por lo tanto es estacionaria y si hay cointegración evidenciando una relación a largo plazo
## Augmented Dickey-Fuller Test
## alternative: stationary
##
## Type 1: no drift no trend
## lag ADF p.value
## [1,] 0 -12.28 0.01
## [2,] 1 -7.60 0.01
## [3,] 2 -6.48 0.01
## [4,] 3 -5.45 0.01
## [5,] 4 -4.67 0.01
## Type 2: with drift no trend
## lag ADF p.value
## [1,] 0 -12.23 0.01
## [2,] 1 -7.57 0.01
## [3,] 2 -6.45 0.01
## [4,] 3 -5.43 0.01
## [5,] 4 -4.65 0.01
## Type 3: with drift and trend
## lag ADF p.value
## [1,] 0 -12.19 0.01
## [2,] 1 -7.54 0.01
## [3,] 2 -6.43 0.01
## [4,] 3 -5.41 0.01
## [5,] 4 -4.63 0.01
## ----
## Note: in fact, p.value = 0.01 means p.value <= 0.01
## Augmented Dickey-Fuller Test
## alternative: stationary
##
## Type 1: no drift no trend
## lag ADF p.value
## [1,] 0 -11.61 0.01
## [2,] 1 -6.85 0.01
## [3,] 2 -5.54 0.01
## [4,] 3 -5.08 0.01
## [5,] 4 -5.03 0.01
## Type 2: with drift no trend
## lag ADF p.value
## [1,] 0 -11.57 0.01
## [2,] 1 -6.82 0.01
## [3,] 2 -5.52 0.01
## [4,] 3 -5.06 0.01
## [5,] 4 -5.02 0.01
## Type 3: with drift and trend
## lag ADF p.value
## [1,] 0 -11.54 0.01
## [2,] 1 -6.80 0.01
## [3,] 2 -5.50 0.01
## [4,] 3 -5.05 0.01
## [5,] 4 -5.00 0.01
## ----
## Note: in fact, p.value = 0.01 means p.value <= 0.01
Con esta información se puede realizar diversas pruebas como Philips y Oularis, en esta se identifica que los residuos son estacionarios por lo que si hay cointegración.
##
## ########################################
## # Phillips and Ouliaris Unit Root Test #
## ########################################
##
## Test of type Pz
## detrending of series none
##
## Response GDP.ts :
##
## Call:
## lm(formula = GDP.ts ~ zr - 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -150.279 -18.515 2.796 27.331 141.137
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## zrGDP.ts 0.95334 0.03958 24.089 <2e-16 ***
## zrPCE.ts 0.08483 0.06116 1.387 0.168
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 37.23 on 133 degrees of freedom
## Multiple R-squared: 0.9999, Adjusted R-squared: 0.9999
## F-statistic: 5.421e+05 on 2 and 133 DF, p-value: < 2.2e-16
##
##
## Response PCE.ts :
##
## Call:
## lm(formula = PCE.ts ~ zr - 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -104.417 -8.223 1.965 11.714 48.952
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## zrGDP.ts 0.007454 0.021281 0.35 0.727
## zrPCE.ts 0.996942 0.032886 30.32 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 20.02 on 133 degrees of freedom
## Multiple R-squared: 0.9999, Adjusted R-squared: 0.9999
## F-statistic: 7.855e+05 on 2 and 133 DF, p-value: < 2.2e-16
##
##
##
## Value of test-statistic is: 13.4923
##
## Critical values of Pz are:
## 10pct 5pct 1pct
## critical values 33.9267 40.8217 55.1911
##
## ########################################
## # Phillips and Ouliaris Unit Root Test #
## ########################################
##
## Test of type Pu
## detrending of series none
##
##
## Call:
## lm(formula = z[, 1] ~ z[, -1] - 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -185.94 -32.81 29.65 77.98 145.10
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## z[, -1] 1.54450 0.00323 478.1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 81.14 on 135 degrees of freedom
## Multiple R-squared: 0.9994, Adjusted R-squared: 0.9994
## F-statistic: 2.286e+05 on 1 and 135 DF, p-value: < 2.2e-16
##
##
## Value of test-statistic is: 13.4278
##
## Critical values of Pu are:
## 10pct 5pct 1pct
## critical values 20.3933 25.9711 38.3413