Datos alemanes de tasa de interés e inflación

El conjunto de datos contiene series temporales trimestrales no ajustadas estacionalmente para las tasas de interés e inflación alemanas a largo plazo desde 1972Q2 hasta 1998Q4. Fue producido a partir del archivo E6 de los conjuntos de datos asociados con Lütkepohl (2007). Los datos sin procesar están disponibles en http://www.jmulti.de/download/datasets/e6.dat y se obtuvieron originalmente de Deutsche Bundesbank y Deutsches Institut für Wirtschaftsforschung

Cargar las librerias

library(vars)
library(tseries)
library(forecast)
library(urca)
library(highcharter)
library(bvartools)
## Warning: package 'bvartools' was built under R version 4.5.3
## Warning: package 'coda' was built under R version 4.5.3
library(MTS)
## Warning: package 'MTS' was built under R version 4.5.3

Cargar la base datos y graficarla

data("e6")  
plot(e6)

hchart(e6)%>%hc_add_theme(hc_theme_economist())
## Warning in create_yaxis(ntss, heights = heights, turnopposite = TRUE, title =
## list(text = NULL), : Deprecated function. Use the `create_axis` function.
summary(e6)
##        R                 Dp           
##  Min.   :0.03800   Min.   :-0.029195  
##  1st Qu.:0.06050   1st Qu.:-0.004265  
##  Median :0.07400   Median : 0.008706  
##  Mean   :0.07458   Mean   : 0.008397  
##  3rd Qu.:0.08600   3rd Qu.: 0.023910  
##  Max.   :0.11300   Max.   : 0.043004

El deflactor del PIB se utiliza para conocer la parte del crecimiento de una economía que se debe al aumento de precios.

Pruebas de estacionariedad

adf.R<- ur.df(e6[,1], type = "trend", selectlags = "BIC")
summary(adf.R)   
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0136682 -0.0038094 -0.0001308  0.0031834  0.0144628 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  9.248e-03  3.905e-03   2.368   0.0198 *
## z.lag.1     -9.742e-02  4.108e-02  -2.372   0.0196 *
## tt          -4.266e-05  2.141e-05  -1.993   0.0490 *
## z.diff.lag   2.027e-01  9.835e-02   2.061   0.0419 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.005404 on 101 degrees of freedom
## Multiple R-squared:  0.0806, Adjusted R-squared:  0.05329 
## F-statistic: 2.951 on 3 and 101 DF,  p-value: 0.03625
## 
## 
## Value of test-statistic is: -2.3716 2.2271 3.1006 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.99 -3.43 -3.13
## phi2  6.22  4.75  4.07
## phi3  8.43  6.49  5.47
plot(adf.R)

adf.test(e6[,1])
## 
##  Augmented Dickey-Fuller Test
## 
## data:  e6[, 1]
## Dickey-Fuller = -2.7095, Lag order = 4, p-value = 0.2824
## alternative hypothesis: stationary
pp.test(e6[,1])
## 
##  Phillips-Perron Unit Root Test
## 
## data:  e6[, 1]
## Dickey-Fuller Z(alpha) = -12.217, Truncation lag parameter = 4, p-value
## = 0.4079
## alternative hypothesis: stationary
adf.Dp <- ur.df(e6[,2], type = "trend", selectlags = "BIC")
summary(adf.Dp)   
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.024165 -0.012291 -0.005201  0.012061  0.044861 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.470e-02  3.820e-03   6.467 3.61e-09 ***
## z.lag.1     -1.846e+00  1.437e-01 -12.853  < 2e-16 ***
## tt          -1.712e-04  5.481e-05  -3.123  0.00234 ** 
## z.diff.lag   4.412e-01  8.956e-02   4.926 3.29e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01645 on 101 degrees of freedom
## Multiple R-squared:  0.7078, Adjusted R-squared:  0.6991 
## F-statistic: 81.56 on 3 and 101 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -12.8528 55.0768 82.6141 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.99 -3.43 -3.13
## phi2  6.22  4.75  4.07
## phi3  8.43  6.49  5.47
adf.test(e6[,2])
## 
##  Augmented Dickey-Fuller Test
## 
## data:  e6[, 2]
## Dickey-Fuller = -2.5209, Lag order = 4, p-value = 0.3606
## alternative hypothesis: stationary
plot(adf.Dp)

