# ============================================================
# ANALISIS VAR: INFLASI, BI RATE, KURS
# ============================================================

# 1. PANGGIL LIBRARY
library(readxl)
## Warning: package 'readxl' was built under R version 4.5.3
library(vars)
## Warning: package 'vars' was built under R version 4.5.3
## Loading required package: MASS
## Warning: package 'MASS' was built under R version 4.5.3
## Loading required package: strucchange
## Warning: package 'strucchange' was built under R version 4.5.3
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.5.2
## 
## 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.5.3
## Loading required package: urca
## Warning: package 'urca' was built under R version 4.5.3
## Loading required package: lmtest
## Warning: package 'lmtest' was built under R version 4.5.3
library(urca)
library(forecast)
## Warning: package 'forecast' was built under R version 4.5.3
# 2. BACA DATA
file <- "C:/ARW/UAS_ARW/Data_Inflasi_Suku Bunga_Kurs Rupiah_Soal Nomor 2.xlsx"

inflasi   <- read_excel(file, sheet = "Inflasi")
sukubunga <- read_excel(file, sheet = "Suku Bunga")
kurs      <- read_excel(file, sheet = "Nilai Tukar Rupiah")
head(data)
##                                                                             
## 1 function (..., list = character(), package = NULL, lib.loc = NULL,        
## 2     verbose = getOption("verbose"), envir = .GlobalEnv, overwrite = TRUE) 
## 3 {                                                                         
## 4     fileExt <- function(x) {                                              
## 5         db <- grepl("\\\\.[^.]+\\\\.(gz|bz2|xz)$", x)                     
## 6         ans <- sub(".*\\\\.", "", x)
# 3. BERSIHKAN DATA
# Ubah koma jadi titik, lalu jadikan angka
inflasi$Inflasi     <- as.numeric(gsub(",", ".", inflasi$Inflasi))
sukubunga$`BI- Rate` <- as.numeric(gsub(",", ".", sukubunga$`BI- Rate`))
kurs$USD            <- as.numeric(gsub(",", ".", kurs$USD))

# 4. GABUNGKAN JADI SATU DATA
data <- data.frame(
  inflasi = inflasi$Inflasi,
  birate  = sukubunga$`BI- Rate`,
  kurs    = kurs$USD
)

