Library

library(readxl)
library(tseries)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
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(ggplot2)

1. Pengumpulan Data

Data yang digunakan merupakan data time series harian yang terdiri dari tiga variabel, yaitu:

Data diolah dalam format numerik dan siap digunakan untuk analisis time series.

data <- read_excel("~/Mine/Rpubs/VAR/DataVar1.xlsx") 
data_ts <- data[, -1] 
data_ts <- as.data.frame(data_ts)
head(data_ts)
##   IHSG USDIDR Minyak_Brent
## 1 7102  15120        78.20
## 2 7089  15135        78.45
## 3 6945  15310        80.50
## 4 6960  15290        80.10
## 5 6985  15275        79.80
## 6 7012  15250        79.30

2. Analisis deskriftif

Analisis deskriptif dilakukan untuk melihat karakteristik awal data, seperti nilai rata-rata, minimum, maksimum, dan pola pergerakan.

summary(data_ts) 
##       IHSG          USDIDR       Minyak_Brent  
##  Min.   :6780   Min.   :14610   Min.   :73.90  
##  1st Qu.:7090   1st Qu.:15070   1st Qu.:78.50  
##  Median :7210   Median :15200   Median :81.10  
##  Mean   :7228   Mean   :15212   Mean   :81.68  
##  3rd Qu.:7345   3rd Qu.:15350   3rd Qu.:85.20  
##  Max.   :7710   Max.   :15670   Max.   :90.80

Berdasarkan ringkasan statistik deskriptif, IHSG memiliki nilai minimum 6.780, maksimum 7.710, dengan rata-rata 7.228 dan median 7.210 yang hampir sama, menunjukkan sebaran data yang relatif simetris. Nilai tukar USD/IDR berada pada rentang 14.610 hingga 15.670, dengan rata-rata 15.212 dan median 15.200, juga mencerminkan distribusi yang cukup simetris. Sementara harga minyak dunia (Brent Crude) memiliki minimum 73,90 USD/barel, maksimum 90,80 USD/barel, rata-rata 81,68, dan median 81,10, dimana median lebih rendah dari rata-rata mengindikasikan distribusi yang sedikit menceng ke kanan (positive skew). Secara keseluruhan, ketiga variabel menunjukkan variasi data yang wajar dengan rentang nilai yang berbeda-beda sesuai karakteristik masing-masing.

plot.ts(data_ts, main = "Plot Time Series")

Ketiga data bergerak secara fluktuatif dengan intensitas perubahan yang tinggi di sepanjang periode. IHSG menunjukkan pola gelombang besar dengan beberapa puncak tertinggi sebelum mengalami penurunan tajam di bagian akhir. USDIDR dan Minyak Brent memiliki pola pergerakan yang lebih rapat dan tajam (zigzag), di mana lonjakan besar pada satu variabel sering kali diikuti oleh pembalikan arah yang cepat.

3. Uji Stasioner (ADF Test)

Uji stasioneritas dilakukan menggunakan metode Augmented Dickey-Fuller (ADF) untuk memastikan data memenuhi asumsi model VAR.

adf.test(data_ts$IHSG) 
## Warning in adf.test(data_ts$IHSG): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  data_ts$IHSG
## Dickey-Fuller = -4.2553, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary
adf.test(data_ts$USDIDR) 
## 
##  Augmented Dickey-Fuller Test
## 
## data:  data_ts$USDIDR
## Dickey-Fuller = -3.0187, Lag order = 7, p-value = 0.147
## alternative hypothesis: stationary
adf.test(data_ts$Minyak_Brent)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  data_ts$Minyak_Brent
## Dickey-Fuller = -2.3855, Lag order = 7, p-value = 0.4142
## alternative hypothesis: stationary

Berdasarkan Output diatas diperoleh bahwa Hanya Variabel IHSG yang stasioner karena p-value < 0.05 dan variabel Kurs dan Harga Minyak tidak stasioner sehingga akan dilakukan deferencing sebagai berikut

# Diferencing satu persatu
IHSG_diff <- diff(data_ts$IHSG)
USD_diff  <- diff(data_ts$USDIDR)
OIL_diff  <- diff(data_ts$Minyak_Brent)
# Gabung kembali 
data_diff <- data.frame(
  IHSG = diff(data_ts$IHSG),
  USDIDR = diff(data_ts$USDIDR),
  Minyak_Brent = diff(data_ts$Minyak_Brent)
)
head(data_diff)
##   IHSG USDIDR Minyak_Brent
## 1  -13     15         0.25
## 2 -144    175         2.05
## 3   15    -20        -0.40
## 4   25    -15        -0.30
## 5   27    -25        -0.50
## 6   38    -30        -0.40

Setelah itu lakukan lagi ADF test

adf.test(IHSG_diff)
## Warning in adf.test(IHSG_diff): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  IHSG_diff
## Dickey-Fuller = -6.1238, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary
adf.test(USD_diff)
## Warning in adf.test(USD_diff): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  USD_diff
## Dickey-Fuller = -6.4777, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary
adf.test(OIL_diff)
## Warning in adf.test(OIL_diff): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  OIL_diff
## Dickey-Fuller = -7.1308, Lag order = 7, p-value = 0.01
## alternative hypothesis: stationary

Seluruh variabel sudah stasioner (p-value <0.05) sehingga dapat dilanjutkan ke tahap selajutnya

4. Penentuan Lag Optimal

Penentuan lag optimal dilakukan menggunakan beberapa kriteria informasi seperti AIC, BIC, dan HQ. Lag optimal dipilih berdasarkan nilai kriteria terkecil.