pp.test(e6[,2])
## Warning in pp.test(e6[, 2]): p-value smaller than printed p-value
## 
##  Phillips-Perron Unit Root Test
## 
## data:  e6[, 2]
## Dickey-Fuller Z(alpha) = -106.58, Truncation lag parameter = 4, p-value
## = 0.01
## alternative hypothesis: stationary

Pruebas con una diferencia

Con una diferencia

diff.adf.R <- ur.df(diff(e6[,1]), type = "trend", selectlags = "BIC")
summary(diff.adf.R)   
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0141027 -0.0039508 -0.0004519  0.0029505  0.0150488 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.996e-04  1.115e-03   0.179    0.858    
## z.lag.1     -8.952e-01  1.304e-01  -6.867 5.63e-10 ***
## tt          -1.169e-05  1.824e-05  -0.641    0.523    
## z.diff.lag   5.332e-02  1.000e-01   0.533    0.595    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.005559 on 100 degrees of freedom
## Multiple R-squared:  0.4273, Adjusted R-squared:  0.4101 
## F-statistic: 24.87 on 3 and 100 DF,  p-value: 4.19e-12
## 
## 
## Value of test-statistic is: -6.867 15.7276 23.5778 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.99 -3.43 -3.13
## phi2  6.22  4.75  4.07
## phi3  8.43  6.49  5.47
plot(diff.adf.R)

diff.adf.Dp <- ur.df(diff(e6[,2]), type = "trend", selectlags = "BIC")
summary(diff.adf.Dp)   
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression trend 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.044322 -0.014729 -0.000134  0.021484  0.045162 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -9.275e-04  5.034e-03  -0.184 0.854205    
## z.lag.1     -1.998e+00  1.615e-01 -12.367  < 2e-16 ***
## tt           1.533e-05  8.206e-05   0.187 0.852215    
## z.diff.lag   3.469e-01  9.372e-02   3.701 0.000351 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.02512 on 100 degrees of freedom
## Multiple R-squared:  0.7719, Adjusted R-squared:  0.765 
## F-statistic: 112.8 on 3 and 100 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -12.3671 51.0126 76.5188 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -3.99 -3.43 -3.13
## phi2  6.22  4.75  4.07
## phi3  8.43  6.49  5.47
plot(diff.adf.Dp)

acf(e6[,2])

adf.test(diff(e6[,1]))
## Warning in adf.test(diff(e6[, 1])): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  diff(e6[, 1])
## Dickey-Fuller = -4.2398, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary
adf.test(diff(e6[,2]))
## Warning in adf.test(diff(e6[, 2])): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  diff(e6[, 2])
## Dickey-Fuller = -6.2017, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary
pp.test(diff(e6[,1]))
## Warning in pp.test(diff(e6[, 1])): p-value smaller than printed p-value
## 
##  Phillips-Perron Unit Root Test
## 
## data:  diff(e6[, 1])
## Dickey-Fuller Z(alpha) = -91.522, Truncation lag parameter = 4, p-value
## = 0.01
## alternative hypothesis: stationary
pp.test(diff(e6[,2]))
## Warning in pp.test(diff(e6[, 2])): p-value smaller than printed p-value
## 
##  Phillips-Perron Unit Root Test
## 
## data:  diff(e6[, 2])
## Dickey-Fuller Z(alpha) = -123.47, Truncation lag parameter = 4, p-value
## = 0.01
## alternative hypothesis: stationary

Una vez las series son estacionarias, se procede a realiza la estimacion