head(data)
##   inflasi birate kurs
## 1    0.89   6.50 9057
## 2    0.13   6.75 8823
## 3   -0.32   6.75 8709
## 4   -0.31   6.75 8574
## 5    0.12   6.75 8537
## 6    0.55   6.75 8597
summary(data)
##     inflasi            birate           kurs      
##  Min.   :-0.7600   Min.   :3.500   Min.   : 8508  
##  1st Qu.: 0.0700   1st Qu.:4.750   1st Qu.:12386  
##  Median : 0.2100   Median :5.750   Median :14078  
##  Mean   : 0.3068   Mean   :5.592   Mean   :13554  
##  3rd Qu.: 0.5125   3rd Qu.:6.312   3rd Qu.:15035  
##  Max.   : 3.2900   Max.   :7.750   Max.   :18078
# 5. JADIKAN TIME SERIES (BULANAN, MULAI JAN 2011)
ts_data <- ts(data, start = c(2011, 1), frequency = 12)
ts_data
##          inflasi birate  kurs
## Jan 2011    0.89   6.50  9057
## Feb 2011    0.13   6.75  8823
## Mar 2011   -0.32   6.75  8709
## Apr 2011   -0.31   6.75  8574
## May 2011    0.12   6.75  8537
## Jun 2011    0.55   6.75  8597
## Jul 2011    0.67   6.75  8508
## Aug 2011    0.93   6.75  8578
## Sep 2011    0.27   6.75  8823
## Oct 2011   -0.12   6.50  8835
## Nov 2011    0.34   6.00  9170
## Dec 2011    0.57   6.00  9068
## Jan 2012    0.76   6.00  9000
## Feb 2012    0.05   5.75  9085
## Mar 2012    0.07   5.75  9180
## Apr 2012    0.21   5.75  9190
## May 2012    0.07   5.75  9565
## Jun 2012    0.62   5.75  9480
## Jul 2012    0.70   5.75  9485
## Aug 2012    0.95   5.75  9560
## Sep 2012    0.01   5.75  9588
## Oct 2012    0.16   5.75  9615
## Nov 2012    0.07   5.75  9605
## Dec 2012    0.54   5.75  9670
## Jan 2013    1.03   5.75  9698
## Feb 2013    0.75   5.75  9667
## Mar 2013    0.63   5.75  9719
## Apr 2013   -0.10   5.75  9722
## May 2013   -0.03   5.75  9802
## Jun 2013    1.03   6.00  9929
## Jul 2013    3.29   6.50 10278
## Aug 2013    1.12   7.00 10924
## Sep 2013   -0.35   7.25 11613
## Oct 2013    0.09   7.25 11234
## Nov 2013    0.12   7.50 11977
## Dec 2013    0.55   7.50 12189
## Jan 2014    1.07   7.50 12226
## Feb 2014    0.26   7.50 11634
## Mar 2014    0.08   7.50 11404
## Apr 2014   -0.02   7.50 11532
## May 2014    0.16   7.50 11611
## Jun 2014    0.43   7.50 11969
## Jul 2014    0.93   7.50 11591
## Aug 2014    0.47   7.50 11717
## Sep 2014    0.27   7.50 12212
## Oct 2014    0.47   7.50 12082
## Nov 2014    1.50   7.75 12196
## Dec 2014    2.46   7.75 12440
## Jan 2015   -0.24   7.75 12625
## Feb 2015   -0.36   7.50 12863
## Mar 2015    0.17   7.50 13084
## Apr 2015    0.36   7.50 12937
## May 2015    0.50   7.50 13211
## Jun 2015    0.54   7.50 13332
## Jul 2015    0.93   7.50 13481
## Aug 2015    0.39   7.50 14027
## Sep 2015   -0.05   7.50 14657
## Oct 2015   -0.08   7.50 13639
## Nov 2015    0.21   7.50 13840
## Dec 2015    0.96   7.50 13795
## Jan 2016    0.51   7.25 13846
## Feb 2016   -0.09   7.00 13395
## Mar 2016    0.19   6.75 13276
## Apr 2016   -0.45   6.75 13204
## May 2016    0.24   6.75 13615
## Jun 2016    0.66   6.50 13180
## Jul 2016    0.69   6.50 13094
## Aug 2016   -0.02   5.25 13300
## Sep 2016    0.22   5.00 12998
## Oct 2016    0.14   4.75 13051
## Nov 2016    0.47   4.75 13563
## Dec 2016    0.42   4.75 13436
## Jan 2017    0.97   4.75 13343
## Feb 2017    0.23   4.75 13347
## Mar 2017   -0.02   4.75 13321
## Apr 2017    0.09   4.75 13327
## May 2017    0.39   4.75 13321
## Jun 2017    0.69   4.75 13319
## Jul 2017    0.22   4.75 13323
## Aug 2017   -0.07   4.50 13351
## Sep 2017    0.13   4.25 13492
## Oct 2017    0.01   4.25 13572
## Nov 2017    0.20   4.25 13514
## Dec 2017    0.71   4.25 13548
## Jan 2018    0.62   4.25 13413
## Feb 2018    0.17   4.25 13707
## Mar 2018    0.20   4.25 13756
## Apr 2018    0.10   4.25 13877
## May 2018    0.21   4.75 13951
## Jun 2018    0.59   5.25 14404
## Jul 2018    0.28   5.25 14413
## Aug 2018   -0.05   5.50 14711
## Sep 2018   -0.18   5.75 14929
## Oct 2018    0.28   5.75 15227
## Nov 2018    0.27   6.00 14339
## Dec 2018    0.62   6.00 14481
## Jan 2019    0.32   6.00 14072
## Feb 2019   -0.08   6.00 14062
## Mar 2019    0.11   6.00 14244
## Apr 2019    0.44   6.00 14215
## May 2019    0.68   6.00 14385
## Jun 2019    0.55   6.00 14141
## Jul 2019    0.31   5.75 14026
## Aug 2019    0.12   5.50 14237
## Sep 2019   -0.27   5.25 14174
## Oct 2019    0.02   5.00 14008
## Nov 2019    0.14   5.00 14102
## Dec 2019    0.34   5.00 13901
## Jan 2020    0.39   5.00 13662
## Feb 2020    0.28   4.75 14234
## Mar 2020    0.10   4.50 16367
## Apr 2020    0.08   4.50 15157
## May 2020    0.07   4.50 14733
## Jun 2020    0.18   4.25 14302
## Jul 2020   -0.10   4.00 14653
## Aug 2020   -0.05   4.00 14554
## Sep 2020   -0.05   4.00 14918
## Oct 2020    0.07   4.00 14690
## Nov 2020    0.28   3.75 14128
## Dec 2020    0.45   3.75 14105
## Jan 2021    0.26   3.75 14084
## Feb 2021    0.10   3.50 14229
## Mar 2021    0.08   3.50 14572
## Apr 2021    0.13   3.50 14468
## May 2021    0.32   3.50 14310
## Jun 2021   -0.16   3.50 14496
## Jul 2021    0.08   3.50 14491
## Aug 2021    0.03   3.50 14374
## Sep 2021   -0.04   3.50 14307
## Oct 2021    0.12   3.50 14199
## Nov 2021    0.37   3.50 14340
## Dec 2021    0.57   3.50 14269
## Jan 2022    0.56   3.50 14381
## Feb 2022   -0.02   3.50 14371
## Mar 2022    0.66   3.50 14349
## Apr 2022    0.95   3.50 14418
## May 2022    0.40   3.50 14544
## Jun 2022    0.61   3.50 14848
## Jul 2022    0.64   3.50 14958
## Aug 2022   -0.21   3.75 14875
## Sep 2022    1.17   4.25 15247
## Oct 2022   -0.11   4.75 15542
## Nov 2022    0.09   5.25 15737
## Dec 2022    0.66   5.50 15731
## Jan 2023    0.34   5.75 14979
## Feb 2023    0.16   5.75 15274
## Mar 2023    0.18   5.75 15062
## Apr 2023    0.33   5.75 14751
## May 2023    0.09   5.75 14969
## Jun 2023    0.14   5.75 15026
## Jul 2023    0.21   5.75 15083
## Aug 2023   -0.02   5.75 15239
## Sep 2023    0.19   5.75 15526
## Oct 2023    0.17   6.00 15916
## Nov 2023    0.38   6.00 15384
## Dec 2023    0.41   6.00 15416
## Jan 2024    0.04   6.00 15796
## Feb 2024    0.37   6.00 15673
## Mar 2024    0.52   6.00 15853
## Apr 2024    0.25   6.25 16249
## May 2024   -0.03   6.25 16253
## Jun 2024   -0.08   6.25 16421
## Jul 2024   -0.18   6.25 16320
## Aug 2024   -0.03   6.25 15409
## Sep 2024   -0.12   6.00 15138
## Oct 2024    0.08   6.00 15732
## Nov 2024    0.30   6.00 15864
## Dec 2024    0.44   6.00 16162
## Jan 2025   -0.76   5.75 16259
## Feb 2025   -0.48   5.75 16431
## Mar 2025    1.65   5.75 16588
## Apr 2025    1.17   5.75 16787
## May 2025   -0.37   5.50 16255
## Jun 2025    0.19   5.50 16233
## Jul 2025    0.30   5.25 16387
## Aug 2025   -0.08   5.00 16356
## Sep 2025    0.21   4.75 16680
## Oct 2025    0.28   4.75 16640
## Nov 2025    0.17   4.75 16644
## Dec 2025    0.64   4.75 16782
## Jan 2026   -0.15   4.75 16786
## Feb 2026    0.68   4.75 16758
## Mar 2026    0.41   4.75 16993
## Apr 2026    0.13   4.75 17324
## May 2026    0.28   5.25 17789
## Jun 2026    0.44   5.75 17856
## Jul 2026   -0.14   5.75 18078
## Aug 2026    0.21   5.75 17703
# 6. PLOT DATA
par(mfrow = c(1, 1))
plot(ts_data[, "inflasi"], main = "Inflasi", ylab = "Inflasi")

