Analisis Pertumbuhan Ekonomi Menggunakan Metode VECM

library(readxl)
## Warning: package 'readxl' was built under R version 4.3.3
library(tseries)
## Warning: package 'tseries' was built under R version 4.3.3
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(urca)
## Warning: package 'urca' was built under R version 4.3.3
library(vars)
## Warning: package 'vars' was built under R version 4.3.3
## Loading required package: MASS
## Loading required package: strucchange
## Warning: package 'strucchange' was built under R version 4.3.3
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.3.3
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## Warning: package 'sandwich' was built under R version 4.3.3
## Loading required package: lmtest
## Warning: package 'lmtest' was built under R version 4.3.3
library(tsDyn)
## Warning: package 'tsDyn' was built under R version 4.3.3

Eksplorasi DATA

data <- read_excel("C:/Users/ASUS/Downloads/Ekonomi 1.xlsx")
str(data)
## tibble [56 × 6] (S3: tbl_df/tbl/data.frame)
##  $ Quarter: chr [1:56] "2011 Q1" "2011 Q2" "20 11 Q3" "2011 Q4" ...
##  $ X1     : chr [1:56] "124.29" "124.29" "115.42" "125.36" ...
##  $ X2     : num [1:56] 5192 5776 5359 5565 6751 ...
##  $ X3     : chr [1:56] "6.65%" "5.54%" "4.61%" "3.79%" ...
##  $ X4     : num [1:56] 7.905 1.805 -14.084 0.821 4.563 ...
##  $ Y      : chr [1:56] "1,834,355.10" "1,928,233.00" "2,053,745.40" "2,015,392.50" ...
df <- data.frame(
X1 = as.numeric(data$X1),
X2 = as.numeric(data$X2),
X3 = as.numeric(gsub("%", "", data$X3))/100,
X4 = as.numeric(data$X4),
Y  = as.numeric(gsub(",", "", data$Y))
)

df_ts <- ts(df, start=c(2011,1), frequency=4)

# Tambahkan rownames dengan nama quarter

quarters <- data$Quarter
df_ts_named <- df_ts
dimnames(df_ts_named) <- list(quarters, colnames(df_ts))
df_ts_named
##             X1       X2     X3          X4       Y
## 2011 Q1 124.29  5192.46 0.0665   7.9051499 1834355
## 2011 Q2 124.29  5775.96 0.0554   1.8051534 1928233
## 2011 Q3 115.42  5358.85 0.0461 -14.0837126 2053745
## 2011 Q4 125.36  5564.79 0.0379   0.8214517 2015393
## 2012 Q1 138.74  6751.16 0.0397   4.5630174 2061338
## 2012 Q2 131.61  5776.83 0.0453  -5.3854231 2162037
## 2012 Q3 143.96  5563.10 0.0431   2.9022243 2223642
## 2012 Q4 144.99  5666.23 0.0430  -0.7723623 2168688
## 2013 Q1 162.64  8540.46 0.0590  10.9412399 2235289
## 2013 Q2 164.24  9437.78 0.0590  -4.2742751 2342590
## 2013 Q3 145.15  9350.89 0.0840  -6.3812527 2491159
## 2013 Q4 143.71  9432.19 0.0838  -5.2420615 2477098
## 2014 Q1 157.35  8918.50 0.0732   7.9099114 2506300
## 2014 Q2 159.75  9384.47 0.0670   0.7939837 2618947
## 2014 Q3 166.76  9690.21 0.0453   0.9585757 2746762
## 2014 Q4 168.64 10198.79 0.0836   2.6996493 2697695
## 2015 Q1 174.10 12035.97 0.0638   4.3345181 2728181
## 2015 Q2 157.92  9303.46 0.0726  -3.4554756 2867948
## 2015 Q3 134.39 10108.49 0.0683 -12.0482329 2990645
## 2015 Q4 145.06 11019.43 0.0335   3.0937022 2939559
## 2016 Q1 155.91  9470.14 0.0445   4.9881261 2929269
## 2016 Q2 165.94  9928.47 0.0345   3.6802120 3073537
## 2016 Q3 176.93 12087.00 0.0307   2.8529579 3205019
## 2016 Q4 172.08 14914.63 0.0302  -2.3204992 3193904
## 2017 Q1 180.49 16123.54 0.0361   5.1757617 3228172
## 2017 Q2 185.22 18914.54 0.0437   2.5400595 3366787
## 2017 Q3 184.23 21427.72 0.0372   1.0256911 3504139
## 2017 Q4 189.86 28311.77 0.0361   5.8255547 3490728
## 2018 Q1 183.59 31108.82 0.0340  -6.3073469 3510363
## 2018 Q2 173.25 32167.28 0.0312  -3.2589330 3686836
## 2018 Q3 178.09 31797.51 0.0288   0.6756575 3842343
## 2018 Q4 184.00 34491.17 0.0313   6.2220812 3799214
## 2019 Q1 190.17 37114.19 0.0248  -0.9830139 3782618
## 2019 Q2 186.01 33056.75 0.0328  -1.4982921 3964075
## 2019 Q3 188.93 55543.29 0.0339  -3.4645176 4067358
## 2019 Q4 187.73 53735.58 0.0272   1.1434865 4018606
## 2020 Q1 133.99 57420.96 0.0296 -23.5876802 3923348
## 2020 Q2 144.91 58069.05 0.0196   4.0070817 3690742
## 2020 Q3 143.81 71649.52 0.0142  -5.4293221 3897852
## 2020 Q4 177.48 74367.44 0.0168  16.5912995 3931411
## 2021 Q1 176.89 79440.23 0.0137   2.1010346 3972933
## 2021 Q2 171.95 40325.60 0.0133  -0.1689567 4178022
## 2021 Q3 181.54 41313.64 0.0160   3.5732878 4327384
## 2021 Q4 189.02 44004.18 0.0187  -0.1497417 4498413
## 2022 Q1 199.91 43233.00 0.0264   6.6397231 4508663
## 2022 Q2 200.39 40859.70 0.0435  -4.3897351 4898032
## 2022 Q3 204.10 40342.63 0.0595   1.2901518 5066968
## 2022 Q4 217.73 40605.11 0.0551  -3.4973073 5114797
## 2023 Q1 211.27 42650.15 0.0497  -0.4980013 5071497
## 2023 Q2 198.85 42947.06 0.0352  -3.6704783 5223290
## 2023 Q3 216.99 43110.74 0.0228   0.1230639 5294903
## 2023 Q4 212.64 42775.16 0.0261   7.7099202 5302658
## 2024 Q1 209.64 43719.10 0.0305   1.1219572 5288577
## 2024 Q2 209.27 44728.93 0.0251  -2.3585193 5536589
## 2024 Q3 226.63 47293.47 0.0184   3.7510888 5638869
## 2024 Q4 215.65 50547.54 0.0157  -6.5238803 5674930