var_aic <- VARselect(e6,lag.max=10, type = "both")
VARselect(e6)
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      4      4      4      4 
## 
## $criteria
##                    1             2             3             4             5
## AIC(n) -1.841669e+01 -1.861079e+01 -1.955586e+01 -2.063736e+01 -2.056539e+01
## HQ(n)  -1.835229e+01 -1.850346e+01 -1.940560e+01 -2.044417e+01 -2.032927e+01
## SC(n)  -1.825743e+01 -1.834536e+01 -1.918425e+01 -2.015958e+01 -1.998144e+01
## FPE(n)  1.004041e-08  8.270206e-09  3.215267e-09  1.090873e-09  1.173312e-09
##                    6             7             8             9            10
## AIC(n) -2.053910e+01 -2.051298e+01 -2.051770e+01 -2.046229e+01 -2.046025e+01
## HQ(n)  -2.026005e+01 -2.019100e+01 -2.015279e+01 -2.005444e+01 -2.000947e+01
## SC(n)  -1.984897e+01 -1.971668e+01 -1.961523e+01 -1.945364e+01 -1.934543e+01
## FPE(n)  1.206122e-09  1.240214e-09  1.237229e-09  1.311578e-09  1.319081e-09
var_aic
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      4      4      4      4 
## 
## $criteria
##                    1             2             3             4             5
## AIC(n) -1.839053e+01 -1.859842e+01 -1.964035e+01 -2.062024e+01 -2.054757e+01
## HQ(n)  -1.830467e+01 -1.846962e+01 -1.946862e+01 -2.040558e+01 -2.028998e+01
## SC(n)  -1.817819e+01 -1.827990e+01 -1.921565e+01 -2.008937e+01 -1.991052e+01
## FPE(n)  1.030704e-08  8.374267e-09  2.955499e-09  1.110156e-09  1.195122e-09
##                    6             7             8             9            10
## AIC(n) -2.052637e+01 -2.051713e+01 -2.050813e+01 -2.046156e+01 -2.047710e+01
## HQ(n)  -2.022585e+01 -2.017368e+01 -2.012175e+01 -2.003225e+01 -2.000485e+01
## SC(n)  -1.978315e+01 -1.966774e+01 -1.955257e+01 -1.939982e+01 -1.930919e+01
## FPE(n)  1.222572e-09  1.236418e-09  1.250869e-09  1.314820e-09  1.299817e-09

Según el AIC, FPE, SC, HQ, el número de retraso óptimo es \(p = 4\),

VARorder(e6, maxp=10)
## selected order: aic =  4 
## selected order: bic =  4 
## selected order: hq =  4 
## Summary table:  
##        p      AIC      BIC       HQ     M(p) p-value
##  [1,]  0 -16.2725 -16.2725 -16.2725   0.0000  0.0000
##  [2,]  1 -18.4656 -18.3657 -18.4251 212.0517  0.0000
##  [3,]  2 -18.6674 -18.4676 -18.5864  25.3067  0.0000
##  [4,]  3 -19.6202 -19.3205 -19.4987  91.9651  0.0000
##  [5,]  4 -20.7094 -20.3098 -20.5474 101.8477  0.0000
##  [6,]  5 -20.6452 -20.1456 -20.4426   0.8987  0.9248
##  [7,]  6 -20.6266 -20.0271 -20.3835   4.6910  0.3205
##  [8,]  7 -20.6082 -19.9087 -20.3246   4.5932  0.3316
##  [9,]  8 -20.6206 -19.8213 -20.2966   6.9320  0.1395
## [10,]  9 -20.5729 -19.6736 -20.2083   2.0973  0.7179
## [11,] 10 -20.5786 -19.5794 -20.1735   6.0729  0.1938

VAR(4)