VARselect(data_diff, lag.max = 10, type = "const")
## $selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      1      1      1      1 
## 
## $criteria
##                   1            2            3            4            5
## AIC(n) 1.576922e+01 1.580773e+01 1.585446e+01 1.588626e+01 1.593575e+01
## HQ(n)  1.582141e+01 1.589906e+01 1.598493e+01 1.605586e+01 1.614449e+01
## SC(n)  1.590038e+01 1.603727e+01 1.618237e+01 1.631254e+01 1.646040e+01
## FPE(n) 7.054837e+06 7.331908e+06 7.682900e+06 7.931539e+06 8.334673e+06
##                   6            7            8            9           10
## AIC(n) 1.598554e+01 1.603553e+01 1.608525e+01 1.612106e+01 1.612984e+01
## HQ(n)  1.623342e+01 1.632255e+01 1.641141e+01 1.648636e+01 1.653428e+01
## SC(n)  1.660856e+01 1.675692e+01 1.690502e+01 1.703920e+01 1.714635e+01
## FPE(n) 8.761262e+06 9.211943e+06 9.683759e+06 1.003968e+07 1.013183e+07

Berdasarkan output diatas ‘AIC(n)’, ‘HQ(n)’,‘SC(n)’, ‘FPE(n)’ memilih lag 1 sebagai lag optimal

5. Estimasi Model VAR

Model VAR dibangun menggunakan lag optimal yang telah ditentukan.

model_var <- VAR(data_diff, p = 1, type = "const")
summary(model_var)
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: IHSG, USDIDR, Minyak_Brent 
## Deterministic variables: const 
## Sample size: 363 
## Log Likelihood: -4390.462 
## Roots of the characteristic polynomial:
## 0.1739 0.02091 0.01939
## Call:
## VAR(y = data_diff, p = 1, type = "const")
## 
## 
## Estimation results for equation IHSG: 
## ===================================== 
## IHSG = IHSG.l1 + USDIDR.l1 + Minyak_Brent.l1 + const 
## 
##                 Estimate Std. Error t value Pr(>|t|)   
## IHSG.l1          0.17072    0.05832   2.927  0.00364 **
## USDIDR.l1        0.02207    0.04901   0.450  0.65276   
## Minyak_Brent.l1 -3.03372    2.70430  -1.122  0.26269   
## const            0.94345    2.61657   0.361  0.71864   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 49.83 on 359 degrees of freedom
## Multiple R-Squared: 0.03758, Adjusted R-squared: 0.02954 
## F-statistic: 4.673 on 3 and 359 DF,  p-value: 0.003234 
## 
## 
## Estimation results for equation USDIDR: 
## ======================================= 
## USDIDR = IHSG.l1 + USDIDR.l1 + Minyak_Brent.l1 + const 
## 
##                 Estimate Std. Error t value Pr(>|t|)    
## IHSG.l1         -0.02605    0.06578  -0.396    0.692    
## USDIDR.l1       -0.01390    0.05528  -0.251    0.802    
## Minyak_Brent.l1 13.07004    3.05056   4.284 2.36e-05 ***
## const           -0.51610    2.95159  -0.175    0.861    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 56.21 on 359 degrees of freedom
## Multiple R-Squared: 0.05898, Adjusted R-squared: 0.05112 
## F-statistic: 7.501 on 3 and 359 DF,  p-value: 6.993e-05 
## 
## 
## Estimation results for equation Minyak_Brent: 
## ============================================= 
## Minyak_Brent = IHSG.l1 + USDIDR.l1 + Minyak_Brent.l1 + const 
## 
##                   Estimate Std. Error t value Pr(>|t|)
## IHSG.l1         -0.0006898  0.0012341  -0.559    0.577
## USDIDR.l1       -0.0000592  0.0010371  -0.057    0.955
## Minyak_Brent.l1  0.0155984  0.0572274   0.273    0.785
## const            0.0051776  0.0553709   0.094    0.926
## 
## 
## Residual standard error: 1.054 on 359 degrees of freedom
## Multiple R-Squared: 0.001623,    Adjusted R-squared: -0.00672 
## F-statistic: 0.1945 on 3 and 359 DF,  p-value: 0.9001 
## 
## 
## 
## Covariance matrix of residuals:
##                 IHSG  USDIDR Minyak_Brent
## IHSG         2482.78 -962.62      -18.538
## USDIDR       -962.62 3159.27       13.124
## Minyak_Brent  -18.54   13.12        1.112
## 
## Correlation matrix of residuals:
##                 IHSG  USDIDR Minyak_Brent
## IHSG          1.0000 -0.3437      -0.3528
## USDIDR       -0.3437  1.0000       0.2214
## Minyak_Brent -0.3528  0.2214       1.0000

Interpretasi

Stabilitas Model VAR

Diperoleh hasil Roots 0.1739; 0.02091; 0.01939 (semua < 1)

sehingga dapat dikatakan Model VAR(1) yang dibangun bersifat stabil

Persamaan IHSG \[ IHSG_t = 0.17072\,IHSG_{t-1} + 0.02207\,USDIDR_{t-1} - 3.03372\,Minyak_{t-1} + 0.94345 \]

Hasil:

IHSG(-1) → signifikan (p = 0.00364) ✔️

USDIDR(-1) → tidak signifikan ❌

Minyak_Brent(-1) → tidak signifikan ❌

Interpetasi:

  1. Pengaruh IHSG terhadap dirinya sendiri IHSG periode sebelumnya berpengaruh positif dan signifikan terhadap IHSG saat ini. Menunjukkan adanya efek persistensi (inertia) dalam pasar saham

  2. Pengaruh Kurs terhadap IHSG Tidak signifikan. Artinya perubahan nilai tukar tidak langsung mempengaruhi IHSG dalam jangka pendek

  3. Pengaruh Harga Minyak terhadap IHSG Tidak signifikan. Menunjukkan bahwa fluktuasi harga minyak tidak berdampak langsung pada pasar saham domestik

  4. Kesimpulan IHSG Pergerakan IHSG lebih ditentukan oleh faktor internal pasar itu sendiri

