Ejemplo VEC

WILSON SANDOVAL

r Sys.Date()

Cargar las librerias

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(tseries)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(forecast)
library(urca)
library(highcharter)
## Highcharts (www.highcharts.com) is a Highsoft software product which is
## not free for commercial and Governmental use
## 
## Attaching package: 'highcharter'
## The following object is masked from 'package:lmtest':
## 
##     unemployment

Cargar la base de datos

Utilizaron las siguientes series: productividad laboral definida como la diferencia logarítmica entre el PIB y el empleo, el registro de empleo, tasa de desempleo y salarios reales, definidos como el logaritmo del salario real índice. Estas series están representadas por “prod”, “e”, “U” y “rw”, respectivamente. Se toman los datos de la base de datos de la OCDE y abarca desde el primer trimestre de 1980 hasta el cuarto trimestre de 2004

data(Canada)

Canada=as.data.frame(Canada)

layout(matrix(1:4, nrow = 2, ncol = 2))
plot.ts(Canada$e, main = "Employment", ylab = "", xlab = "")
plot.ts(Canada$prod, main = "Productivity", ylab = "", xlab = "")
plot.ts(Canada$rw, main = "Real Wage", ylab = "", xlab = "")
plot.ts(Canada$U, main = "Unemployment Rate", ylab = "", xlab = "")

.

var_canada<-ts(Canada[,c(1,2,3,4)],frequency = 12)

plot.ts(var_canada)

hchart(var_canada)

Pruebas de estacionariedad

adf.empleo <- ur.df(var_canada[,1], type = "trend", selectlags = "BIC")
summary(adf.empleo)   
## 
## ############################################### 
## # 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.84769 -0.24745 -0.02081  0.24187  0.82344 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 47.681128  17.445770   2.733  0.00776 ** 
## z.lag.1     -0.051256   0.018785  -2.729  0.00786 ** 
## tt           0.019217   0.007005   2.743  0.00754 ** 
## z.diff.lag   0.753011   0.075724   9.944 1.61e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3937 on 78 degrees of freedom
## Multiple R-squared:  0.5674, Adjusted R-squared:  0.5508 
## F-statistic: 34.11 on 3 and 78 DF,  p-value: 3.462e-14
## 
## 
## Value of test-statistic is: -2.7286 4.0771 3.8115 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -4.04 -3.45 -3.15
## phi2  6.50  4.88  4.16
## phi3  8.73  6.49  5.47
plot(adf.empleo)

adf.test(var_canada[,1])
## 
##  Augmented Dickey-Fuller Test
## 
## data:  var_canada[, 1]
## Dickey-Fuller = -2.148, Lag order = 4, p-value = 0.5152
## alternative hypothesis: stationary
adf.product <- ur.df(var_canada[,2], type = "trend", selectlags = "BIC")
summary(adf.product)   
## 
## ############################################### 
## # 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 
## -2.22554 -0.40892  0.02578  0.41669  1.70908 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 29.281115  14.506222   2.019  0.04697 * 
## z.lag.1     -0.073036   0.036127  -2.022  0.04664 * 
## tt           0.014219   0.006151   2.312  0.02344 * 
## z.diff.lag   0.310251   0.109678   2.829  0.00594 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6797 on 78 degrees of freedom
## Multiple R-squared:  0.1467, Adjusted R-squared:  0.1139 
## F-statistic: 4.471 on 3 and 78 DF,  p-value: 0.005977
## 
## 
## Value of test-statistic is: -2.0216 2.4483 2.6786 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -4.04 -3.45 -3.15
## phi2  6.50  4.88  4.16
## phi3  8.73  6.49  5.47
plot(adf.product)

pruebas de estacionariedad salario