p1ct <- vars::VAR(e6, p = 4, type = "both")
p1ct
## 
## VAR Estimation Results:
## ======================= 
## 
## Estimated coefficients for equation R: 
## ====================================== 
## Call:
## R = R.l1 + Dp.l1 + R.l2 + Dp.l2 + R.l3 + Dp.l3 + R.l4 + Dp.l4 + const + trend 
## 
##          R.l1         Dp.l1          R.l2         Dp.l2          R.l3 
##  1.099030e+00  4.741335e-02 -2.277632e-01  6.742609e-02  2.234283e-01 
##         Dp.l3          R.l4         Dp.l4         const         trend 
##  7.871929e-02 -2.518795e-01  1.770827e-02  1.173696e-02 -3.632482e-05 
## 
## 
## Estimated coefficients for equation Dp: 
## ======================================= 
## Call:
## Dp = R.l1 + Dp.l1 + R.l2 + Dp.l2 + R.l3 + Dp.l3 + R.l4 + Dp.l4 + const + trend 
## 
##          R.l1         Dp.l1          R.l2         Dp.l2          R.l3 
##  1.883463e-01 -1.993946e-01  8.394473e-02 -1.829431e-01 -1.585265e-01 
##         Dp.l3          R.l4         Dp.l4         const         trend 
## -1.898380e-01  2.658589e-02  7.603442e-01 -2.454637e-03 -2.859212e-05
summary(p1ct, equation = "R")
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: R, Dp 
## Deterministic variables: both 
## Sample size: 103 
## Log Likelihood: 780.741 
## Roots of the characteristic polynomial:
## 0.9902 0.9882 0.9882 0.8398 0.8096 0.8096 0.6006 0.6006
## Call:
## vars::VAR(y = e6, p = 4, type = "both")
## 
## 
## Estimation results for equation R: 
## ================================== 
## R = R.l1 + Dp.l1 + R.l2 + Dp.l2 + R.l3 + Dp.l3 + R.l4 + Dp.l4 + const + trend 
## 
##         Estimate Std. Error t value Pr(>|t|)    
## R.l1   1.099e+00  1.007e-01  10.913  < 2e-16 ***
## Dp.l1  4.741e-02  5.656e-02   0.838  0.40406    
## R.l2  -2.278e-01  1.517e-01  -1.502  0.13653    
## Dp.l2  6.743e-02  5.695e-02   1.184  0.23949    
## R.l3   2.234e-01  1.518e-01   1.472  0.14450    
## Dp.l3  7.872e-02  5.670e-02   1.388  0.16833    
## R.l4  -2.519e-01  1.031e-01  -2.443  0.01647 *  
## Dp.l4  1.771e-02  5.612e-02   0.316  0.75306    
## const  1.174e-02  4.157e-03   2.824  0.00581 ** 
## trend -3.632e-05  2.418e-05  -1.502  0.13639    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.005337 on 93 degrees of freedom
## Multiple R-Squared: 0.9068,  Adjusted R-squared: 0.8978 
## F-statistic: 100.5 on 9 and 93 DF,  p-value: < 2.2e-16 
## 
## 
## 
## Covariance matrix of residuals:
##             R        Dp
## R   2.849e-05 -3.02e-06
## Dp -3.020e-06  3.88e-05
## 
## Correlation matrix of residuals:
##           R       Dp
## R   1.00000 -0.09086
## Dp -0.09086  1.00000
plot(p1ct, names = "R")

summary(p1ct, equation = "Dp")
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: R, Dp 
## Deterministic variables: both 
## Sample size: 103 
## Log Likelihood: 780.741 
## Roots of the characteristic polynomial:
## 0.9902 0.9882 0.9882 0.8398 0.8096 0.8096 0.6006 0.6006
## Call:
## vars::VAR(y = e6, p = 4, type = "both")
## 
## 
## Estimation results for equation Dp: 
## =================================== 
## Dp = R.l1 + Dp.l1 + R.l2 + Dp.l2 + R.l3 + Dp.l3 + R.l4 + Dp.l4 + const + trend 
## 
##         Estimate Std. Error t value Pr(>|t|)    
## R.l1   1.883e-01  1.175e-01   1.603  0.11241    
## Dp.l1 -1.994e-01  6.601e-02  -3.021  0.00326 ** 
## R.l2   8.394e-02  1.770e-01   0.474  0.63640    
## Dp.l2 -1.829e-01  6.647e-02  -2.752  0.00711 ** 
## R.l3  -1.585e-01  1.772e-01  -0.895  0.37325    
## Dp.l3 -1.898e-01  6.617e-02  -2.869  0.00509 ** 
## R.l4   2.659e-02  1.203e-01   0.221  0.82563    
## Dp.l4  7.603e-01  6.549e-02  11.609  < 2e-16 ***
## const -2.455e-03  4.851e-03  -0.506  0.61403    
## trend -2.859e-05  2.822e-05  -1.013  0.31354    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.006229 on 93 degrees of freedom
## Multiple R-Squared: 0.903,   Adjusted R-squared: 0.8936 
## F-statistic: 96.17 on 9 and 93 DF,  p-value: < 2.2e-16 
## 
## 
## 
## Covariance matrix of residuals:
##             R        Dp
## R   2.849e-05 -3.02e-06
## Dp -3.020e-06  3.88e-05
## 
## Correlation matrix of residuals:
##           R       Dp
## R   1.00000 -0.09086
## Dp -0.09086  1.00000
plot(p1ct , name="Dp")

Diagnostico VAR(4)