plot(ts_data[, "birate"],  main = "BI Rate", ylab = "BI Rate")

plot(ts_data[, "kurs"],    main = "Kurs", ylab = "Kurs")

par(mfrow = c(1, 1))

# 7. UJI STASIONER (ADF) PADA LEVEL
summary(ur.df(ts_data[, "inflasi"], type = "trend", lags = 12, selectlags = "AIC"))
## 
## ############################################### 
## # 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.94814 -0.20190 -0.04501  0.14203  2.43355 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.4215019  0.1142385   3.690 0.000304 ***
## z.lag.1     -0.8733167  0.1859033  -4.698 5.47e-06 ***
## tt          -0.0015592  0.0006977  -2.235 0.026769 *  
## z.diff.lag1  0.1670645  0.1684801   0.992 0.322828    
## z.diff.lag2 -0.1842894  0.1460359  -1.262 0.208728    
## z.diff.lag3 -0.1634268  0.1224852  -1.334 0.183936    
## z.diff.lag4 -0.2262029  0.0920072  -2.459 0.014971 *  
## z.diff.lag5 -0.1450356  0.0764607  -1.897 0.059572 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4069 on 167 degrees of freedom
## Multiple R-squared:  0.4863, Adjusted R-squared:  0.4648 
## F-statistic: 22.58 on 7 and 167 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -4.6977 7.3659 11.0364 
## 
## 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
summary(ur.df(ts_data[, "birate"],  type = "trend", lags = 12, selectlags = "AIC"))
## 
## ############################################### 
## # 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 
## -1.18920 -0.04167 -0.00169  0.03939  0.49891 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  0.1522068  0.0810660   1.878   0.0622 .  
## z.lag.1     -0.0240329  0.0115026  -2.089   0.0382 *  
## tt          -0.0002009  0.0002775  -0.724   0.4701    
## z.diff.lag1  0.3977601  0.0748963   5.311 3.38e-07 ***
## z.diff.lag2  0.1733207  0.0757561   2.288   0.0234 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1649 on 170 degrees of freedom
## Multiple R-squared:  0.2529, Adjusted R-squared:  0.2353 
## F-statistic: 14.39 on 4 and 170 DF,  p-value: 3.873e-10
## 
## 
## Value of test-statistic is: -2.0893 1.478 2.2157 
## 
## 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
summary(ur.df(ts_data[, "kurs"],    type = "trend", lags = 12, selectlags = "AIC"))
## 
## ############################################### 
## # 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 
## -959.09 -158.99  -11.13  176.46 2105.95 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 1122.25450  339.03926   3.310  0.00114 **
## z.lag.1       -0.10358    0.03311  -3.128  0.00207 **
## tt             3.64960    1.33076   2.743  0.00675 **
## z.diff.lag    -0.03886    0.07597  -0.512  0.60962   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 329.4 on 171 degrees of freedom
## Multiple R-squared:  0.06219,    Adjusted R-squared:  0.04574 
## F-statistic:  3.78 on 3 and 171 DF,  p-value: 0.01166
## 
## 
## Value of test-statistic is: -3.1282 4.8692 4.9898 
## 
## 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
# UJI KOINTEGRASI (JOHANSEN TEST)
library(urca)