Uji Akar Unit

adf_results <- lapply(df_ts_named, function(x) ur.df(x, type="trend", selectlags="AIC"))
lapply(adf_results, summary)
## $X1
## 
## ############################################### 
## # 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 
## -53.207  -2.775   1.593   6.817  16.753 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)  52.4345    15.7112   3.337  0.00160 **
## z.lag.1      -0.3814     0.1165  -3.273  0.00194 **
## tt            0.5208     0.1932   2.696  0.00953 **
## z.diff.lag    0.1007     0.1421   0.709  0.48186   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.89 on 50 degrees of freedom
## Multiple R-squared:  0.1839, Adjusted R-squared:  0.1349 
## F-statistic: 3.755 on 3 and 50 DF,  p-value: 0.01648
## 
## 
## Value of test-statistic is: -3.2725 4.0109 5.3617 
## 
## 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
## 
## 
## $X2
## 
## ############################################### 
## # 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 
## -33450  -1629   -817    924  21304 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  594.00888 1900.27262   0.313   0.7559  
## z.lag.1       -0.16812    0.08390  -2.004   0.0505 .
## tt           177.00896  107.26145   1.650   0.1052  
## z.diff.lag    -0.03152    0.14196  -0.222   0.8252  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6639 on 50 degrees of freedom
## Multiple R-squared:  0.08715,    Adjusted R-squared:  0.03238 
## F-statistic: 1.591 on 3 and 50 DF,  p-value: 0.2032
## 
## 
## Value of test-statistic is: -2.0039 1.6815 2.0099 
## 
## 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
## 
## 
## $X3
## 
## ############################################### 
## # 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.028900 -0.005763 -0.001803  0.003317  0.036680 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  0.0150524  0.0069803   2.156   0.0359 *
## z.lag.1     -0.2559776  0.1039069  -2.464   0.0172 *
## tt          -0.0001938  0.0001181  -1.640   0.1072  
## z.diff.lag  -0.0493038  0.1402509  -0.352   0.7267  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01074 on 50 degrees of freedom
## Multiple R-squared:  0.137,  Adjusted R-squared:  0.08526 
## F-statistic: 2.647 on 3 and 50 DF,  p-value: 0.05909
## 
## 
## Value of test-statistic is: -2.4635 2.1572 3.0503 
## 
## 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
## 
## 
## $X4
## 
## ############################################### 
## # 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 
## -23.7353  -3.2693   0.2378   3.7062  15.6093 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.44554    1.79125  -0.249    0.805    
## z.lag.1     -1.22639    0.21416  -5.726 5.81e-07 ***
## tt           0.01724    0.05520   0.312    0.756    
## z.diff.lag   0.05022    0.14049   0.357    0.722    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.31 on 50 degrees of freedom
## Multiple R-squared:  0.5799, Adjusted R-squared:  0.5547 
## F-statistic: 23.01 on 3 and 50 DF,  p-value: 1.692e-09
## 
## 
## Value of test-statistic is: -5.7264 10.9491 16.3973 
## 
## 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
## 
## 
## $Y
## 
## ############################################### 
## # 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 
## -323341  -71401   19207   62877  288144 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  3.372e+05  1.395e+05   2.417   0.0193 *
## z.lag.1     -1.797e-01  8.363e-02  -2.149   0.0365 *
## tt           1.273e+04  5.610e+03   2.269   0.0276 *
## z.diff.lag   1.310e-01  1.440e-01   0.910   0.3672  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 99930 on 50 degrees of freedom
## Multiple R-squared:  0.1007, Adjusted R-squared:  0.04674 
## F-statistic: 1.866 on 3 and 50 DF,  p-value: 0.1473
## 
## 
## Value of test-statistic is: -2.1488 7.1874 2.7489 
## 
## 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