ser11 <- serial.test(p1ct, lags.pt =4, type = "PT.asymptotic")
ser11$serial
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object p1ct
## Chi-squared = 11.289, df = 0, p-value < 2.2e-16
norm1 <-normality.test(p1ct)
norm1$jb.mul
## $JB
## 
##  JB-Test (multivariate)
## 
## data:  Residuals of VAR object p1ct
## Chi-squared = 2.2792, df = 4, p-value = 0.6846
## 
## 
## $Skewness
## 
##  Skewness only (multivariate)
## 
## data:  Residuals of VAR object p1ct
## Chi-squared = 1.43, df = 2, p-value = 0.4892
## 
## 
## $Kurtosis
## 
##  Kurtosis only (multivariate)
## 
## data:  Residuals of VAR object p1ct
## Chi-squared = 0.84915, df = 2, p-value = 0.654
arch1 <- arch.test(p1ct, lags.multi = 12)
arch1$arch.mul
## 
##  ARCH (multivariate)
## 
## data:  Residuals of VAR object p1ct
## Chi-squared = 140.71, df = 108, p-value = 0.01885
plot(arch1, names = "R")

plot(stability(p1ct), nc = 2)

Estimar prueba Johanssen cointegracion.

vec <- ca.jo(e6, ecdet = "none", type = "eigen",
             K = 4, spec = "transitory", season = 4)

summary(vec)
## 
## ###################### 
## # Johansen-Procedure # 
## ###################### 
## 
## Test type: maximal eigenvalue statistic (lambda max) , with linear trend 
## 
## Eigenvalues (lambda):
## [1] 0.15184737 0.03652339
## 
## Values of teststatistic and critical values of test:
## 
##           test 10pct  5pct  1pct
## r <= 1 |  3.83  6.50  8.18 11.65
## r = 0  | 16.96 12.91 14.90 19.19
## 
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
## 
##            R.l1    Dp.l1
## R.l1   1.000000 1.000000
## Dp.l1 -3.961937 1.700513
## 
## Weights W:
## (This is the loading matrix)
## 
##            R.l1       Dp.l1
## R.d  -0.1028717 -0.03938511
## Dp.d  0.1577005 -0.02146119
class(vec)
## [1] "ca.jo"
## attr(,"package")
## [1] "urca"

En la salida anterior, se rechaza la hipótesis nula de no cointegración y no rechazamos la hipótesis nula de a lo sumo una ecuación de cointegración. Por lo tanto concluimos que hay una ecuación de cointegración en el modelo bivariado.

Transformar VEC a VAR con r = 1

var <- vec2var(vec, r = 1)
var
## 
## Coefficient matrix of lagged endogenous variables:
## 
## A1:
##         R.l1      Dp.l1
## R  1.1658999 0.19732143
## Dp 0.2230793 0.03598872
## 
## 
## A2:
##           R.l2       Dp.l2
## R  -0.28658151 -0.01273115
## Dp -0.06967063 -0.05162046
## 
## 
## A3:
##          R.l3      Dp.l3
## R  0.24061842 0.11535798
## Dp 0.02269341 0.04361369
## 
## 
## A4:
##           R.l4     Dp.l4
## R  -0.22280852 0.1076232
## Dp -0.01840163 0.3472186
## 
## 
## Coefficient matrix of deterministic regressor(s).
## 
##        constant         sd1          sd2          sd3
## R   0.003982491 0.007367097 -0.001898661 -0.001485568
## Dp -0.006961569 0.016214946  0.017688578  0.034124804
class(var)
## [1] "vec2var"
var1<-cajorls(vec, r=1)
var1
## $rlm
## 
## Call:
## lm(formula = substitute(form1), data = data.mat)
## 
## Coefficients:
##           R.d        Dp.d     
## ect1      -0.102872   0.157700
## constant   0.003982  -0.006962
## sd1        0.007367   0.016215
## sd2       -0.001899   0.017689
## sd3       -0.001486   0.034125
## R.dl1      0.268772   0.065379
## Dp.dl1    -0.210250  -0.339212
## R.dl2     -0.017810  -0.004292
## Dp.dl2    -0.222981  -0.390832
## R.dl3      0.222809   0.018402
## Dp.dl3    -0.107623  -0.347219
## 
## 
## $beta
##            ect1
## R.l1   1.000000
## Dp.l1 -3.961937

Validacion

Correlación serial

\(H_0: \text{Ausencia de correlación serial en los residuales}\)

ser11 <- serial.test(var, lags.pt = 5, type = "PT.asymptotic")
ser11$serial
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object var
## Chi-squared = 4.8421, df = 6, p-value = 0.5642