Persamaan USD/IDR \[ USDIDR_t = -0.02605\,IHSG_{t-1} - 0.01390\,USDIDR_{t-1} + 13.07004\,Minyak_{t-1} - 0.51610 \] Hasil:

IHSG(-1) → tidak signifikan ❌

USDIDR(-1) → tidak signifikan ❌

Minyak_Brent(-1) → signifikan (p < 0.001) ✔️

Interpretasi:

  1. Pengaruh IHSG terhadap USD/IDR Tidak signifikan. Artinya, pergerakan pasar saham tidak memberikan pengaruh langsung terhadap nilai tukar dalam jangka pendek.

  2. Pengaruh USD/IDR terhadap dirinya sendiri Tidak signifikan. Menunjukkan bahwa nilai tukar pada periode sebelumnya tidak memiliki pengaruh yang kuat terhadap nilai tukar saat ini dalam model ini.

  3. Pengaruh Harga Minyak terhadap USD/IDR Signifikan dan bernilai positif. Artinya, kenaikan harga minyak pada periode sebelumnya cenderung meningkatkan nilai USD/IDR (pelemahan rupiah).

  4. Kesimpulan USD/IDR : Pergerakan nilai tukar lebih dipengaruhi oleh faktor eksternal, khususnya harga komoditas global seperti minyak, dibandingkan faktor domestik seperti IHSG.

Persamaan Harga Minyak \[ Minyak\_Brent_t = -0.00069\,IHSG_{t-1} - 0.00006\,USDIDR_{t-1} + 0.01560\,Minyak\_Brent_{t-1} + 0.00518 \] Hasil:

IHSG(-1) → tidak signifikan ❌

USDIDR(-1) → tidak signifikan ❌

Minyak_Brent(-1) → tidak signifikan ❌ Interpretasi:

  1. Pengaruh IHSG terhadap Harga Minyak Tidak signifikan. Artinya, pergerakan pasar saham domestik tidak mempengaruhi harga minyak dunia.

  2. Pengaruh USD/IDR terhadap Harga Minyak Tidak signifikan. Nilai tukar rupiah tidak memiliki dampak terhadap harga minyak Brent.

  3. Pengaruh Harga Minyak terhadap dirinya sendiri Tidak signifikan. Menunjukkan tidak adanya ketergantungan jangka pendek yang kuat dalam model ini.

  4. Kesimpulan Harga Minyak Pergerakan harga minyak Brent tidak dipengaruhi oleh variabel dalam model, sehingga dapat dianggap sebagai variabel eksogen yang lebih ditentukan oleh faktor global seperti kondisi geopolitik dan dinamika pasar energi dunia.

6. Uji Diagnostik Model

Model yang baik adalah model yang tidak mengandung autokorelasi, residual berdistribusi normal, dan stabil.

a. Uji Autokorelasi

serial.test(model_var)
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object model_var
## Chi-squared = 135.99, df = 135, p-value = 0.46

Berdasarkan output diatas diperoleh p-value >0.05 sehingga tidak terdapat autokorelasi pada residual dan bersifat white noise

b. Uji Normalitas

normality.test(model_var)
## $JB
## 
##  JB-Test (multivariate)
## 
## data:  Residuals of VAR object model_var
## Chi-squared = 107802, df = 6, p-value < 2.2e-16
## 
## 
## $Skewness
## 
##  Skewness only (multivariate)
## 
## data:  Residuals of VAR object model_var
## Chi-squared = 2268.4, df = 3, p-value < 2.2e-16
## 
## 
## $Kurtosis
## 
##  Kurtosis only (multivariate)
## 
## data:  Residuals of VAR object model_var
## Chi-squared = 105534, df = 3, p-value < 2.2e-16

Berdasarkan nilai JB-Test diperoleh p-value < 0.05 sehingga residual tidak berdistribusi normal

c. Uji Stabilitas

plot(stability(model_var))

Ketiga grafik menunjukkan bahwa garis fluktuasi empiris (garis hitam) secara konsisten berada di dalam batas ambang kritis (garis merah horizontal). Hal ini mengindikasikan bahwa parameter dalam model statistik tersebut bersifat stabil dan tidak ditemukan adanya perubahan struktural (structural break) yang signifikan selama periode pengamatan

7. Impulse Response Function (IRF)

IRF digunakan untuk melihat respon suatu variabel akibat shock dari variabel lain.

Respon IHSG terhadap Shock USD/IDR

irf_kurs_ihsg <- irf(model_var, impulse = "USDIDR", response = "IHSG", n.ahead = 10)
plot(irf_kurs_ihsg)

Grafik menunjukkan pola respons IHSG yang tidak signifikan secara statistik terhadap guncangan (shock) dari USDIDR. Meskipun garis hitam (garis respons) menunjukkan kenaikan kecil pada periode kedua, garis tersebut tetap berada di dalam area batas kepercayaan 95% (garis putus-putus merah) yang mencakup angka nol. Respons ini kemudian bergerak cepat menuju garis nol atau stabil (konvergen) mulai dari periode keempat. Hal ini mengindikasikan bahwa dalam model ini, kejutan pada nilai tukar USDIDR tidak memberikan dampak yang meyakinkan atau permanen terhadap pergerakan IHSG.

Respon Harga Minyak terhadap USDIDR

irf_oil_usd <- irf(model_var, impulse = "Minyak_Brent", response = "USDIDR", n.ahead = 10)
plot(irf_oil_usd)