Differencing L(1)

df_diff <- diff(df_ts_named)
colnames(df_diff) <- colnames(df_ts_named)
rownames(df_diff) <- rownames(df_ts_named)[-1]

adf_diff_results <- lapply(df_diff, function(x) ur.df(x, type="drift", selectlags="AIC"))
lapply(adf_diff_results, summary)
## $X1
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -55.792  -5.028   1.314   6.682  32.688 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.3099     1.8093   1.277    0.208    
## z.lag.1      -1.2393     0.2070  -5.987  2.3e-07 ***
## z.diff.lag    0.1324     0.1424   0.930    0.357    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.9 on 50 degrees of freedom
## Multiple R-squared:  0.555,  Adjusted R-squared:  0.5372 
## F-statistic: 31.18 on 2 and 50 DF,  p-value: 1.621e-09
## 
## 
## Value of test-statistic is: -5.9865 17.9218 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.51 -2.89 -2.58
## phi1  6.70  4.71  3.86
## 
## 
## $X2
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -39487   -947    -33   1890  21052 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 936.602023 961.296969   0.974    0.335    
## z.lag.1      -1.106752   0.211904  -5.223 3.43e-06 ***
## z.diff.lag   -0.009662   0.141671  -0.068    0.946    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6898 on 50 degrees of freedom
## Multiple R-squared:  0.5584, Adjusted R-squared:  0.5407 
## F-statistic: 31.61 on 2 and 50 DF,  p-value: 1.338e-09
## 
## 
## Value of test-statistic is: -5.2229 13.6439 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.51 -2.89 -2.58
## phi1  6.70  4.71  3.86
## 
## 
## $X3
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.035807 -0.006023 -0.000582  0.003830  0.035736 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -0.0006183  0.0015489  -0.399    0.691    
## z.lag.1     -1.0758172  0.2139046  -5.029 6.71e-06 ***
## z.diff.lag  -0.0991756  0.1388432  -0.714    0.478    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01122 on 50 degrees of freedom
## Multiple R-squared:  0.6032, Adjusted R-squared:  0.5873 
## F-statistic:    38 on 2 and 50 DF,  p-value: 9.209e-11
## 
## 
## Value of test-statistic is: -5.0294 12.6542 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.51 -2.89 -2.58
## phi1  6.70  4.71  3.86
## 
## 
## $X4
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -22.0692  -4.4249  -0.6795   3.0811  21.0145 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   0.1283     1.0256   0.125    0.901    
## z.lag.1      -1.8983     0.2303  -8.244    7e-11 ***
## z.diff.lag    0.2052     0.1309   1.567    0.123    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.465 on 50 degrees of freedom
## Multiple R-squared:  0.808,  Adjusted R-squared:  0.8003 
## F-statistic: 105.2 on 2 and 50 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -8.2437 34.0157 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.51 -2.89 -2.58
## phi1  6.70  4.71  3.86
## 
## 
## $Y
## 
## ############################################### 
## # Augmented Dickey-Fuller Test Unit Root Test # 
## ############################################### 
## 
## Test regression drift 
## 
## 
## Call:
## lm(formula = z.diff ~ z.lag.1 + 1 + z.diff.lag)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -326990  -60836    1837   54901  353988 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 85130.8612 18976.6868   4.486 4.27e-05 ***
## z.lag.1        -1.2407     0.1865  -6.651 2.11e-08 ***
## z.diff.lag      0.2941     0.1350   2.179   0.0341 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 100300 on 50 degrees of freedom
## Multiple R-squared:  0.5258, Adjusted R-squared:  0.5069 
## F-statistic: 27.72 on 2 and 50 DF,  p-value: 7.912e-09
## 
## 
## Value of test-statistic is: -6.6511 22.1259 
## 
## Critical values for test statistics: 
##       1pct  5pct 10pct
## tau2 -3.51 -2.89 -2.58
## phi1  6.70  4.71  3.86

Penentuan Panjang lag optimal

df_diff_scaled <- scale(df_diff)
lag <- VARselect(df_diff_scaled, lag.max = 8, type = "const")
p_lag <- as.numeric(lag$selection["AIC(n)"])
lag$selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      8      8      8      8

Uji Kointegrasi