Normalidad de los residuales

\(H_0 : \text{Los residuales siguen una distribución normal}\)

norm1 <-normality.test(var)
norm1$jb.mul
## $JB
## 
##  JB-Test (multivariate)
## 
## data:  Residuals of VAR object var
## Chi-squared = 2.5413, df = 4, p-value = 0.6373
## 
## 
## $Skewness
## 
##  Skewness only (multivariate)
## 
## data:  Residuals of VAR object var
## Chi-squared = 0.21828, df = 2, p-value = 0.8966
## 
## 
## $Kurtosis
## 
##  Kurtosis only (multivariate)
## 
## data:  Residuals of VAR object var
## Chi-squared = 2.323, df = 2, p-value = 0.313

Homocedasticiad

\(H_0 : \text{Los residuales son homocedasticos}\)

arch1 <- arch.test(var, lags.multi = 7)
arch1$arch.mul
## 
##  ARCH (multivariate)
## 
## data:  Residuals of VAR object var
## Chi-squared = 100.43, df = 63, p-value = 0.001901
summary(arch1)
##          Length Class  Mode   
## resid    206    -none- numeric
## arch.mul   5    htest  list
class(arch1)
## [1] "varcheck"
arch1$resid
##          resids of R  resids of Dp
##   [1,]  0.0089312531 -0.0047001852
##   [2,] -0.0042602121 -0.0008350771
##   [3,]  0.0010582338  0.0033856924
##   [4,]  0.0046628280  0.0008156606
##   [5,] -0.0003573043  0.0042282830
##   [6,]  0.0001970870  0.0048599211
##   [7,] -0.0098541072  0.0019377867
##   [8,] -0.0102951147 -0.0018336384
##   [9,] -0.0049818395 -0.0029426157
##  [10,]  0.0049840608 -0.0087108011
##  [11,]  0.0027283834  0.0005862713
##  [12,] -0.0077997354 -0.0066323434
##  [13,]  0.0068952206  0.0036329496
##  [14,] -0.0029341183  0.0049280442
##  [15,] -0.0031588384 -0.0117837693
##  [16,] -0.0018373066  0.0047879117
##  [17,] -0.0074782826  0.0064058522
##  [18,] -0.0024471435 -0.0013619971
##  [19,]  0.0037246946  0.0087234652
##  [20,] -0.0061301842  0.0026336018
##  [21,]  0.0025501326  0.0073996774
##  [22,]  0.0005495901  0.0082689313
##  [23,]  0.0015346883 -0.0064877486
##  [24,]  0.0031460159  0.0013472429
##  [25,]  0.0042837771 -0.0026563443
##  [26,] -0.0034503740  0.0103048456
##  [27,]  0.0022951626  0.0002099843
##  [28,]  0.0132066048  0.0037337705
##  [29,] -0.0164457392  0.0047025994
##  [30,]  0.0013492074 -0.0022860388
##  [31,]  0.0068001788 -0.0025908444
##  [32,]  0.0138502777 -0.0077763529
##  [33,]  0.0053361285 -0.0018624897
##  [34,]  0.0013412623 -0.0017371339
##  [35,] -0.0115866344  0.0021410791
##  [36,] -0.0002926766 -0.0047570111
##  [37,] -0.0030887333 -0.0050802452
##  [38,]  0.0008885027  0.0046045772
##  [39,] -0.0050158689 -0.0047865582
##  [40,] -0.0022377864 -0.0014751709
##  [41,]  0.0081203614 -0.0066641151
##  [42,]  0.0043458432  0.0026242402
##  [43,]  0.0017537056 -0.0002554060
##  [44,] -0.0037018800 -0.0084847430
##  [45,]  0.0039082178 -0.0066576987
##  [46,] -0.0025106918 -0.0027611740
##  [47,] -0.0019491393  0.0038759137
##  [48,]  0.0087829049 -0.0071962249
##  [49,] -0.0052773418 -0.0032065400
##  [50,] -0.0019189915  0.0054531574
##  [51,]  0.0029164645  0.0051455755
##  [52,] -0.0050459488  0.0028425110
##  [53,]  0.0016161795  0.0025388285
##  [54,] -0.0041034556  0.0006133145
##  [55,]  0.0041815592  0.0028242545
##  [56,] -0.0059289054 -0.0011930456
##  [57,] -0.0007963789 -0.0010861957
##  [58,]  0.0061118459 -0.0075814319
##  [59,] -0.0016662489  0.0050945219
##  [60,] -0.0021897958 -0.0036101297
##  [61,]  0.0037810107  0.0032558399
##  [62,]  0.0029535144 -0.0023996223
##  [63,]  0.0017868504  0.0063756658
##  [64,]  0.0059285888  0.0006417301
##  [65,] -0.0009505614 -0.0021790391
##  [66,]  0.0012412628  0.0005708646
##  [67,]  0.0074087432  0.0030924259
##  [68,]  0.0100233020  0.0014843892
##  [69,] -0.0015919047 -0.0029529433
##  [70,]  0.0018637155 -0.0070612357
##  [71,]  0.0004386742 -0.0097428913
##  [72,] -0.0012527762  0.0006833903
##  [73,]  0.0014500748  0.0120198259
##  [74,]  0.0025385648  0.0022771215
##  [75,]  0.0029312242  0.0103318474
##  [76,] -0.0074394464  0.0009071638
##  [77,]  0.0005697748  0.0006492072
##  [78,] -0.0033611692  0.0029226335
##  [79,] -0.0059499138 -0.0068888447
##  [80,] -0.0081918082  0.0060446557
##  [81,]  0.0004682640  0.0035197987
##  [82,] -0.0061675902 -0.0079989578
##  [83,]  0.0005383067  0.0019447199
##  [84,]  0.0037725575  0.0025079557
##  [85,]  0.0047439528 -0.0021581048
##  [86,]  0.0059068699 -0.0006774194
##  [87,]  0.0004034948 -0.0038330122
##  [88,] -0.0038577402 -0.0015048768
##  [89,] -0.0073825752  0.0026690476
##  [90,] -0.0009835281  0.0013534949
##  [91,] -0.0027453726 -0.0042700193
##  [92,]  0.0055222552  0.0030949142
##  [93,] -0.0012890070 -0.0075171797
##  [94,] -0.0008696326 -0.0024004053
##  [95,] -0.0011520223 -0.0024997022
##  [96,]  0.0009808237  0.0065141737
##  [97,] -0.0019053397 -0.0041049957
##  [98,]  0.0040568470 -0.0012081357
##  [99,]  0.0017915422 -0.0023235272
## [100,] -0.0036750535  0.0064244655
## [101,] -0.0011093399  0.0027467829
## [102,] -0.0053212669 -0.0017617156
## [103,]  0.0007862390 -0.0002068801
plot(arch1)