adf.salario <- ur.df(var_canada[,3], type = "trend", selectlags = "BIC")
summary(adf.salario)   
## 
## ############################################### 
## # 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 
## -2.14517 -0.55886 -0.00263  0.50749  2.96709 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 23.38961    7.77366   3.009  0.00353 **
## z.lag.1     -0.05421    0.01925  -2.816  0.00615 **
## tt           0.03134    0.01797   1.744  0.08512 . 
## z.diff.lag   0.17639    0.10670   1.653  0.10233   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8466 on 78 degrees of freedom
## Multiple R-squared:  0.3674, Adjusted R-squared:  0.3431 
## F-statistic:  15.1 on 3 and 78 DF,  p-value: 7.717e-08
## 
## 
## Value of test-statistic is: -2.8163 13.4198 11.3011 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -4.04 -3.45 -3.15
## phi2  6.50  4.88  4.16
## phi3  8.73  6.49  5.47
plot(adf.salario)

adf.desempleo <- ur.df(var_canada[,1], type = "trend", selectlags = "BIC")
summary(adf.desempleo)   
## 
## ############################################### 
## # 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.84769 -0.24745 -0.02081  0.24187  0.82344 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 47.681128  17.445770   2.733  0.00776 ** 
## z.lag.1     -0.051256   0.018785  -2.729  0.00786 ** 
## tt           0.019217   0.007005   2.743  0.00754 ** 
## z.diff.lag   0.753011   0.075724   9.944 1.61e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3937 on 78 degrees of freedom
## Multiple R-squared:  0.5674, Adjusted R-squared:  0.5508 
## F-statistic: 34.11 on 3 and 78 DF,  p-value: 3.462e-14
## 
## 
## Value of test-statistic is: -2.7286 4.0771 3.8115 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -4.04 -3.45 -3.15
## phi2  6.50  4.88  4.16
## phi3  8.73  6.49  5.47
plot(adf.desempleo)

Con una diferencia

diff.adf.empleo <- ur.df(diff(var_canada[,1]), type = "trend", selectlags = "BIC")
summary(diff.adf.empleo)   
## 
## ############################################### 
## # 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.9077 -0.2442 -0.0408  0.3000  0.7114 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.086812   0.092323   0.940   0.3500    
## z.lag.1     -0.364701   0.080222  -4.546    2e-05 ***
## tt           0.001341   0.001870   0.717   0.4756    
## z.diff.lag   0.322536   0.108388   2.976   0.0039 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3914 on 77 degrees of freedom
## Multiple R-squared:  0.2273, Adjusted R-squared:  0.1972 
## F-statistic: 7.549 on 3 and 77 DF,  p-value: 0.0001715
## 
## 
## Value of test-statistic is: -4.5462 6.9125 10.3669 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -4.04 -3.45 -3.15
## phi2  6.50  4.88  4.16
## phi3  8.73  6.49  5.47
plot(diff.adf.empleo)

diff.adf.product <- ur.df(diff(var_canada[,2]), type = "trend", selectlags = "BIC")
summary(diff.adf.product)   
## 
## ############################################### 
## # 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 
## -2.08255 -0.41492  0.03547  0.42292  1.77919 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.007671   0.160585  -0.048    0.962    
## z.lag.1     -0.723368   0.139237  -5.195 1.63e-06 ***
## tt           0.003058   0.003456   0.885    0.379    
## z.diff.lag  -0.024356   0.114799  -0.212    0.833    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6981 on 77 degrees of freedom
## Multiple R-squared:  0.3679, Adjusted R-squared:  0.3433 
## F-statistic: 14.94 on 3 and 77 DF,  p-value: 9.378e-08
## 
## 
## Value of test-statistic is: -5.1952 9.1153 13.6696 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -4.04 -3.45 -3.15
## phi2  6.50  4.88  4.16
## phi3  8.73  6.49  5.47
plot(diff.adf.product)

diff.adf.salario <- ur.df(diff(var_canada[,3]), type = "trend", selectlags = "BIC")
summary(diff.adf.salario)   
## 
## ############################################### 
## # 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 
## -2.2737 -0.5911 -0.0613  0.4972  3.4851 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.502206   0.344946   4.355 4.05e-05 ***
## z.lag.1     -0.791156   0.141679  -5.584 3.38e-07 ***
## tt          -0.017532   0.005305  -3.305  0.00145 ** 
## z.diff.lag   0.020803   0.114310   0.182  0.85607    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.8924 on 77 degrees of freedom
## Multiple R-squared:  0.388,  Adjusted R-squared:  0.3642 
## F-statistic: 16.27 on 3 and 77 DF,  p-value: 2.764e-08
## 
## 
## Value of test-statistic is: -5.5841 10.4507 15.5933 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -4.04 -3.45 -3.15
## phi2  6.50  4.88  4.16
## phi3  8.73  6.49  5.47
plot(diff.adf.salario)