# Uji kointegrasi Johansen
# H0: Tidak ada kointegrasi
# H1: Ada kointegrasi

# Gunakan data pada LEVEL (bukan difference)
jo_test <- ca.jo(
  ts_data,           # data level (inflasi, birate, kurs)
  type = "trace",    # uji trace
  ecdet = "const",   # ada konstanta
  K = 2              # lag (sesuaikan)
)

summary(jo_test)
## 
## ###################### 
## # Johansen-Procedure # 
## ###################### 
## 
## Test type: trace statistic , without linear trend and constant in cointegration 
## 
## Eigenvalues (lambda):
## [1] 4.664030e-01 3.821592e-02 1.932174e-02 2.919387e-17
## 
## Values of teststatistic and critical values of test:
## 
##            test 10pct  5pct  1pct
## r <= 2 |   3.63  7.52  9.24 12.97
## r <= 1 |  10.88 17.85 19.96 24.60
## r = 0  | 127.71 32.00 34.91 41.07
## 
## Eigenvectors, normalised to first column:
## (These are the cointegration relations)
## 
##               inflasi.l2     birate.l2       kurs.l2     constant
## inflasi.l2  1.000000e+00   1.000000000   1.000000000   1.00000000
## birate.l2  -1.867410e-02  -2.355598529 -12.043223858  -0.78006064
## kurs.l2     3.201331e-05   0.003074355  -0.002692784  -0.01875741
## constant   -6.266710e-01 -42.892529339 105.483146982 233.05964322
## 
## Weights W:
## (This is the loading matrix)
## 
##             inflasi.l2     birate.l2      kurs.l2      constant
## inflasi.d  -1.06237194 -0.0005719345 0.0007814209 -2.255919e-18
## birate.d   -0.03593061  0.0006967080 0.0015313831 -3.122648e-18
## kurs.d    119.38456492 -3.4772434275 1.4440560471 -9.245847e-15
# Lihat bagian "test statistics" dan "critical values"
# Bandingkan
# - Jika test statistic > critical value (5%) → TOLAK H0 → ADA kointegrasi
# - Jika test statistic < critical value (5%) → GAGAL TOLAK H0 → TIDAK ADA kointegrasi