df_level_var <- as.data.frame(df_ts_named)
colnames(df_level_var) <- c("SS", "RD", "Inflasi", "IHSGr", "PDB")
cat("Variables:", colnames(df_level_var), "\n")
## Variables: SS RD Inflasi IHSGr PDB
str(df_level_var)
## 'data.frame':    56 obs. of  5 variables:
##  $ SS     : num  124 124 115 125 139 ...
##  $ RD     : num  5192 5776 5359 5565 6751 ...
##  $ Inflasi: num  0.0665 0.0554 0.0461 0.0379 0.0397 0.0453 0.0431 0.043 0.059 0.059 ...
##  $ IHSGr  : num  7.905 1.805 -14.084 0.821 4.563 ...
##  $ PDB    : num  1834355 1928233 2053745 2015393 2061338 ...
df_scaled <- scale(df_level_var)
johansen_test <- ca.jo(df_scaled, type="trace", ecdet="const", K = 2)
summary(johansen_test)
## 
## ###################### 
## # Johansen-Procedure # 
## ###################### 
## 
## Test type: trace statistic , without linear trend and constant in cointegration 
## 
## Eigenvalues (lambda):
## [1] 6.272718e-01 3.987427e-01 3.416712e-01 1.917654e-01 6.757313e-02
## [6] 2.563575e-17
## 
## Values of teststatistic and critical values of test:
## 
##            test 10pct  5pct  1pct
## r <= 4 |   3.78  7.52  9.24 12.97
## r <= 3 |  15.27 17.85 19.96 24.60
## r <= 2 |  37.85 32.00 34.91 41.07
## r <= 1 |  65.32 49.65 53.12 60.16
## r = 0  | 118.61 71.86 76.07 84.45
## 
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
## 
##                  SS.l2       RD.l2 Inflasi.l2   IHSGr.l2    PDB.l2   constant
## SS.l2       1.00000000  1.00000000  1.0000000  1.0000000   1.00000  1.0000000
## RD.l2       0.19786327  0.47777367  0.2394901 -1.4770842  90.52194  1.5071532
## Inflasi.l2 -0.11780270  0.11725562 -0.2959037 -1.7877029 -32.40224  1.0153027
## IHSGr.l2   -1.89164145 -0.08726961 -0.1484687 -0.1915079 -16.73856 -0.7157287
## PDB.l2     -0.98401311 -1.10488887 -1.3408885 -0.7881501 -88.35949 -5.2911294
## constant   -0.08361057  0.17005768 -0.7405340  0.6246780   3.60423  0.1690477
## 
## Weights W:
## (This is the loading matrix)
## 
##                  SS.l2       RD.l2  Inflasi.l2     IHSGr.l2        PDB.l2
## SS.d       0.002311096 -0.63288512 -0.11498314  0.019391242  4.890111e-04
## RD.d       0.130875418 -0.07817508 -0.01610687  0.058073134 -7.292602e-04
## Inflasi.d  0.056264902  0.16638160  0.29190578  0.112594453  9.458949e-04
## IHSGr.d    0.734826548 -1.32802820 -0.19743527 -0.006951971  1.554248e-03
## PDB.d     -0.033697868  0.06501222 -0.06170546  0.012700568  9.377307e-05
##                constant
## SS.d       4.137705e-17
## RD.d      -1.414658e-17
## Inflasi.d -4.658815e-17
## IHSGr.d    1.965326e-17
## PDB.d     -4.259199e-18

Estimasi VECM