Grafik menunjukkan pola respons yang signifikan secara statistik pada periode awal. Guncangan (shock) pada harga Minyak Brent direspons secara positif dan cukup tajam oleh USDIDR, yang mencapai puncaknya pada periode kedua. Hal ini terlihat dari garis respons hitam dan seluruh area batas kepercayaan 95% (garis merah putus-putus) yang berada sepenuhnya di atas garis nol. Namun, respons ini bersifat jangka pendek karena pada periode ketiga, nilai respons langsung menurun drastis dan kembali stabil mendekati garis nol (konvergen) hingga periode akhir pengamatan.

8. Forecast Error Variance Decomposition (FEVD)

FEVD digunakan untuk mengetahui kontribusi masing-masing variabel terhadap variansi error.

fevd_result <- fevd(model_var, n.ahead = 10)
fevd_result
## $IHSG
##            IHSG       USDIDR Minyak_Brent
##  [1,] 1.0000000 0.0000000000  0.000000000
##  [2,] 0.9963057 0.0002632220  0.003431104
##  [3,] 0.9962707 0.0002730139  0.003456267
##  [4,] 0.9962696 0.0002733166  0.003457086
##  [5,] 0.9962696 0.0002733257  0.003457110
##  [6,] 0.9962696 0.0002733260  0.003457111
##  [7,] 0.9962696 0.0002733260  0.003457111
##  [8,] 0.9962696 0.0002733260  0.003457111
##  [9,] 0.9962696 0.0002733260  0.003457111
## [10,] 0.9962696 0.0002733260  0.003457111
## 
## $USDIDR
##            IHSG    USDIDR Minyak_Brent
##  [1,] 0.1181371 0.8818629   0.00000000
##  [2,] 0.1214605 0.8296738   0.04886569
##  [3,] 0.1215768 0.8295612   0.04886195
##  [4,] 0.1215804 0.8295576   0.04886193
##  [5,] 0.1215805 0.8295575   0.04886193
##  [6,] 0.1215805 0.8295575   0.04886193
##  [7,] 0.1215805 0.8295575   0.04886193
##  [8,] 0.1215805 0.8295575   0.04886193
##  [9,] 0.1215805 0.8295575   0.04886193
## [10,] 0.1215805 0.8295575   0.04886193
## 
## $Minyak_Brent
##            IHSG     USDIDR Minyak_Brent
##  [1,] 0.1244936 0.01137861    0.8641278
##  [2,] 0.1256650 0.01136233    0.8629727
##  [3,] 0.1256990 0.01136221    0.8629388
##  [4,] 0.1257000 0.01136221    0.8629378
##  [5,] 0.1257000 0.01136221    0.8629378
##  [6,] 0.1257000 0.01136221    0.8629378
##  [7,] 0.1257000 0.01136221    0.8629378
##  [8,] 0.1257000 0.01136221    0.8629378
##  [9,] 0.1257000 0.01136221    0.8629378
## [10,] 0.1257000 0.01136221    0.8629378

FEVD IHSG

Hasil (periode ke-10) - IHSG → 99.63% - USDIDR → 0.03% - Minyak → 0.35%

  1. Pengaruh IHSG terhadap dirinya sendiri Sangat dominan (≈99%).Variasi IHSG hampir seluruhnya dijelaskan oleh shock dari IHSG itu sendiri.

  2. Pengaruh USD/IDR terhadap IHSG Sangat kecil (<1%).Nilai tukar tidak memiliki kontribusi berarti terhadap fluktuasi IHSG.

  3. Pengaruh Harga Minyak terhadap IHSG Sangat kecil (<1%). Harga minyak tidak berperan penting dalam menjelaskan pergerakan IHSG.

FEVD Kurs

Hasil (periode ke-10) - USDIDR → 82.96% - IHSG → 12.16% - Minyak → 4.89%

  1. Pengaruh USD/IDR terhadap dirinya sendiri Dominan (~83%). Kurs sangat dipengaruhi oleh shock internalnya sendiri.

  2. Pengaruh IHSG terhadap USD/IDR Cukup besar (~12%). Pasar saham memiliki kontribusi terhadap nilai tukar.

  3. Pengaruh Harga Minyak terhadap USD/IDR Ada pengaruh (~4.9%). Harga minyak berkontribusi terhadap fluktuasi kurs

FEVD Minyak Brent

Hasil (periode ke-10) - Minyak → 86.29% - IHSG → 12.57% - USDIDR → 1.13%

  1. Pengaruh Minyak terhadap dirinya sendiri Dominan (~86%). Harga minyak sebagian besar ditentukan oleh shock internal/globalnya sendiri.

  2. Pengaruh IHSG terhadap Minyak Cukup terlihat (~12.5%). Ada kontribusi kecil dari pasar saham (meskipun tidak signifikan di VAR)

  3. Pengaruh USD/IDR terhadap Minyak Sangat kecil (~1%). Nilai tukar tidak berpengaruh berarti terhadap harga minyak.

9. Forecast Nilai 100 periode kedepan

IHSG