diff.adf.desempleo <- ur.df(diff(var_canada[,1]), type = "trend", selectlags = "BIC")
summary(diff.adf.desempleo)   
## 
## ############################################### 
## # 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.9077 -0.2442 -0.0408  0.3000  0.7114 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.086812   0.092323   0.940   0.3500    
## z.lag.1     -0.364701   0.080222  -4.546    2e-05 ***
## tt           0.001341   0.001870   0.717   0.4756    
## z.diff.lag   0.322536   0.108388   2.976   0.0039 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3914 on 77 degrees of freedom
## Multiple R-squared:  0.2273, Adjusted R-squared:  0.1972 
## F-statistic: 7.549 on 3 and 77 DF,  p-value: 0.0001715
## 
## 
## Value of test-statistic is: -4.5462 6.9125 10.3669 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau3 -4.04 -3.45 -3.15
## phi2  6.50  4.88  4.16
## phi3  8.73  6.49  5.47
plot(diff.adf.desempleo)

Se puede concluir que todas las series temporales están integradas de orden uno

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

VARselect(Canada,lag.max=10, type = "both")
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      3      2      1      3 
## 
## $criteria
##                   1            2             3            4            5
## AIC(n) -6.457999837 -6.862930587 -6.9695915550 -6.826230019 -6.696865092
## HQ(n)  -6.159906898 -6.366109023 -6.2740413655 -5.931951204 -5.603857651
## SC(n)  -5.710735482 -5.617489996 -5.2259747277 -4.584436956 -3.956895792
## FPE(n)  0.001570168  0.001052827  0.0009575467  0.001128994  0.001329669
##                   6           7            8            9           10
## AIC(n) -6.687175990 -6.55982329 -6.584746129 -6.493397603 -6.523612352
## HQ(n)  -5.395439924 -5.06935860 -4.895552811 -4.605475660 -4.436961783
## SC(n)  -3.449030454 -2.82350152 -2.350248120 -1.760723357 -1.292761870
## FPE(n)  0.001412901  0.00172546  0.001859561  0.002330702  0.002704777

Según el AIC y el FPE, el número de retraso óptimo es \(p = 3\), mientras que el criterio HQ indica \(p = 2\) y el criterio SC indica una longitud de retraso óptima de \(p = 1\).

VAR(1)