vecm_model <- cajorls(johansen_test, r = 1)
summary(vecm_model$rlm)
## Response SS.d :
## 
## Call:
## lm(formula = SS.d ~ ect1 + SS.dl1 + RD.dl1 + Inflasi.dl1 + IHSGr.dl1 + 
##     PDB.dl1 - 1, data = data.mat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.90887 -0.21828  0.03225  0.26994  0.97000 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)  
## ect1         0.0023111  0.0837606   0.028   0.9781  
## SS.dl1      -0.1931799  0.3042747  -0.635   0.5285  
## RD.dl1       0.0931194  0.1971841   0.472   0.6389  
## Inflasi.dl1 -0.0008441  0.1092996  -0.008   0.9939  
## IHSGr.dl1    0.0471118  0.1301991   0.362   0.7191  
## PDB.dl1      1.3055252  0.6430401   2.030   0.0479 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4642 on 48 degrees of freedom
## Multiple R-squared:  0.08768,    Adjusted R-squared:  -0.02635 
## F-statistic: 0.7689 on 6 and 48 DF,  p-value: 0.5981
## 
## 
## Response RD.d :
## 
## Call:
## lm(formula = RD.d ~ ect1 + SS.dl1 + RD.dl1 + Inflasi.dl1 + IHSGr.dl1 + 
##     PDB.dl1 - 1, data = data.mat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.40638 -0.06926  0.03015  0.15054  0.86044 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## ect1         0.13088    0.05345   2.448   0.0181 *
## SS.dl1       0.12543    0.19417   0.646   0.5214  
## RD.dl1      -0.06727    0.12583  -0.535   0.5954  
## Inflasi.dl1  0.05583    0.06975   0.800   0.4274  
## IHSGr.dl1   -0.04514    0.08309  -0.543   0.5894  
## PDB.dl1      0.61091    0.41036   1.489   0.1431  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2962 on 48 degrees of freedom
## Multiple R-squared:  0.2818, Adjusted R-squared:  0.1921 
## F-statistic:  3.14 on 6 and 48 DF,  p-value: 0.01119
## 
## 
## Response Inflasi.d :
## 
## Call:
## lm(formula = Inflasi.d ~ ect1 + SS.dl1 + RD.dl1 + Inflasi.dl1 + 
##     IHSGr.dl1 + PDB.dl1 - 1, data = data.mat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.50513 -0.38820 -0.08304  0.17085  1.74218 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## ect1         0.05626    0.10411   0.540    0.591  
## SS.dl1       0.70621    0.37819   1.867    0.068 .
## RD.dl1      -0.25963    0.24508  -1.059    0.295  
## Inflasi.dl1 -0.13128    0.13585  -0.966    0.339  
## IHSGr.dl1   -0.17324    0.16183  -1.071    0.290  
## PDB.dl1     -0.28223    0.79924  -0.353    0.726  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5769 on 48 degrees of freedom
## Multiple R-squared:   0.14,  Adjusted R-squared:  0.03252 
## F-statistic: 1.302 on 6 and 48 DF,  p-value: 0.2743
## 
## 
## Response IHSGr.d :
## 
## Call:
## lm(formula = IHSGr.d ~ ect1 + SS.dl1 + RD.dl1 + Inflasi.dl1 + 
##     IHSGr.dl1 + PDB.dl1 - 1, data = data.mat)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.1122 -0.6259 -0.0434  0.6363  2.7712 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## ect1          0.7348     0.2001   3.672 0.000604 ***
## SS.dl1        0.7861     0.7270   1.081 0.284951    
## RD.dl1        0.1890     0.4711   0.401 0.690010    
## Inflasi.dl1  -0.2004     0.2611  -0.767 0.446681    
## IHSGr.dl1    -1.2937     0.3111  -4.159 0.000131 ***
## PDB.dl1       0.4072     1.5363   0.265 0.792087    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.109 on 48 degrees of freedom
## Multiple R-squared:  0.5202, Adjusted R-squared:  0.4602 
## F-statistic: 8.673 on 6 and 48 DF,  p-value: 2.1e-06
## 
## 
## Response PDB.d :
## 
## Call:
## lm(formula = PDB.d ~ ect1 + SS.dl1 + RD.dl1 + Inflasi.dl1 + IHSGr.dl1 + 
##     PDB.dl1 - 1, data = data.mat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.08402 -0.01450  0.02848  0.07102  0.30392 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)  
## ect1        -0.033698   0.018030  -1.869   0.0677 .
## SS.dl1      -0.007775   0.065497  -0.119   0.9060  
## RD.dl1      -0.023928   0.042445  -0.564   0.5756  
## Inflasi.dl1  0.006613   0.023527   0.281   0.7799  
## IHSGr.dl1    0.042145   0.028026   1.504   0.1392  
## PDB.dl1      0.352664   0.138419   2.548   0.0141 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.09992 on 48 degrees of freedom
## Multiple R-squared:  0.2783, Adjusted R-squared:  0.1881 
## F-statistic: 3.085 on 6 and 48 DF,  p-value: 0.01233

Var dari VECM untuk IRF & IDF

var_from_vecm <- vec2var(johansen_test, r = 1)
variables <- colnames(var_from_vecm$y)
cat("Variables in model:", variables, "\n")
## Variables in model: SS RD Inflasi IHSGr PDB

Uji Stabilitas

# Cek stabilitas
p_lag_level <- p_lag - 1
var_model <- VAR(df_level_var, p = p_lag_level, type = "const")

# Check stability
cat("Model Roots:\n")
## Model Roots:
print(roots(var_model))
##  [1] 1.0043572 0.9918262 0.9918262 0.9746900 0.9746900 0.9616932 0.9616932
##  [8] 0.9610912 0.9610912 0.9592556 0.9592556 0.9588253 0.9588253 0.9575513
## [15] 0.9575513 0.9557252 0.9557252 0.9458494 0.9458494 0.9288141 0.9288141
## [22] 0.9031963 0.8976925 0.8976925 0.8835030 0.8835030 0.8805860 0.8805860
## [29] 0.8770121 0.8648712 0.8648712 0.6301003 0.5975605 0.5975605 0.4919370
cat("\nAll roots < 1?", all(roots(var_model) < 1), "\n")
## 
## All roots < 1? FALSE

Uji Kausalitas