periode <- 100
# Forecast 10 hari
forecast_var <- predict(model_var, n.ahead = periode)
data_plot <- data.frame(
  Tanggal = c(data$Tanggal, seq(max(data$Tanggal) + 1, by = "day", length.out = periode)),
  IHSG = c(data$IHSG, cumsum(forecast_var$fcst$IHSG[,1]) + tail(data$IHSG, 1)),
  Tipe = rep(c("Asli", "Forecast"), c(nrow(data), periode))
)
tail(data_plot,periode)
##                 Tanggal     IHSG     Tipe
## 366 2025-12-31 00:00:01 7490.020 Forecast
## 367 2026-01-01 00:00:01 7490.373 Forecast
## 368 2026-01-02 00:00:01 7491.354 Forecast
## 369 2026-01-03 00:00:01 7492.440 Forecast
## 370 2026-01-04 00:00:01 7493.544 Forecast
## 371 2026-01-05 00:00:01 7494.652 Forecast
## 372 2026-01-06 00:00:01 7495.760 Forecast
## 373 2026-01-07 00:00:01 7496.868 Forecast
## 374 2026-01-08 00:00:01 7497.977 Forecast
## 375 2026-01-09 00:00:01 7499.085 Forecast
## 376 2026-01-10 00:00:01 7500.194 Forecast
## 377 2026-01-11 00:00:01 7501.302 Forecast
## 378 2026-01-12 00:00:01 7502.410 Forecast
## 379 2026-01-13 00:00:01 7503.519 Forecast
## 380 2026-01-14 00:00:01 7504.627 Forecast
## 381 2026-01-15 00:00:01 7505.736 Forecast
## 382 2026-01-16 00:00:01 7506.844 Forecast
## 383 2026-01-17 00:00:01 7507.953 Forecast
## 384 2026-01-18 00:00:01 7509.061 Forecast
## 385 2026-01-19 00:00:01 7510.169 Forecast
## 386 2026-01-20 00:00:01 7511.278 Forecast
## 387 2026-01-21 00:00:01 7512.386 Forecast
## 388 2026-01-22 00:00:01 7513.495 Forecast
## 389 2026-01-23 00:00:01 7514.603 Forecast
## 390 2026-01-24 00:00:01 7515.711 Forecast
## 391 2026-01-25 00:00:01 7516.820 Forecast
## 392 2026-01-26 00:00:01 7517.928 Forecast
## 393 2026-01-27 00:00:01 7519.037 Forecast
## 394 2026-01-28 00:00:01 7520.145 Forecast
## 395 2026-01-29 00:00:01 7521.253 Forecast
## 396 2026-01-30 00:00:01 7522.362 Forecast
## 397 2026-01-31 00:00:01 7523.470 Forecast
## 398 2026-02-01 00:00:01 7524.579 Forecast
## 399 2026-02-02 00:00:01 7525.687 Forecast
## 400 2026-02-03 00:00:01 7526.795 Forecast
## 401 2026-02-04 00:00:01 7527.904 Forecast
## 402 2026-02-05 00:00:01 7529.012 Forecast
## 403 2026-02-06 00:00:01 7530.121 Forecast
## 404 2026-02-07 00:00:01 7531.229 Forecast
## 405 2026-02-08 00:00:01 7532.337 Forecast
## 406 2026-02-09 00:00:01 7533.446 Forecast
## 407 2026-02-10 00:00:01 7534.554 Forecast
## 408 2026-02-11 00:00:01 7535.663 Forecast
## 409 2026-02-12 00:00:01 7536.771 Forecast
## 410 2026-02-13 00:00:01 7537.879 Forecast
## 411 2026-02-14 00:00:01 7538.988 Forecast
## 412 2026-02-15 00:00:01 7540.096 Forecast
## 413 2026-02-16 00:00:01 7541.205 Forecast
## 414 2026-02-17 00:00:01 7542.313 Forecast
## 415 2026-02-18 00:00:01 7543.421 Forecast
## 416 2026-02-19 00:00:01 7544.530 Forecast
## 417 2026-02-20 00:00:01 7545.638 Forecast
## 418 2026-02-21 00:00:01 7546.747 Forecast
## 419 2026-02-22 00:00:01 7547.855 Forecast
## 420 2026-02-23 00:00:01 7548.963 Forecast
## 421 2026-02-24 00:00:01 7550.072 Forecast
## 422 2026-02-25 00:00:01 7551.180 Forecast
## 423 2026-02-26 00:00:01 7552.289 Forecast
## 424 2026-02-27 00:00:01 7553.397 Forecast
## 425 2026-02-28 00:00:01 7554.505 Forecast
## 426 2026-03-01 00:00:01 7555.614 Forecast
## 427 2026-03-02 00:00:01 7556.722 Forecast
## 428 2026-03-03 00:00:01 7557.831 Forecast
## 429 2026-03-04 00:00:01 7558.939 Forecast
## 430 2026-03-05 00:00:01 7560.048 Forecast
## 431 2026-03-06 00:00:01 7561.156 Forecast
## 432 2026-03-07 00:00:01 7562.264 Forecast
## 433 2026-03-08 00:00:01 7563.373 Forecast
## 434 2026-03-09 00:00:01 7564.481 Forecast
## 435 2026-03-10 00:00:01 7565.590 Forecast
## 436 2026-03-11 00:00:01 7566.698 Forecast
## 437 2026-03-12 00:00:01 7567.806 Forecast
## 438 2026-03-13 00:00:01 7568.915 Forecast
## 439 2026-03-14 00:00:01 7570.023 Forecast
## 440 2026-03-15 00:00:01 7571.132 Forecast
## 441 2026-03-16 00:00:01 7572.240 Forecast
## 442 2026-03-17 00:00:01 7573.348 Forecast
## 443 2026-03-18 00:00:01 7574.457 Forecast
## 444 2026-03-19 00:00:01 7575.565 Forecast
## 445 2026-03-20 00:00:01 7576.674 Forecast
## 446 2026-03-21 00:00:01 7577.782 Forecast
## 447 2026-03-22 00:00:01 7578.890 Forecast
## 448 2026-03-23 00:00:01 7579.999 Forecast
## 449 2026-03-24 00:00:01 7581.107 Forecast
## 450 2026-03-25 00:00:01 7582.216 Forecast
## 451 2026-03-26 00:00:01 7583.324 Forecast
## 452 2026-03-27 00:00:01 7584.432 Forecast
## 453 2026-03-28 00:00:01 7585.541 Forecast
## 454 2026-03-29 00:00:01 7586.649 Forecast
## 455 2026-03-30 00:00:01 7587.758 Forecast
## 456 2026-03-31 00:00:01 7588.866 Forecast
## 457 2026-04-01 00:00:01 7589.974 Forecast
## 458 2026-04-02 00:00:01 7591.083 Forecast
## 459 2026-04-03 00:00:01 7592.191 Forecast
## 460 2026-04-04 00:00:01 7593.300 Forecast
## 461 2026-04-05 00:00:01 7594.408 Forecast
## 462 2026-04-06 00:00:01 7595.516 Forecast
## 463 2026-04-07 00:00:01 7596.625 Forecast
## 464 2026-04-08 00:00:01 7597.733 Forecast
## 465 2026-04-09 00:00:01 7598.842 Forecast
# Plot
ggplot(data_plot, aes(Tanggal, IHSG, color = Tipe)) + 
  geom_line(size = 1) + 
  labs(title = "IHSG: Data Asli dan Forecast", x = "Tanggal", y = "IHSG") +
  theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