# 8. DIFFERENCE KALAU TIDAK STASIONER
d_birate <- diff(ts_data[, "birate"])
d_kurs   <- diff(ts_data[, "kurs"])

summary(ur.df(d_birate, type = "trend", lags = 12, selectlags = "AIC"))
## 
## ############################################### 
## # 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 
## -1.21287 -0.00200 -0.00053  0.03634  0.49940 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -6.844e-04  2.794e-02  -0.024   0.9805    
## z.lag.1     -4.553e-01  7.802e-02  -5.836 2.64e-08 ***
## tt           1.474e-05  2.507e-04   0.059   0.9532    
## z.diff.lag  -1.497e-01  7.535e-02  -1.987   0.0486 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1659 on 170 degrees of freedom
## Multiple R-squared:  0.2868, Adjusted R-squared:  0.2742 
## F-statistic: 22.79 on 3 and 170 DF,  p-value: 1.892e-12
## 
## 
## Value of test-statistic is: -5.8358 11.3693 17.0475 
## 
## 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
summary(ur.df(d_kurs,   type = "trend", lags = 12, selectlags = "AIC"))
## 
## ############################################### 
## # 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 
## -978.00 -130.61   -3.06  167.03 2096.54 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 85.32424   57.04665   1.496   0.1366    
## z.lag.1     -1.23924    0.11227 -11.038   <2e-16 ***
## tt          -0.23666    0.50789  -0.466   0.6418    
## z.diff.lag   0.14029    0.07628   1.839   0.0676 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 336.4 on 170 degrees of freedom
## Multiple R-squared:  0.5504, Adjusted R-squared:  0.5425 
## F-statistic: 69.38 on 3 and 170 DF,  p-value: < 2.2e-16
## 
## 
## Value of test-statistic is: -11.0379 40.62 60.9274 
## 
## 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
# 9. DATA FINAL UNTUK VAR
model_data <- cbind(
  inflasi = ts_data[, "inflasi"][-1],
  birate  = d_birate,
  kurs    = d_kurs
)
model_data <- na.omit(model_data)