Canada <- Canada[, c("prod", "e", "U", "rw")]
p1ct <- VAR(Canada, p = 1, type = "both")
p1ct
## 
## VAR Estimation Results:
## ======================= 
## 
## Estimated coefficients for equation prod: 
## ========================================= 
## Call:
## prod = prod.l1 + e.l1 + U.l1 + rw.l1 + const + trend 
## 
##     prod.l1        e.l1        U.l1       rw.l1       const       trend 
##  0.96313671  0.01291155  0.21108918 -0.03909399 16.24340747  0.04613085 
## 
## 
## Estimated coefficients for equation e: 
## ====================================== 
## Call:
## e = prod.l1 + e.l1 + U.l1 + rw.l1 + const + trend 
## 
##       prod.l1          e.l1          U.l1         rw.l1         const 
##    0.19465028    1.23892283    0.62301475   -0.06776277 -278.76121138 
##         trend 
##   -0.04066045 
## 
## 
## Estimated coefficients for equation U: 
## ====================================== 
## Call:
## U = prod.l1 + e.l1 + U.l1 + rw.l1 + const + trend 
## 
##      prod.l1         e.l1         U.l1        rw.l1        const        trend 
##  -0.12319201  -0.24844234   0.39158002   0.06580819 259.98200967   0.03451663 
## 
## 
## Estimated coefficients for equation rw: 
## ======================================= 
## Call:
## rw = prod.l1 + e.l1 + U.l1 + rw.l1 + const + trend 
## 
##      prod.l1         e.l1         U.l1        rw.l1        const        trend 
##  -0.22308744  -0.05104397  -0.36863956   0.94890946 163.02453066   0.07142229
summary(p1ct, equation = "e")
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: prod, e, U, rw 
## Deterministic variables: both 
## Sample size: 83 
## Log Likelihood: -207.525 
## Roots of the characteristic polynomial:
## 0.9504 0.9504 0.9045 0.7513
## Call:
## VAR(y = Canada, p = 1, type = "both")
## 
## 
## Estimation results for equation e: 
## ================================== 
## e = prod.l1 + e.l1 + U.l1 + rw.l1 + const + trend 
## 
##           Estimate Std. Error t value Pr(>|t|)    
## prod.l1    0.19465    0.03612   5.389 7.49e-07 ***
## e.l1       1.23892    0.08632  14.353  < 2e-16 ***
## U.l1       0.62301    0.16927   3.681 0.000430 ***
## rw.l1     -0.06776    0.02828  -2.396 0.018991 *  
## const   -278.76121   75.18295  -3.708 0.000392 ***
## trend     -0.04066    0.01970  -2.064 0.042378 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.4701 on 77 degrees of freedom
## Multiple R-Squared: 0.9975,  Adjusted R-squared: 0.9973 
## F-statistic:  6088 on 5 and 77 DF,  p-value: < 2.2e-16 
## 
## 
## 
## Covariance matrix of residuals:
##           prod        e        U        rw
## prod  0.469517  0.06767 -0.04128  0.002141
## e     0.067667  0.22096 -0.13200 -0.082793
## U    -0.041280 -0.13200  0.12161  0.063738
## rw    0.002141 -0.08279  0.06374  0.593174
## 
## Correlation matrix of residuals:
##           prod       e       U        rw
## prod  1.000000  0.2101 -0.1728  0.004057
## e     0.210085  1.0000 -0.8052 -0.228688
## U    -0.172753 -0.8052  1.0000  0.237307
## rw    0.004057 -0.2287  0.2373  1.000000
plot(p1ct, names = "e")

plot(p1ct , name="U")

Diagnostico VAR(1)

ser11 <- serial.test(p1ct, lags.pt = 16, type = "PT.asymptotic")
ser11$serial
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object p1ct
## Chi-squared = 233.5, df = 240, p-value = 0.606
norm1 <-normality.test(p1ct)
norm1$jb.mul
## $JB
## 
##  JB-Test (multivariate)
## 
## data:  Residuals of VAR object p1ct
## Chi-squared = 9.9189, df = 8, p-value = 0.2708
## 
## 
## $Skewness
## 
##  Skewness only (multivariate)
## 
## data:  Residuals of VAR object p1ct
## Chi-squared = 6.356, df = 4, p-value = 0.1741
## 
## 
## $Kurtosis
## 
##  Kurtosis only (multivariate)
## 
## data:  Residuals of VAR object p1ct
## Chi-squared = 3.5629, df = 4, p-value = 0.4684
arch1 <- arch.test(p1ct, lags.multi = 5)
arch1$arch.mul
## 
##  ARCH (multivariate)
## 
## data:  Residuals of VAR object p1ct
## Chi-squared = 570.14, df = 500, p-value = 0.01606
plot(arch1, names = "e")

plot(stability(p1ct), nc = 2)

VEC r = 1

vec <- ca.jo(Canada[, c("rw", "prod", "e", "U")], type = "trace", ecdet = "trend", K = 3, spec = "transitory") 