Kurs

periode <- 100

# Forecast 100 hari untuk USDIDR
forecast_var <- predict(model_var, n.ahead = periode)
data_plot <- data.frame(
  Tanggal = c(data$Tanggal, seq(max(data$Tanggal) + 1, by = "day", length.out = periode)),
  USDIDR = c(data$USDIDR, cumsum(forecast_var$fcst$USDIDR[,1]) + tail(data$USDIDR, 1)),
  Tipe = rep(c("Asli", "Forecast"), c(nrow(data), periode))
)

tail(data_plot, periode)
##                 Tanggal   USDIDR     Tipe
## 366 2025-12-31 00:00:01 14963.67 Forecast
## 367 2026-01-01 00:00:01 14963.58 Forecast
## 368 2026-01-02 00:00:01 14963.14 Forecast
## 369 2026-01-03 00:00:01 14962.67 Forecast
## 370 2026-01-04 00:00:01 14962.20 Forecast
## 371 2026-01-05 00:00:01 14961.72 Forecast
## 372 2026-01-06 00:00:01 14961.24 Forecast
## 373 2026-01-07 00:00:01 14960.76 Forecast
## 374 2026-01-08 00:00:01 14960.28 Forecast
## 375 2026-01-09 00:00:01 14959.80 Forecast
## 376 2026-01-10 00:00:01 14959.32 Forecast
## 377 2026-01-11 00:00:01 14958.84 Forecast
## 378 2026-01-12 00:00:01 14958.36 Forecast
## 379 2026-01-13 00:00:01 14957.88 Forecast
## 380 2026-01-14 00:00:01 14957.40 Forecast
## 381 2026-01-15 00:00:01 14956.92 Forecast
## 382 2026-01-16 00:00:01 14956.45 Forecast
## 383 2026-01-17 00:00:01 14955.97 Forecast
## 384 2026-01-18 00:00:01 14955.49 Forecast
## 385 2026-01-19 00:00:01 14955.01 Forecast
## 386 2026-01-20 00:00:01 14954.53 Forecast
## 387 2026-01-21 00:00:01 14954.05 Forecast
## 388 2026-01-22 00:00:01 14953.57 Forecast
## 389 2026-01-23 00:00:01 14953.09 Forecast
## 390 2026-01-24 00:00:01 14952.61 Forecast
## 391 2026-01-25 00:00:01 14952.13 Forecast
## 392 2026-01-26 00:00:01 14951.65 Forecast
## 393 2026-01-27 00:00:01 14951.17 Forecast
## 394 2026-01-28 00:00:01 14950.69 Forecast
## 395 2026-01-29 00:00:01 14950.21 Forecast
## 396 2026-01-30 00:00:01 14949.73 Forecast
## 397 2026-01-31 00:00:01 14949.25 Forecast
## 398 2026-02-01 00:00:01 14948.78 Forecast
## 399 2026-02-02 00:00:01 14948.30 Forecast
## 400 2026-02-03 00:00:01 14947.82 Forecast
## 401 2026-02-04 00:00:01 14947.34 Forecast
## 402 2026-02-05 00:00:01 14946.86 Forecast
## 403 2026-02-06 00:00:01 14946.38 Forecast
## 404 2026-02-07 00:00:01 14945.90 Forecast
## 405 2026-02-08 00:00:01 14945.42 Forecast
## 406 2026-02-09 00:00:01 14944.94 Forecast
## 407 2026-02-10 00:00:01 14944.46 Forecast
## 408 2026-02-11 00:00:01 14943.98 Forecast
## 409 2026-02-12 00:00:01 14943.50 Forecast
## 410 2026-02-13 00:00:01 14943.02 Forecast
## 411 2026-02-14 00:00:01 14942.54 Forecast
## 412 2026-02-15 00:00:01 14942.06 Forecast
## 413 2026-02-16 00:00:01 14941.59 Forecast
## 414 2026-02-17 00:00:01 14941.11 Forecast
## 415 2026-02-18 00:00:01 14940.63 Forecast
## 416 2026-02-19 00:00:01 14940.15 Forecast
## 417 2026-02-20 00:00:01 14939.67 Forecast
## 418 2026-02-21 00:00:01 14939.19 Forecast
## 419 2026-02-22 00:00:01 14938.71 Forecast
## 420 2026-02-23 00:00:01 14938.23 Forecast
## 421 2026-02-24 00:00:01 14937.75 Forecast
## 422 2026-02-25 00:00:01 14937.27 Forecast
## 423 2026-02-26 00:00:01 14936.79 Forecast
## 424 2026-02-27 00:00:01 14936.31 Forecast
## 425 2026-02-28 00:00:01 14935.83 Forecast
## 426 2026-03-01 00:00:01 14935.35 Forecast
## 427 2026-03-02 00:00:01 14934.87 Forecast
## 428 2026-03-03 00:00:01 14934.40 Forecast
## 429 2026-03-04 00:00:01 14933.92 Forecast
## 430 2026-03-05 00:00:01 14933.44 Forecast
## 431 2026-03-06 00:00:01 14932.96 Forecast
## 432 2026-03-07 00:00:01 14932.48 Forecast
## 433 2026-03-08 00:00:01 14932.00 Forecast
## 434 2026-03-09 00:00:01 14931.52 Forecast
## 435 2026-03-10 00:00:01 14931.04 Forecast
## 436 2026-03-11 00:00:01 14930.56 Forecast
## 437 2026-03-12 00:00:01 14930.08 Forecast
## 438 2026-03-13 00:00:01 14929.60 Forecast
## 439 2026-03-14 00:00:01 14929.12 Forecast
## 440 2026-03-15 00:00:01 14928.64 Forecast
## 441 2026-03-16 00:00:01 14928.16 Forecast
## 442 2026-03-17 00:00:01 14927.68 Forecast
## 443 2026-03-18 00:00:01 14927.21 Forecast
## 444 2026-03-19 00:00:01 14926.73 Forecast
## 445 2026-03-20 00:00:01 14926.25 Forecast
## 446 2026-03-21 00:00:01 14925.77 Forecast
## 447 2026-03-22 00:00:01 14925.29 Forecast
## 448 2026-03-23 00:00:01 14924.81 Forecast
## 449 2026-03-24 00:00:01 14924.33 Forecast
## 450 2026-03-25 00:00:01 14923.85 Forecast
## 451 2026-03-26 00:00:01 14923.37 Forecast
## 452 2026-03-27 00:00:01 14922.89 Forecast
## 453 2026-03-28 00:00:01 14922.41 Forecast
## 454 2026-03-29 00:00:01 14921.93 Forecast
## 455 2026-03-30 00:00:01 14921.45 Forecast
## 456 2026-03-31 00:00:01 14920.97 Forecast
## 457 2026-04-01 00:00:01 14920.49 Forecast
## 458 2026-04-02 00:00:01 14920.02 Forecast
## 459 2026-04-03 00:00:01 14919.54 Forecast
## 460 2026-04-04 00:00:01 14919.06 Forecast
## 461 2026-04-05 00:00:01 14918.58 Forecast
## 462 2026-04-06 00:00:01 14918.10 Forecast
## 463 2026-04-07 00:00:01 14917.62 Forecast
## 464 2026-04-08 00:00:01 14917.14 Forecast
## 465 2026-04-09 00:00:01 14916.66 Forecast
# Plot
ggplot(data_plot, aes(Tanggal, USDIDR, color = Tipe)) + 
  geom_line(size = 1) + 
  labs(title = "USD/IDR: Data Asli dan Forecast", 
       x = "Tanggal", y = "USD/IDR") +
  theme_minimal()