granger_results <- lapply(colnames(df_level_var), function(v) {
causality(var_model, cause = v)$Granger
})
names(granger_results) <- colnames(df_level_var)
granger_results
## $SS
## 
##  Granger causality H0: SS do not Granger-cause RD Inflasi IHSGr PDB
## 
## data:  VAR object var_model
## F-Test = 1.2241, df1 = 28, df2 = 65, p-value = 0.2484
## 
## 
## $RD
## 
##  Granger causality H0: RD do not Granger-cause SS Inflasi IHSGr PDB
## 
## data:  VAR object var_model
## F-Test = 2.9261, df1 = 28, df2 = 65, p-value = 0.0001901
## 
## 
## $Inflasi
## 
##  Granger causality H0: Inflasi do not Granger-cause SS RD IHSGr PDB
## 
## data:  VAR object var_model
## F-Test = 2.1928, df1 = 28, df2 = 65, p-value = 0.00484
## 
## 
## $IHSGr
## 
##  Granger causality H0: IHSGr do not Granger-cause SS RD Inflasi PDB
## 
## data:  VAR object var_model
## F-Test = 1.1373, df1 = 28, df2 = 65, p-value = 0.3278
## 
## 
## $PDB
## 
##  Granger causality H0: PDB do not Granger-cause SS RD Inflasi IHSGr
## 
## data:  VAR object var_model
## F-Test = 1.8467, df1 = 28, df2 = 65, p-value = 0.02187

IMPULSE RESPONSE FUNCTION (IRF)

irf_result <- irf(var_from_vecm, 
                  impulse = variables,
                  response = variables,
                  n.ahead = 10,
                  boot = TRUE,
                  ci = 0.95)
plot(irf_result)

# Forcast Eror Variance Decomposition (FEVD)

fevd_result <- fevd(var_model, n.ahead = 10)
plot(fevd_result)

print(fevd_result)
## $SS
##              SS        RD      Inflasi      IHSGr       PDB
##  [1,] 1.0000000 0.0000000 0.000000e+00 0.00000000 0.0000000
##  [2,] 0.7281873 0.0289293 3.775027e-05 0.07817614 0.1646696
##  [3,] 0.5664762 0.1983509 1.217145e-03 0.07706022 0.1568955
##  [4,] 0.5019173 0.2490619 4.068439e-02 0.06871174 0.1396248
##  [5,] 0.4726017 0.2775177 3.995165e-02 0.07805908 0.1318699
##  [6,] 0.4692073 0.2736820 3.970868e-02 0.07752598 0.1398760
##  [7,] 0.4645187 0.2701913 4.228852e-02 0.07997328 0.1430282
##  [8,] 0.4408226 0.2783522 5.621764e-02 0.07727585 0.1473317
##  [9,] 0.4370682 0.2766407 5.738076e-02 0.08372912 0.1451812
## [10,] 0.4183811 0.2836891 5.524071e-02 0.08923495 0.1534541
## 
## $RD
##               SS        RD    Inflasi        IHSGr         PDB
##  [1,] 0.04122455 0.9587754 0.00000000 0.0000000000 0.000000000
##  [2,] 0.07088983 0.8854233 0.03411995 0.0002910951 0.009275824
##  [3,] 0.19131300 0.7563915 0.02358425 0.0205411327 0.008170079
##  [4,] 0.22076291 0.6998317 0.01867628 0.0220728123 0.038656275
##  [5,] 0.25357107 0.6322477 0.05208235 0.0264472291 0.035651657
##  [6,] 0.25240161 0.5722023 0.09809642 0.0254687898 0.051830913
##  [7,] 0.23652055 0.5486132 0.11954350 0.0233689865 0.071953805
##  [8,] 0.24260749 0.5141950 0.12895891 0.0393513330 0.074887268
##  [9,] 0.22638332 0.4466874 0.18219145 0.0472396857 0.097498177
## [10,] 0.22412951 0.3736586 0.19651266 0.0730491993 0.132649981
## 
## $Inflasi
##               SS         RD   Inflasi      IHSGr         PDB
##  [1,] 0.03478859 0.01381851 0.9513929 0.00000000 0.000000000
##  [2,] 0.02662640 0.02602875 0.8557683 0.08675067 0.004825843
##  [3,] 0.10521774 0.02532673 0.7738347 0.08374458 0.011876291
##  [4,] 0.13161678 0.07250585 0.7088789 0.07416453 0.012833923
##  [5,] 0.12707545 0.27034335 0.5262784 0.05904592 0.017256872
##  [6,] 0.13406094 0.34094918 0.4587140 0.05140591 0.014869971
##  [7,] 0.12247079 0.36420962 0.4220725 0.07465556 0.016591550
##  [8,] 0.12229073 0.36495542 0.4193281 0.07397661 0.019449121
##  [9,] 0.16246275 0.33473818 0.3922929 0.07577431 0.034731886
## [10,] 0.17080954 0.30077184 0.3710133 0.08119550 0.076209808
## 
## $IHSGr
##              SS          RD     Inflasi      IHSGr       PDB
##  [1,] 0.9137473 0.002712839 0.003916223 0.07962362 0.0000000
##  [2,] 0.7112095 0.019619179 0.006145066 0.08286264 0.1801636
##  [3,] 0.6347732 0.118768909 0.006169241 0.07416367 0.1661250
##  [4,] 0.6069815 0.137891082 0.063048782 0.06353695 0.1285417
##  [5,] 0.5851700 0.130396450 0.092783471 0.06375096 0.1278992
##  [6,] 0.5464605 0.178116891 0.088166012 0.06220221 0.1250544
##  [7,] 0.5401426 0.172128354 0.105065017 0.05966817 0.1229959
##  [8,] 0.5160909 0.170236127 0.102796466 0.07400149 0.1368750
##  [9,] 0.4988781 0.166277605 0.110583675 0.08154810 0.1427125
## [10,] 0.4848540 0.185832017 0.106779493 0.08089597 0.1416385
## 
## $PDB
##               SS        RD     Inflasi        IHSGr       PDB
##  [1,] 0.07207455 0.3485492 0.015653326 9.953849e-06 0.5637130
##  [2,] 0.43110634 0.2923672 0.006186715 5.230683e-03 0.2651091
##  [3,] 0.50357180 0.2424045 0.006088616 4.400393e-02 0.2039312
##  [4,] 0.48049553 0.2702484 0.004512831 6.924681e-02 0.1754964
##  [5,] 0.42577365 0.3192087 0.012362000 6.543285e-02 0.1772228
##  [6,] 0.41618436 0.3328644 0.016896287 7.546978e-02 0.1585852
##  [7,] 0.44476669 0.3123080 0.015658512 8.148412e-02 0.1457827
##  [8,] 0.43911751 0.3022100 0.016710765 9.479208e-02 0.1471696
##  [9,] 0.43433878 0.2959900 0.021145242 9.589008e-02 0.1526359
## [10,] 0.43273521 0.2917161 0.024252372 9.664125e-02 0.1546551