#plot(vars::stability(var), nc = 2)

La función de respuesta al impulso se calcula de la manera habitual utilizando la función irf.

ir <- vars::irf(var, n.ahead = 20, impulse = "R", response = "Dp")

plot(ir)

ir1 <- vars::irf(var, n.ahead = 20, impulse = "Dp", response = "R")

plot(ir1)

Descomposición de la varianza FEVD

fevd.R <- vars::fevd(var, n.ahead = 12)
plot(fevd.R)

Pronóstico

predictions <- predict(var, n.ahead = 16, ci = 0.95)
plot(predictions)

rt=e6[,1] -3.9619*e6[,2]
plot(rt)

adf.test(rt)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  rt
## Dickey-Fuller = -2.9879, Lag order = 4, p-value = 0.1669
## alternative hypothesis: stationary
pp.test(rt)
## Warning in pp.test(rt): p-value smaller than printed p-value
## 
##  Phillips-Perron Unit Root Test
## 
## data:  rt
## Dickey-Fuller Z(alpha) = -105.3, Truncation lag parameter = 4, p-value
## = 0.01
## alternative hypothesis: stationary
summary(ur.df(rt))
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression none 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 - 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.09005 -0.01904  0.04231  0.09689  0.19470 
## 
## Coefficients:
##            Estimate Std. Error t value Pr(>|t|)    
## z.lag.1    -0.99203    0.13754  -7.213 9.54e-11 ***
## z.diff.lag  0.01369    0.09821   0.139    0.889    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.08586 on 103 degrees of freedom
## Multiple R-squared:  0.4884, Adjusted R-squared:  0.4785 
## F-statistic: 49.16 on 2 and 103 DF,  p-value: 1.024e-15
## 
## 
## Value of test-statistic is: -7.2126 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau1 -2.58 -1.95 -1.62