summary(vec)
## 
## ###################### 
## # Johansen-Procedure # 
## ###################### 
## 
## Test type: trace statistic , with linear trend in cointegration 
## 
## Eigenvalues (lambda):
## [1]  4.505013e-01  1.962777e-01  1.676668e-01  4.647108e-02 -2.869035e-17
## 
## Values of teststatistic and critical values of test:
## 
##           test 10pct  5pct  1pct
## r <= 3 |  3.85 10.49 12.25 16.26
## r <= 2 | 18.72 22.76 25.32 30.45
## r <= 1 | 36.42 39.06 42.44 48.45
## r = 0  | 84.92 59.14 62.99 70.05
## 
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
## 
##                rw.l1     prod.l1       e.l1       U.l1   trend.l1
## rw.l1     1.00000000   1.0000000  1.0000000   1.000000  1.0000000
## prod.l1   0.54487553  -3.0021508  0.7153696  -7.173608  0.4087221
## e.l1     -0.01299605  -3.8867890 -2.0625220 -30.429074 -3.3884676
## U.l1      1.72657189 -10.2183403 -5.3124427 -49.077208 -5.1326687
## trend.l1 -0.70918872   0.6913363 -0.3643533  11.424630  0.1157125
## 
## Weights W:
## (This is the loading matrix)
## 
##               rw.l1      prod.l1        e.l1          U.l1      trend.l1
## rw.d   -0.084814510  0.048563998 -0.02368721 -0.0016583070 -5.214289e-12
## prod.d -0.011994081  0.009204887 -0.09921487  0.0020567547 -8.557489e-12
## e.d    -0.015606038 -0.038019448 -0.01140202 -0.0005559337 -1.893956e-12
## U.d    -0.008659911  0.020499658  0.02896325  0.0009140795  3.357504e-12
vec.r1 <- cajorls(vec, r = 1)
vec.r1
## $rlm
## 
## Call:
## lm(formula = substitute(form1), data = data.mat)
## 
## Coefficients:
##           rw.d       prod.d     e.d        U.d      
## ect1      -0.084815  -0.011994  -0.015606  -0.008660
## constant  55.469125   8.274808  10.331308   5.687832
## rw.dl1    -0.012082   0.004707  -0.078491   0.017263
## prod.dl1  -0.074493   0.234441   0.200953  -0.138916
## e.dl1     -0.634084  -0.246544   0.821558  -0.646846
## U.dl1      0.063137  -0.979868   0.003379  -0.191125
## rw.dl2    -0.157388  -0.190264  -0.095835   0.080354
## prod.dl2  -0.251940  -0.029520   0.048273  -0.002909
## e.dl2      0.081197  -0.580473  -0.459693  -0.019741
## U.dl2     -0.230009  -0.128101  -0.103415  -0.262685
## 
## 
## $beta
##                 ect1
## rw.l1     1.00000000
## prod.l1   0.54487553
## e.l1     -0.01299605
## U.l1      1.72657189
## trend.l1 -0.70918872
vec <- ca.jo(Canada[, c("rw", "prod", "e", "U")], type = "eigen", ecdet = "trend", K = 3, spec = "transitory") 

summary(vec)
## 
## ###################### 
## # Johansen-Procedure # 
## ###################### 
## 
## Test type: maximal eigenvalue statistic (lambda max) , with linear trend in cointegration 
## 
## Eigenvalues (lambda):
## [1]  4.505013e-01  1.962777e-01  1.676668e-01  4.647108e-02 -2.869035e-17
## 
## Values of teststatistic and critical values of test:
## 
##           test 10pct  5pct  1pct
## r <= 3 |  3.85 10.49 12.25 16.26
## r <= 2 | 14.87 16.85 18.96 23.65
## r <= 1 | 17.70 23.11 25.54 30.34
## r = 0  | 48.50 29.12 31.46 36.65
## 
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
## 
##                rw.l1     prod.l1       e.l1       U.l1   trend.l1
## rw.l1     1.00000000   1.0000000  1.0000000   1.000000  1.0000000
## prod.l1   0.54487553  -3.0021508  0.7153696  -7.173608  0.4087221
## e.l1     -0.01299605  -3.8867890 -2.0625220 -30.429074 -3.3884676
## U.l1      1.72657189 -10.2183403 -5.3124427 -49.077208 -5.1326687
## trend.l1 -0.70918872   0.6913363 -0.3643533  11.424630  0.1157125
## 
## Weights W:
## (This is the loading matrix)
## 
##               rw.l1      prod.l1        e.l1          U.l1      trend.l1
## rw.d   -0.084814510  0.048563998 -0.02368721 -0.0016583070 -5.214289e-12
## prod.d -0.011994081  0.009204887 -0.09921487  0.0020567547 -8.557489e-12
## e.d    -0.015606038 -0.038019448 -0.01140202 -0.0005559337 -1.893956e-12
## U.d    -0.008659911  0.020499658  0.02896325  0.0009140795  3.357504e-12
vec.r1 <- cajorls(vec, r = 1)
vec.r1
## $rlm
## 
## Call:
## lm(formula = substitute(form1), data = data.mat)
## 
## Coefficients:
##           rw.d       prod.d     e.d        U.d      
## ect1      -0.084815  -0.011994  -0.015606  -0.008660
## constant  55.469125   8.274808  10.331308   5.687832
## rw.dl1    -0.012082   0.004707  -0.078491   0.017263
## prod.dl1  -0.074493   0.234441   0.200953  -0.138916
## e.dl1     -0.634084  -0.246544   0.821558  -0.646846
## U.dl1      0.063137  -0.979868   0.003379  -0.191125
## rw.dl2    -0.157388  -0.190264  -0.095835   0.080354
## prod.dl2  -0.251940  -0.029520   0.048273  -0.002909
## e.dl2      0.081197  -0.580473  -0.459693  -0.019741
## U.dl2     -0.230009  -0.128101  -0.103415  -0.262685
## 
## 
## $beta
##                 ect1
## rw.l1     1.00000000
## prod.l1   0.54487553
## e.l1     -0.01299605
## U.l1      1.72657189
## trend.l1 -0.70918872