harga Minyak

periode <- 100

# Forecast 100 hari untuk Minyak Brent
forecast_var <- predict(model_var, n.ahead = periode)
data_plot <- data.frame(
  Tanggal = c(data$Tanggal, seq(max(data$Tanggal) + 1, by = "day", length.out = periode)),
  Minyak_Brent = c(data$Minyak_Brent, cumsum(forecast_var$fcst$Minyak_Brent[,1]) + tail(data$Minyak_Brent, 1)),
  Tipe = rep(c("Asli", "Forecast"), c(nrow(data), periode))
)

tail(data_plot, periode)
##                 Tanggal Minyak_Brent     Tipe
## 366 2025-12-31 00:00:01     80.10433 Forecast
## 367 2026-01-01 00:00:01     80.11112 Forecast
## 368 2026-01-02 00:00:01     80.11616 Forecast
## 369 2026-01-03 00:00:01     80.12077 Forecast
## 370 2026-01-04 00:00:01     80.12530 Forecast
## 371 2026-01-05 00:00:01     80.12981 Forecast
## 372 2026-01-06 00:00:01     80.13432 Forecast
## 373 2026-01-07 00:00:01     80.13883 Forecast
## 374 2026-01-08 00:00:01     80.14335 Forecast
## 375 2026-01-09 00:00:01     80.14786 Forecast
## 376 2026-01-10 00:00:01     80.15237 Forecast
## 377 2026-01-11 00:00:01     80.15688 Forecast
## 378 2026-01-12 00:00:01     80.16139 Forecast
## 379 2026-01-13 00:00:01     80.16591 Forecast
## 380 2026-01-14 00:00:01     80.17042 Forecast
## 381 2026-01-15 00:00:01     80.17493 Forecast
## 382 2026-01-16 00:00:01     80.17944 Forecast
## 383 2026-01-17 00:00:01     80.18395 Forecast
## 384 2026-01-18 00:00:01     80.18846 Forecast
## 385 2026-01-19 00:00:01     80.19298 Forecast
## 386 2026-01-20 00:00:01     80.19749 Forecast
## 387 2026-01-21 00:00:01     80.20200 Forecast
## 388 2026-01-22 00:00:01     80.20651 Forecast
## 389 2026-01-23 00:00:01     80.21102 Forecast
## 390 2026-01-24 00:00:01     80.21553 Forecast
## 391 2026-01-25 00:00:01     80.22005 Forecast
## 392 2026-01-26 00:00:01     80.22456 Forecast
## 393 2026-01-27 00:00:01     80.22907 Forecast
## 394 2026-01-28 00:00:01     80.23358 Forecast
## 395 2026-01-29 00:00:01     80.23809 Forecast
## 396 2026-01-30 00:00:01     80.24260 Forecast
## 397 2026-01-31 00:00:01     80.24712 Forecast
## 398 2026-02-01 00:00:01     80.25163 Forecast
## 399 2026-02-02 00:00:01     80.25614 Forecast
## 400 2026-02-03 00:00:01     80.26065 Forecast
## 401 2026-02-04 00:00:01     80.26516 Forecast
## 402 2026-02-05 00:00:01     80.26968 Forecast
## 403 2026-02-06 00:00:01     80.27419 Forecast
## 404 2026-02-07 00:00:01     80.27870 Forecast
## 405 2026-02-08 00:00:01     80.28321 Forecast
## 406 2026-02-09 00:00:01     80.28772 Forecast
## 407 2026-02-10 00:00:01     80.29223 Forecast
## 408 2026-02-11 00:00:01     80.29675 Forecast
## 409 2026-02-12 00:00:01     80.30126 Forecast
## 410 2026-02-13 00:00:01     80.30577 Forecast
## 411 2026-02-14 00:00:01     80.31028 Forecast
## 412 2026-02-15 00:00:01     80.31479 Forecast
## 413 2026-02-16 00:00:01     80.31930 Forecast
## 414 2026-02-17 00:00:01     80.32382 Forecast
## 415 2026-02-18 00:00:01     80.32833 Forecast
## 416 2026-02-19 00:00:01     80.33284 Forecast
## 417 2026-02-20 00:00:01     80.33735 Forecast
## 418 2026-02-21 00:00:01     80.34186 Forecast
## 419 2026-02-22 00:00:01     80.34637 Forecast
## 420 2026-02-23 00:00:01     80.35089 Forecast
## 421 2026-02-24 00:00:01     80.35540 Forecast
## 422 2026-02-25 00:00:01     80.35991 Forecast
## 423 2026-02-26 00:00:01     80.36442 Forecast
## 424 2026-02-27 00:00:01     80.36893 Forecast
## 425 2026-02-28 00:00:01     80.37345 Forecast
## 426 2026-03-01 00:00:01     80.37796 Forecast
## 427 2026-03-02 00:00:01     80.38247 Forecast
## 428 2026-03-03 00:00:01     80.38698 Forecast
## 429 2026-03-04 00:00:01     80.39149 Forecast
## 430 2026-03-05 00:00:01     80.39600 Forecast
## 431 2026-03-06 00:00:01     80.40052 Forecast
## 432 2026-03-07 00:00:01     80.40503 Forecast
## 433 2026-03-08 00:00:01     80.40954 Forecast
## 434 2026-03-09 00:00:01     80.41405 Forecast
## 435 2026-03-10 00:00:01     80.41856 Forecast
## 436 2026-03-11 00:00:01     80.42307 Forecast
## 437 2026-03-12 00:00:01     80.42759 Forecast
## 438 2026-03-13 00:00:01     80.43210 Forecast
## 439 2026-03-14 00:00:01     80.43661 Forecast
## 440 2026-03-15 00:00:01     80.44112 Forecast
## 441 2026-03-16 00:00:01     80.44563 Forecast
## 442 2026-03-17 00:00:01     80.45015 Forecast
## 443 2026-03-18 00:00:01     80.45466 Forecast
## 444 2026-03-19 00:00:01     80.45917 Forecast
## 445 2026-03-20 00:00:01     80.46368 Forecast
## 446 2026-03-21 00:00:01     80.46819 Forecast
## 447 2026-03-22 00:00:01     80.47270 Forecast
## 448 2026-03-23 00:00:01     80.47722 Forecast
## 449 2026-03-24 00:00:01     80.48173 Forecast
## 450 2026-03-25 00:00:01     80.48624 Forecast
## 451 2026-03-26 00:00:01     80.49075 Forecast
## 452 2026-03-27 00:00:01     80.49526 Forecast
## 453 2026-03-28 00:00:01     80.49977 Forecast
## 454 2026-03-29 00:00:01     80.50429 Forecast
## 455 2026-03-30 00:00:01     80.50880 Forecast
## 456 2026-03-31 00:00:01     80.51331 Forecast
## 457 2026-04-01 00:00:01     80.51782 Forecast
## 458 2026-04-02 00:00:01     80.52233 Forecast
## 459 2026-04-03 00:00:01     80.52684 Forecast
## 460 2026-04-04 00:00:01     80.53136 Forecast
## 461 2026-04-05 00:00:01     80.53587 Forecast
## 462 2026-04-06 00:00:01     80.54038 Forecast
## 463 2026-04-07 00:00:01     80.54489 Forecast
## 464 2026-04-08 00:00:01     80.54940 Forecast
## 465 2026-04-09 00:00:01     80.55392 Forecast
# Plot
ggplot(data_plot, aes(Tanggal, Minyak_Brent, color = Tipe)) + 
  geom_line(size = 1) + 
  labs(title = "Harga Minyak Brent: Data Asli dan Forecast", 
       x = "Tanggal", y = "USD/Barrel") +
  theme_minimal()

Daftar Pustaka

Box, G. E. P., Jenkins, G. M., Reinsel, G. C., & Ljung, G. M. (2015). Time Series Analysis: Forecasting and Control (5th ed.). Wiley.

Enders, W. (2015). Applied Econometric Time Series (4th ed.). Wiley.

Hamilton, J. D. (1994). Time Series Analysis. Princeton University Press.

Lütkepohl, H. (2005). New Introduction to Multiple Time Series Analysis. Springer.

Stock, J. H., & Watson, M. W. (2015). Introduction to Econometrics (3rd ed.). Pearson.

Gujarati, D. N., & Porter, D. C. (2009). Basic Econometrics (5th ed.). McGraw-Hill.

Wooldridge, J. M. (2013). Introductory Econometrics: A Modern Approach (5th ed.). South-Western.

Tsay, R. S. (2010). Analysis of Financial Time Series (3rd ed.). Wiley.

Hyndman, R. J., & Athanasopoulos, G. (2021). Forecasting: Principles and Practice (3rd ed.). OTexts. https://otexts.com/fpp3/

Pfaff, B. (2008). Analysis of Integrated and Cointegrated Time Series with R. Springer.