head(model_data)
##          inflasi birate kurs
## Feb 2011    0.13   0.25 -234
## Mar 2011   -0.32   0.00 -114
## Apr 2011   -0.31   0.00 -135
## May 2011    0.12   0.00  -37
## Jun 2011    0.55   0.00   60
## Jul 2011    0.67   0.00  -89
# 10. PILIH LAG OPTIMAL
lag_select <- VARselect(model_data, lag.max = 12, type = "const")
lag_select$selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      2      2      1      2
# 11. ESTIMASI VAR (GANTI p SESUAI HASIL DI ATAS)
var_model <- VAR(model_data, p = 2, type = "const")
summary(var_model)
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: inflasi, birate, kurs 
## Deterministic variables: const 
## Sample size: 185 
## Log Likelihood: -1341.028 
## Roots of the characteristic polynomial:
## 0.6289 0.584 0.584 0.3473 0.3473 0.2429
## Call:
## VAR(y = model_data, p = 2, type = "const")
## 
## 
## Estimation results for equation inflasi: 
## ======================================== 
## inflasi = inflasi.l1 + birate.l1 + kurs.l1 + inflasi.l2 + birate.l2 + kurs.l2 + const 
## 
##              Estimate Std. Error t value Pr(>|t|)    
## inflasi.l1  3.454e-01  7.182e-02   4.809 3.22e-06 ***
## birate.l1   3.314e-01  1.904e-01   1.741   0.0834 .  
## kurs.l1     1.383e-05  9.445e-05   0.146   0.8837    
## inflasi.l2 -3.295e-01  7.221e-02  -4.563 9.37e-06 ***
## birate.l2  -1.526e-01  1.875e-01  -0.814   0.4166    
## kurs.l2     8.020e-05  9.485e-05   0.846   0.3989    
## const       3.002e-01  4.100e-02   7.323 8.10e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.414 on 178 degrees of freedom
## Multiple R-Squared: 0.2009,  Adjusted R-squared: 0.174 
## F-statistic: 7.459 on 6 and 178 DF,  p-value: 3.867e-07 
## 
## 
## Estimation results for equation birate: 
## ======================================= 
## birate = inflasi.l1 + birate.l1 + kurs.l1 + inflasi.l2 + birate.l2 + kurs.l2 + const 
## 
##              Estimate Std. Error t value Pr(>|t|)    
## inflasi.l1  1.158e-02  2.813e-02   0.412   0.6811    
## birate.l1   3.602e-01  7.455e-02   4.832 2.91e-06 ***
## kurs.l1     7.998e-05  3.699e-05   2.162   0.0319 *  
## inflasi.l2 -6.622e-02  2.828e-02  -2.342   0.0203 *  
## birate.l2   1.609e-01  7.341e-02   2.192   0.0297 *  
## kurs.l2     8.550e-05  3.715e-05   2.302   0.0225 *  
## const       5.892e-03  1.606e-02   0.367   0.7141    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.1622 on 178 degrees of freedom
## Multiple R-Squared: 0.2794,  Adjusted R-squared: 0.2551 
## F-statistic:  11.5 on 6 and 178 DF,  p-value: 7.357e-11 
## 
## 
## Estimation results for equation kurs: 
## ===================================== 
## kurs = inflasi.l1 + birate.l1 + kurs.l1 + inflasi.l2 + birate.l2 + kurs.l2 + const 
## 
##             Estimate Std. Error t value Pr(>|t|)  
## inflasi.l1  51.72788   56.30011   0.919   0.3594  
## birate.l1  204.73188  149.22273   1.372   0.1718  
## kurs.l1     -0.12516    0.07404  -1.690   0.0927 .
## inflasi.l2  85.67447   56.60289   1.514   0.1319  
## birate.l2  -70.69989  146.94693  -0.481   0.6310  
## kurs.l2     -0.16039    0.07436  -2.157   0.0323 *
## const       21.28227   32.14225   0.662   0.5087  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 324.6 on 178 degrees of freedom
## Multiple R-Squared: 0.06263, Adjusted R-squared: 0.03103 
## F-statistic: 1.982 on 6 and 178 DF,  p-value: 0.07048 
## 
## 
## 
## Covariance matrix of residuals:
##         inflasi  birate      kurs
## inflasi  0.1714 0.01400 9.869e+00
## birate   0.0140 0.02629 6.738e+00
## kurs     9.8691 6.73786 1.053e+05
## 
## Correlation matrix of residuals:
##         inflasi birate    kurs
## inflasi 1.00000 0.2086 0.07344
## birate  0.20860 1.0000 0.12802
## kurs    0.07344 0.1280 1.00000
# 12. UJI DIAGNOSTIK
serial.test(var_model, lags.pt = 12, type = "PT.asymptotic")
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object var_model
## Chi-squared = 90.658, df = 90, p-value = 0.4607
arch.test(var_model, lags.multi = 12)
## 
##  ARCH (multivariate)
## 
## data:  Residuals of VAR object var_model
## Chi-squared = 330.84, df = 432, p-value = 0.9999
normality.test(var_model)
## $JB
## 
##  JB-Test (multivariate)
## 
## data:  Residuals of VAR object var_model
## Chi-squared = 3446.9, df = 6, p-value < 2.2e-16
## 
## 
## $Skewness
## 
##  Skewness only (multivariate)
## 
## data:  Residuals of VAR object var_model
## Chi-squared = 242.88, df = 3, p-value < 2.2e-16
## 
## 
## $Kurtosis
## 
##  Kurtosis only (multivariate)
## 
## data:  Residuals of VAR object var_model
## Chi-squared = 3204.1, df = 3, p-value < 2.2e-16
# 13. CEK STABILITAS
roots(var_model)
## [1] 0.6289188 0.5839940 0.5839940 0.3473020 0.3473020 0.2429450
dev.off()
## null device 
##           1
par(mfrow = c(1, 1))
plot(stability(var_model))