ECM Analysis

cat("Long-run equilibrium relationships (Cointegrating vectors):\n")
## Long-run equilibrium relationships (Cointegrating vectors):
print(vecm_model$rlm)
## 
## Call:
## lm(formula = substitute(form1), data = data.mat)
## 
## Coefficients:
##              SS.d        RD.d        Inflasi.d   IHSGr.d     PDB.d     
## ect1          0.0023111   0.1308754   0.0562649   0.7348265  -0.0336979
## SS.dl1       -0.1931799   0.1254267   0.7062060   0.7860843  -0.0077749
## RD.dl1        0.0931194  -0.0672729  -0.2596284   0.1890338  -0.0239277
## Inflasi.dl1  -0.0008441   0.0558348  -0.1312762  -0.2003584   0.0066129
## IHSGr.dl1     0.0471118  -0.0451419  -0.1732431  -1.2936517   0.0421446
## PDB.dl1       1.3055252   0.6109090  -0.2822330   0.4072394   0.3526638
# Extract error correction term
ec_term <- vecm_model$rlm$residuals
cat("\nError correction residuals:\n")
## 
## Error correction residuals:
head(ec_term)
##                 SS.d         RD.d    Inflasi.d     IHSGr.d        PDB.d
## 2011 Q1  -0.37865983  0.312081504 -0.535616077 -1.77513190  0.027892941
## 2011 Q2   0.27193465  0.043144161 -0.622532626  0.05287344 -0.005544014
## 20 11 Q3  0.47191832 -0.264881208  0.009175851  0.92601146  0.069708752
## 2011 Q4  -0.24904992 -0.003456839  0.144084958 -0.62562092  0.028597598
## 2012 Q1   0.35855743  0.069705675 -0.076753493  0.59222442  0.035646285
## 2012 Q2  -0.01474392 -0.168646735 -0.153590576 -0.10019918 -0.082839750

Forcasting

forecast_result <- predict(var_from_vecm, n.ahead = 8, ci = 0.95)

# Plot forecast
plot(forecast_result)