vecm <- ca.jo(Canada[, c("prod", "e", "U", "rw")], type = "trace", 
              ecdet = "trend", K = 3, spec = "transitory")
SR <- matrix(NA, nrow = 4, ncol = 4)
SR[4, 2] <- 0
LR <- matrix(NA, nrow = 4, ncol = 4)
LR[1, 2:4] <- 0
LR[2:4, 4] <- 0
svec <- SVEC(vecm, LR = LR, SR = SR, r = 1, lrtest = FALSE, 
             boot = TRUE, runs = 100)
summary(svec)
## 
## SVEC Estimation Results:
## ======================== 
## 
## Call:
## SVEC(x = vecm, LR = LR, SR = SR, r = 1, lrtest = FALSE, boot = TRUE, 
##     runs = 100)
## 
## Type: B-model 
## Sample size: 81 
## Log Likelihood: -161.838 
## Number of iterations: 7 
## 
## Estimated contemporaneous impact matrix:
##          prod        e         U      rw
## prod  0.58402  0.07434 -0.152578 0.06900
## e    -0.12029  0.26144 -0.155096 0.08978
## U     0.02526 -0.26720  0.005488 0.04982
## rw    0.11170  0.00000  0.483771 0.48791
## 
## Estimated standard errors for impact matrix:
##         prod       e       U      rw
## prod 0.09126 0.10702 0.22242 0.07370
## e    0.06836 0.06127 0.17681 0.03814
## U    0.05484 0.04236 0.04912 0.02651
## rw   0.14754 0.00000 0.63775 0.08119
## 
## Estimated long run impact matrix:
##         prod       e       U rw
## prod  0.7910  0.0000  0.0000  0
## e     0.2024  0.5769 -0.4923  0
## U    -0.1592 -0.3409  0.1408  0
## rw   -0.1535  0.5961 -0.2495  0
## 
## Estimated standard errors for long-run matrix:
##        prod       e      U rw
## prod 0.1539 0.00000 0.0000  0
## e    0.2265 0.18255 0.5664  0
## U    0.1109 0.09259 0.1504  0
## rw   0.1908 0.16210 0.2666  0
## 
## Covariance matrix of reduced form residuals (*100):
##         prod      e       U     rw
## prod 37.4642 -2.096 -0.2512  2.509
## e    -2.0960 11.494 -6.9273 -4.467
## U    -0.2512 -6.927  7.4544  2.978
## rw    2.5087 -4.467  2.9783 48.457

SVEC - IRF

svec.irf <- irf(svec, response = "U", n.ahead = 48, boot = TRUE)
plot(svec.irf)

fevd.U <- fevd(svec, n.ahead = 48)
plot(fevd.U)

Pronostico

predictions <- predict(p1ct, n.ahead = 8, ci = 0.95)
plot(predictions)