# 14. IRF (CONTOH 3)
plot(irf(var_model, impulse = "inflasi", response = "inflasi", n.ahead = 24))
plot(irf(var_model, impulse = "birate",  response = "inflasi", n.ahead = 24))
plot(irf(var_model, impulse = "kurs",    response = "inflasi", n.ahead = 24))

# 15. FEVD
fevd(var_model, n.ahead = 24)
## $inflasi
##         inflasi     birate         kurs
##  [1,] 1.0000000 0.00000000 0.000000e+00
##  [2,] 0.9856854 0.01421481 9.984009e-05
##  [3,] 0.9787154 0.01514494 6.139676e-03
##  [4,] 0.9784636 0.01465768 6.878743e-03
##  [5,] 0.9777001 0.01478296 7.516926e-03
##  [6,] 0.9775602 0.01472494 7.714875e-03
##  [7,] 0.9774793 0.01477439 7.746307e-03
##  [8,] 0.9774172 0.01478314 7.799647e-03
##  [9,] 0.9774196 0.01478134 7.799097e-03
## [10,] 0.9774153 0.01478166 7.803050e-03
## [11,] 0.9774151 0.01478149 7.803381e-03
## [12,] 0.9774145 0.01478184 7.803684e-03
## [13,] 0.9774142 0.01478187 7.803906e-03
## [14,] 0.9774142 0.01478187 7.803902e-03
## [15,] 0.9774142 0.01478187 7.803920e-03
## [16,] 0.9774142 0.01478187 7.803920e-03
## [17,] 0.9774142 0.01478187 7.803923e-03
## [18,] 0.9774142 0.01478187 7.803924e-03
## [19,] 0.9774142 0.01478187 7.803924e-03
## [20,] 0.9774142 0.01478187 7.803924e-03
## [21,] 0.9774142 0.01478187 7.803924e-03
## [22,] 0.9774142 0.01478187 7.803924e-03
## [23,] 0.9774142 0.01478187 7.803924e-03
## [24,] 0.9774142 0.01478187 7.803924e-03
## 
## $birate
##          inflasi    birate       kurs
##  [1,] 0.04351197 0.9564880 0.00000000
##  [2,] 0.04852656 0.9300917 0.02138175
##  [3,] 0.04539243 0.9034429 0.05116472
##  [4,] 0.04536680 0.9021470 0.05248619
##  [5,] 0.04529448 0.9021025 0.05260303
##  [6,] 0.04553367 0.9015825 0.05288387
##  [7,] 0.04545611 0.9014385 0.05310536
##  [8,] 0.04544018 0.9013776 0.05318218
##  [9,] 0.04543030 0.9013697 0.05319996
## [10,] 0.04542909 0.9013663 0.05320463
## [11,] 0.04542919 0.9013633 0.05320751
## [12,] 0.04542842 0.9013622 0.05320935
## [13,] 0.04542818 0.9013618 0.05321002
## [14,] 0.04542807 0.9013617 0.05321019
## [15,] 0.04542805 0.9013617 0.05321025
## [16,] 0.04542804 0.9013617 0.05321028
## [17,] 0.04542804 0.9013617 0.05321030
## [18,] 0.04542803 0.9013617 0.05321030
## [19,] 0.04542803 0.9013617 0.05321030
## [20,] 0.04542803 0.9013617 0.05321030
## [21,] 0.04542803 0.9013617 0.05321031
## [22,] 0.04542803 0.9013617 0.05321031
## [23,] 0.04542803 0.9013617 0.05321031
## [24,] 0.04542803 0.9013617 0.05321031
## 
## $kurs
##           inflasi     birate      kurs
##  [1,] 0.005393152 0.01327981 0.9813270
##  [2,] 0.011175691 0.02003169 0.9687926
##  [3,] 0.023768204 0.01974967 0.9564821
##  [4,] 0.023753360 0.02029460 0.9559520
##  [5,] 0.026371123 0.02031707 0.9533118
##  [6,] 0.026455847 0.02031530 0.9532289
##  [7,] 0.026696859 0.02031045 0.9529927
##  [8,] 0.026756068 0.02031811 0.9529258
##  [9,] 0.026763606 0.02032115 0.9529152
## [10,] 0.026775142 0.02032107 0.9529038
## [11,] 0.026775150 0.02032107 0.9529038
## [12,] 0.026776442 0.02032108 0.9529025
## [13,] 0.026776611 0.02032114 0.9529022
## [14,] 0.026776671 0.02032116 0.9529022
## [15,] 0.026776717 0.02032116 0.9529021
## [16,] 0.026776717 0.02032116 0.9529021
## [17,] 0.026776724 0.02032116 0.9529021
## [18,] 0.026776725 0.02032116 0.9529021
## [19,] 0.026776725 0.02032116 0.9529021
## [20,] 0.026776725 0.02032116 0.9529021
## [21,] 0.026776725 0.02032116 0.9529021
## [22,] 0.026776725 0.02032116 0.9529021
## [23,] 0.026776725 0.02032116 0.9529021
## [24,] 0.026776725 0.02032116 0.9529021
plot(fevd(var_model, n.ahead = 24))