# Extract forecast values
cat("\nForecast values (8 quarters ahead):\n")
## 
## Forecast values (8 quarters ahead):
print(forecast_result$fcst)
## $SS
##          fcst      lower    upper        CI
## [1,] 1.605694  0.7479494 2.463439 0.8577446
## [2,] 1.611751  0.4336166 2.789886 1.1781347
## [3,] 1.586620  0.1371140 3.036127 1.4495065
## [4,] 1.575733 -0.1251618 3.276628 1.7008948
## [5,] 1.575254 -0.3553441 3.505852 1.9305980
## [6,] 1.573707 -0.5637094 3.711122 2.1374159
## [7,] 1.573379 -0.7538937 3.900652 2.3272729
## [8,] 1.573031 -0.9301532 4.076216 2.5031844
## 
## $RD
##          fcst      lower    upper        CI
## [1,] 1.010021  0.4626479 1.557394 0.5473729
## [2,] 1.198063  0.4363986 1.959727 0.7616644
## [3,] 1.119401  0.1308119 2.107990 0.9885888
## [4,] 1.124661 -0.0168723 2.266194 1.1415329
## [5,] 1.123182 -0.1529811 2.399344 1.2761628
## [6,] 1.122848 -0.2760455 2.521741 1.3988931
## [7,] 1.123058 -0.3881106 2.634226 1.5111683
## [8,] 1.122517 -0.4933669 2.738400 1.6158837
## 
## $Inflasi
##           fcst     lower       upper       CI
## [1,] -1.360096 -2.426200 -0.29399141 1.066104
## [2,] -1.406947 -2.832335  0.01844013 1.425387
## [3,] -1.422497 -3.151050  0.30605525 1.728552
## [4,] -1.414617 -3.398196  0.56896172 1.983579
## [5,] -1.422962 -3.632680  0.78675654 2.209718
## [6,] -1.421232 -3.837504  0.99504099 2.416273
## [7,] -1.422686 -4.028842  1.18346908 2.606156
## [8,] -1.422406 -4.205838  1.36102592 2.783432
## 
## $IHSGr
##            fcst     lower    upper       CI
## [1,] 0.27439821 -1.774880 2.323677 2.049278
## [2,] 0.02429745 -2.072218 2.120813 2.096516
## [3,] 0.04022440 -2.085499 2.165947 2.125723
## [4,] 0.03617014 -2.128068 2.200409 2.164238
## [5,] 0.03681954 -2.160124 2.233763 2.196943
## [6,] 0.04127901 -2.189411 2.271969 2.230690
## [7,] 0.03851103 -2.223840 2.300862 2.262351
## [8,] 0.03987593 -2.254377 2.334129 2.294253
## 
## $PDB
##          fcst    lower    upper        CI
## [1,] 1.867036 1.682400 2.051671 0.1846354
## [2,] 1.845104 1.533872 2.156336 0.3112317
## [3,] 1.837949 1.414088 2.261810 0.4238611
## [4,] 1.835734 1.313495 2.357973 0.5222390
## [5,] 1.834543 1.226102 2.442984 0.6084411
## [6,] 1.833916 1.148585 2.519246 0.6853308
## [7,] 1.833690 1.078664 2.588716 0.7550260
## [8,] 1.833582 1.014533 2.652632 0.8190496

Forecast Eror Matrix

for(var in names(forecast_result$fcst)){
  cat("\n--- Forecast for", var, "---\n")
  print(forecast_result$fcst[[var]])
}
## 
## --- Forecast for SS ---
##          fcst      lower    upper        CI
## [1,] 1.605694  0.7479494 2.463439 0.8577446
## [2,] 1.611751  0.4336166 2.789886 1.1781347
## [3,] 1.586620  0.1371140 3.036127 1.4495065
## [4,] 1.575733 -0.1251618 3.276628 1.7008948
## [5,] 1.575254 -0.3553441 3.505852 1.9305980
## [6,] 1.573707 -0.5637094 3.711122 2.1374159
## [7,] 1.573379 -0.7538937 3.900652 2.3272729
## [8,] 1.573031 -0.9301532 4.076216 2.5031844
## 
## --- Forecast for RD ---
##          fcst      lower    upper        CI
## [1,] 1.010021  0.4626479 1.557394 0.5473729
## [2,] 1.198063  0.4363986 1.959727 0.7616644
## [3,] 1.119401  0.1308119 2.107990 0.9885888
## [4,] 1.124661 -0.0168723 2.266194 1.1415329
## [5,] 1.123182 -0.1529811 2.399344 1.2761628
## [6,] 1.122848 -0.2760455 2.521741 1.3988931
## [7,] 1.123058 -0.3881106 2.634226 1.5111683
## [8,] 1.122517 -0.4933669 2.738400 1.6158837
## 
## --- Forecast for Inflasi ---
##           fcst     lower       upper       CI
## [1,] -1.360096 -2.426200 -0.29399141 1.066104
## [2,] -1.406947 -2.832335  0.01844013 1.425387
## [3,] -1.422497 -3.151050  0.30605525 1.728552
## [4,] -1.414617 -3.398196  0.56896172 1.983579
## [5,] -1.422962 -3.632680  0.78675654 2.209718
## [6,] -1.421232 -3.837504  0.99504099 2.416273
## [7,] -1.422686 -4.028842  1.18346908 2.606156
## [8,] -1.422406 -4.205838  1.36102592 2.783432
## 
## --- Forecast for IHSGr ---
##            fcst     lower    upper       CI
## [1,] 0.27439821 -1.774880 2.323677 2.049278
## [2,] 0.02429745 -2.072218 2.120813 2.096516
## [3,] 0.04022440 -2.085499 2.165947 2.125723
## [4,] 0.03617014 -2.128068 2.200409 2.164238
## [5,] 0.03681954 -2.160124 2.233763 2.196943
## [6,] 0.04127901 -2.189411 2.271969 2.230690
## [7,] 0.03851103 -2.223840 2.300862 2.262351
## [8,] 0.03987593 -2.254377 2.334129 2.294253
## 
## --- Forecast for PDB ---
##          fcst    lower    upper        CI
## [1,] 1.867036 1.682400 2.051671 0.1846354
## [2,] 1.845104 1.533872 2.156336 0.3112317
## [3,] 1.837949 1.414088 2.261810 0.4238611
## [4,] 1.835734 1.313495 2.357973 0.5222390
## [5,] 1.834543 1.226102 2.442984 0.6084411
## [6,] 1.833916 1.148585 2.519246 0.6853308
## [7,] 1.833690 1.078664 2.588716 0.7550260
## [8,] 1.833582 1.014533 2.652632 0.8190496