title: “Analisis Regresi Data Panel Statis: Data WDI 15 Negara”

author: “Afrodita E. Pendong”

date: “2026-11-19”

output:

html_document:

toc: true

toc_depth: 3

toc_float: 

  collapsed: false

  smooth_scroll: true

theme: flatly

highlight: tango

number_sections: true

code_folding: show

1 Persiapan Lingkungan dan Import Data

Pada tahap ini dilakukan pemanggilan paket (library) yang dibutuhkan, pembacaan file Excel WDI, serta transformasi struktur data dari format melebar (wide) menjadi format panel (long).

library(plm)       # Regresi data panel, uji CD, CIPS, Hausman, Chow, LM

library(lmtest)    # Uji heteroskedastisitas & autokorelasi

library(sandwich)  # Estimasi Robust Standard Error (Driscoll-Kraay / Arellano)

library(car)       # Uji multikolinearitas (VIF)

library(tseries)   # Uji normalitas Jarque-Bera

library(readxl)    # Membaca file Excel (.xlsx)

library(tidyr)     # Mengubah bentuk data (Wide ke Long Panel Format)

library(dplyr)     # Manipulasi dan pembersihan data

library(knitr)     # Menyajikan tabel output HTML yang rapi
file_path <- "C:/Users/User/Downloads/Data WDI 15 Negara.xlsx"



# Membaca Excel (na = ".." otomatis mengubah simbol kosong WDI menjadi NA)

data_raw <- read_excel(file_path, sheet = 1, na = "..")



# Pembersihan dan konversi Wide Format ke Long Panel Format

data_panel <- data_raw %>%

  filter(!is.na(Negara), !is.na(Indikator)) %>%

  mutate(across(`2000`:`2024`, ~ as.numeric(as.character(.)))) %>%

  pivot_longer(

    cols = `2000`:`2024`,

    names_to = "Tahun",

    values_to = "Nilai"

  ) %>%

  mutate(Tahun = as.numeric(Tahun)) %>%

  pivot_wider(

    names_from = Indikator,

    values_from = Nilai,

    values_fn = ~ mean(.x, na.rm = TRUE)

  ) %>%

  as.data.frame()



# Penamaan variabel bersih (Y, X1, X2, ...) & pembuatan tabel kamus

indikator_asli <- setdiff(names(data_panel), c("Negara", "Tahun"))

urutan_Y <- 1  # Ubah angka ini jika variabel Y bukan indikator pertama



nama_Y_asli <- indikator_asli[urutan_Y]

nama_X_asli <- indikator_asli[-urutan_Y]

kode_X <- paste0("X", seq_along(nama_X_asli))

kode_semua <- c("Y", kode_X)



kamus_variabel <- data.frame(

  Kode = kode_semua,

  Indikator_WDI = c(nama_Y_asli, nama_X_asli),

  Peran = c("Variabel Dependen (Y)", rep("Variabel Independen (X)", length(kode_X)))

)



kable(kamus_variabel, caption = "Tabel 1. Kamus Kode Variabel Penelitian")
Tabel 1. Kamus Kode Variabel Penelitian
Kode Indikator_WDI Peran
Y Gross fixed capital formation (% of GDP) Variabel Dependen (Y)
X1 Employment in agriculture (% of total employment) (modeled ILO estimate) Variabel Independen (X)
X2 Deposit interest rate (%) Variabel Independen (X)
X3 Total natural resources rents (% of GDP) Variabel Independen (X)

1.1 Pemeriksaan Kelengkapan Observasi per Negara

data_bersih <- data_panel[, c("Negara", "Tahun", nama_Y_asli, nama_X_asli)]

names(data_bersih) <- c("Negara", "Tahun", kode_semua)



ringkasan_negara <- data_bersih %>%

  group_by(Negara) %>%

  summarise(

    Total_Tahun = n(),

    Observasi_Lengkap = sum(complete.cases(across(all_of(kode_semua)))),

    Status = ifelse(Observasi_Lengkap > 0, "Masuk Estimasi", "Tereliminasi (Data Kosong)")

  )



kable(ringkasan_negara, caption = "Tabel 2. Kelengkapan Data Observasi per Negara (2000-2024)")
Tabel 2. Kelengkapan Data Observasi per Negara (2000-2024)
Negara Total_Tahun Observasi_Lengkap Status
China 25 22 Masuk Estimasi
India 25 0 Tereliminasi (Data Kosong)
Indonesia 25 22 Masuk Estimasi
Japan 25 18 Masuk Estimasi
Korea, Rep. 25 22 Masuk Estimasi
Malaysia 25 22 Masuk Estimasi
Mongolia 25 22 Masuk Estimasi
Nepal 25 0 Tereliminasi (Data Kosong)
Philippines 25 20 Masuk Estimasi
Qatar 25 0 Tereliminasi (Data Kosong)
Saudi Arabia 25 0 Tereliminasi (Data Kosong)
Singapore 25 22 Masuk Estimasi
Thailand 25 20 Masuk Estimasi
Turkiye 25 22 Masuk Estimasi
Viet Nam 25 22 Masuk Estimasi
# Deklarasi struktur panel dan formula regresi

pdata <- pdata.frame(data_bersih, index = c("Negara", "Tahun"))

pdim(pdata)
Balanced Panel: n = 15, T = 25, N = 375
model_formula <- as.formula(paste0("Y ~ ", paste0(kode_X, collapse = " + ")))

1.2 Statistik Deskriptif

sampel_estimasi <- data_bersih %>% filter(complete.cases(across(all_of(kode_semua))))



stat_desc <- data.frame(

  Variabel = kode_semua,

  N = sapply(sampel_estimasi[kode_semua], length),

  Mean = round(sapply(sampel_estimasi[kode_semua], mean), 4),

  Std_Dev = round(sapply(sampel_estimasi[kode_semua], sd), 4),

  Min = round(sapply(sampel_estimasi[kode_semua], min), 4),

  Median = round(sapply(sampel_estimasi[kode_semua], median), 4),

  Max = round(sapply(sampel_estimasi[kode_semua], max), 4)

)



kable(stat_desc, row.names = FALSE, caption = "Tabel 3. Statistik Deskriptif Variabel Penelitian")
Tabel 3. Statistik Deskriptif Variabel Penelitian
Variabel N Mean Std_Dev Min Median Max
Y 234 27.9582 6.1125 18.0765 27.2528 48.4123
X1 234 25.5568 16.8891 0.1078 29.0540 64.2068
X2 234 6.3260 8.4284 0.0356 3.3271 74.6992
X3 234 4.6509 6.6936 0.0002 1.9488 42.2167

2 Uji Ketergantungan Lintas Negara (CD) dan Heterogenitas Slope

2.1 Uji Cross-Sectional Dependence (Pesaran CD & Breusch-Pagan LM)

cd_pesaran <- pcdtest(model_formula, data = pdata, test = "cd")

cd_lm      <- pcdtest(model_formula, data = pdata, test = "lm")



tabel_cd <- data.frame(

  Metode_Uji = c("Pesaran CD Test", "Breusch-Pagan LM Test"),

  Statistik = round(c(cd_pesaran$statistic, cd_lm$statistic), 4),

  P_Value = format.pval(c(cd_pesaran$p.value, cd_lm$p.value), digits = 4),

  Kesimpulan = ifelse(

    c(cd_pesaran$p.value, cd_lm$p.value) < 0.05,

    "Terdapat Cross-Sectional Dependence (Signifikan)",

    "Tidak Ada Cross-Sectional Dependence (Independen)"

  )

)



kable(tabel_cd, row.names = FALSE, caption = "Tabel 4. Hasil Uji Cross-Sectional Dependence")
Tabel 4. Hasil Uji Cross-Sectional Dependence
Metode_Uji Statistik P_Value Kesimpulan
Pesaran CD Test -1.3254 0.185 Tidak Ada Cross-Sectional Dependence (Independen)
Breusch-Pagan LM Test 106.6902 3.678e-05 Terdapat Cross-Sectional Dependence (Signifikan)

2.2 Uji Heterogenitas Slope (Poolability & Swamy Test)

uji_pool <- pooltest(model_formula, data = pdata, model = "within")

pvcm_model <- pvcm(model_formula, data = pdata, model = "random")

sum_pvcm <- summary(pvcm_model)



print(uji_pool)

    F statistic

data:  model_formula
F = 6.1119, df1 = 30, df2 = 190, p-value = 1.206e-15
alternative hypothesis: unstability
print(sum_pvcm)
Oneway (individual) effect Random coefficients model

Call:
pvcm(formula = model_formula, data = pdata, model = "random")

Unbalanced Panel: n = 11, T = 18-22, N = 234

Residuals:
    Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
-354.417  -61.581  -20.711  -43.965   -6.187    5.226 

Estimated mean of the coefficients:
            Estimate Std. Error z-value  Pr(>|z|)    
(Intercept) 30.93443    4.77704  6.4756 9.441e-11 ***
X1          -0.10983    0.49194 -0.2233    0.8233    
X2           0.45388    0.64338  0.7055    0.4805    
X3           8.79926   16.30122  0.5398    0.5893    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Estimated variance of the coefficients:
            (Intercept)      X1       X2       X3
(Intercept)    236.7007 -7.7732  -3.0688 -344.358
X1              -7.7732  2.5116  -2.5133   42.910
X2              -3.0688 -2.5133   4.1876  -42.603
X3            -344.3577 42.9097 -42.6027 2745.063

Total Sum of Squares: 209020
Residual Sum of Squares: 1236100
Multiple R-Squared: -4.914
Chisq: 1.27878 on 3 DF, p-value: 0.73418
Test for parameter homogeneity: Chisq = 3477.58 on 40 DF, p-value: < 2.22e-16

3 Uji Stasioneritas Panel Generasi Kedua (Pesaran CIPS)

hasil_cips <- lapply(kode_semua, function(v) {

  cips_lvl  <- cipstest(pdata[[v]], lags = 2, type = "drift")

  cips_diff <- cipstest(diff(pdata[[v]]), lags = 2, type = "drift")

  

  data.frame(

    Variabel = v,

    Stat_Level = round(cips_lvl$statistic, 4),

    PVal_Level = round(cips_lvl$p.value, 4),

    Status_Level = ifelse(cips_lvl$p.value < 0.05, "Stasioner I(0)", "Tidak Stasioner"),

    Stat_Diff1 = round(cips_diff$statistic, 4),

    PVal_Diff1 = round(cips_diff$p.value, 4),

    Status_Diff1 = ifelse(cips_diff$p.value < 0.05, "Stasioner I(1)", "Tidak Stasioner")

  )

}) %>% bind_rows()



kable(hasil_cips, caption = "Tabel 5. Rangkuman Uji Stasioneritas Panel Pesaran CIPS")
Tabel 5. Rangkuman Uji Stasioneritas Panel Pesaran CIPS
Variabel Stat_Level PVal_Level Status_Level Stat_Diff1 PVal_Diff1 Status_Diff1
CIPS test…1 Y -1.9623 0.1 Tidak Stasioner -2.0521 0.1000 Tidak Stasioner
CIPS test…2 X1 -1.5972 0.1 Tidak Stasioner -1.9325 0.1000 Tidak Stasioner
CIPS test…3 X2 -1.3232 0.1 Tidak Stasioner -2.5033 0.0205 Stasioner I(1)
CIPS test…4 X3 -1.1631 0.1 Tidak Stasioner -2.3437 0.0370 Stasioner I(1)

4 Estimasi Model Regresi Panel Statis (CEM, FEM, REM)

cem <- plm(model_formula, data = pdata, model = "pooling")

fem <- plm(model_formula, data = pdata, model = "within")

rem <- plm(model_formula, data = pdata, model = "random")



cat("=== 1. COMMON EFFECT MODEL (CEM) ===\n")
=== 1. COMMON EFFECT MODEL (CEM) ===
summary(cem)
Pooling Model

Call:
plm(formula = model_formula, data = pdata, model = "pooling")

Unbalanced Panel: n = 11, T = 18-22, N = 234

Residuals:
   Min. 1st Qu.  Median 3rd Qu.    Max. 
-10.005  -4.121  -0.459   3.614  15.557 

Coefficients:
             Estimate Std. Error t-value  Pr(>|t|)    
(Intercept) 26.735696   0.713379 37.4775 < 2.2e-16 ***
X1           0.057158   0.026395  2.1655  0.031381 *  
X2          -0.133543   0.048303 -2.7647  0.006159 ** 
X3           0.130412   0.064050  2.0361  0.042886 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:    8705.5
Residual Sum of Squares: 8064
R-Squared:      0.073688
Adj. R-Squared: 0.061606
F-statistic: 6.09881 on 3 and 230 DF, p-value: 0.00052105
cat("\n=== 2. FIXED EFFECT MODEL (FEM) ===\n")

=== 2. FIXED EFFECT MODEL (FEM) ===
summary(fem)
Oneway (individual) effect Within Model

Call:
plm(formula = model_formula, data = pdata, model = "within")

Unbalanced Panel: n = 11, T = 18-22, N = 234

Residuals:
    Min.  1st Qu.   Median  3rd Qu.     Max. 
-10.8863  -1.5839  -0.0682   1.6895  13.5473 

Coefficients:
    Estimate Std. Error t-value  Pr(>|t|)    
X1 -0.191478   0.039391 -4.8609 2.222e-06 ***
X2 -0.143087   0.046021 -3.1092  0.002124 ** 
X3  0.362574   0.055984  6.4763 6.054e-10 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:    3000.7
Residual Sum of Squares: 2140.8
R-Squared:      0.28656
Adj. R-Squared: 0.2444
F-statistic: 29.4553 on 3 and 220 DF, p-value: 4.7556e-16
cat("\n=== 3. RANDOM EFFECT MODEL (REM) ===\n")

=== 3. RANDOM EFFECT MODEL (REM) ===
summary(rem)
Oneway (individual) effect Random Effect Model 
   (Swamy-Arora's transformation)

Call:
plm(formula = model_formula, data = pdata, model = "random")

Unbalanced Panel: n = 11, T = 18-22, N = 234

Effects:
                 var std.dev share
idiosyncratic  9.731   3.119 0.222
individual    34.113   5.841 0.778
theta:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.8751  0.8869  0.8869  0.8850  0.8869  0.8869 

Residuals:
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
-10.57539  -1.73041  -0.01361   0.00744   1.79855  13.65333 

Coefficients:
             Estimate Std. Error z-value  Pr(>|z|)    
(Intercept) 31.375516   1.989225 15.7727 < 2.2e-16 ***
X1          -0.167271   0.037607 -4.4479 8.671e-06 ***
X2          -0.148625   0.045451 -3.2700  0.001076 ** 
X3           0.359311   0.055549  6.4684 9.905e-11 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:    3067.7
Residual Sum of Squares: 2258
R-Squared:      0.26398
Adj. R-Squared: 0.25438
Chisq: 83.2666 on 3 DF, p-value: < 2.22e-16

5 Pemilihan Model Terbaik (Chow, Hausman, Lagrange Multiplier)

chow_test    <- pFtest(fem, cem)

hausman_test <- phtest(fem, rem)

lm_test      <- plmtest(cem, type = "bp")



if (chow_test$p.value < 0.05) {

  if (hausman_test$p.value < 0.05) {

    nama_terpilih <- "Fixed Effect Model (FEM)"

    model_terpilih <- fem

  } else {

    nama_terpilih <- "Random Effect Model (REM)"

    model_terpilih <- rem

  }

} else {

  if (lm_test$p.value < 0.05) {

    nama_terpilih <- "Random Effect Model (REM)"

    model_terpilih <- rem

  } else {

    nama_terpilih <- "Common Effect Model (CEM)"

    model_terpilih <- cem

  }

}



tabel_pemilihan <- data.frame(

  Tahap_Uji = c("1. Uji Chow (CEM vs FEM)", "2. Uji Hausman (REM vs FEM)", "3. Uji Breusch-Pagan LM (CEM vs REM)"),

  Statistik = round(c(chow_test$statistic, hausman_test$statistic, lm_test$statistic), 4),

  P_Value = format.pval(c(chow_test$p.value, hausman_test$p.value, lm_test$p.value), digits = 4),

  Rekomendasi = c(

    ifelse(chow_test$p.value < 0.05, "Fixed Effect (FEM)", "Common Effect (CEM)"),

    ifelse(hausman_test$p.value < 0.05, "Fixed Effect (FEM)", "Random Effect (REM)"),

    ifelse(lm_test$p.value < 0.05, "Random Effect (REM)", "Common Effect (CEM)")

  )

)



kable(tabel_pemilihan, row.names = FALSE, caption = "Tabel 6. Rangkuman Uji Pemilihan Model Terbaik")
Tabel 6. Rangkuman Uji Pemilihan Model Terbaik
Tahap_Uji Statistik P_Value Rekomendasi
1. Uji Chow (CEM vs FEM) 60.8708 < 2e-16 Fixed Effect (FEM)
2. Uji Hausman (REM vs FEM) 6.6667 0.08332 Random Effect (REM)
3. Uji Breusch-Pagan LM (CEM vs REM) 1002.6720 < 2e-16 Random Effect (REM)
cat("\n>>> KESIMPULAN MODEL TERPILIH OTOMATIS:", nama_terpilih, "<<<\n")

>>> KESIMPULAN MODEL TERPILIH OTOMATIS: Random Effect Model (REM) <<<

6 Uji Asumsi Klasik pada Model Terpilih

# 1. Multikolinearitas (VIF)

ols_vif <- lm(model_formula, data = sampel_estimasi)

nilai_vif <- vif(ols_vif)



tabel_vif <- data.frame(

  Variabel = names(nilai_vif),

  VIF = round(nilai_vif, 4),

  Keterangan = ifelse(nilai_vif < 10, "Bebas Multikolinearitas (VIF < 10)", "Terindikasi Multikolinearitas")

)

kable(tabel_vif, row.names = FALSE, caption = "Tabel 7. Hasil Uji Multikolinearitas (VIF)")
Tabel 7. Hasil Uji Multikolinearitas (VIF)
Variabel VIF Keterangan
X1 1.3207 Bebas Multikolinearitas (VIF < 10)
X2 1.1014 Bebas Multikolinearitas (VIF < 10)
X3 1.2215 Bebas Multikolinearitas (VIF < 10)
# 2. Normalitas, Heteroskedastisitas, dan Autokorelasi

jb_test <- jarque.bera.test(residuals(model_terpilih))

bp_test <- bptest(model_formula, data = pdata, studentize = FALSE)

bg_test <- pbgtest(model_terpilih)



tabel_asumsi <- data.frame(

  Jenis_Uji = c(

    "Normalitas Residual (Jarque-Bera)",

    "Heteroskedastisitas (Breusch-Pagan)",

    "Autokorelasi (Breusch-Godfrey / Wooldridge)"

  ),

  Statistik = round(c(jb_test$statistic, bp_test$statistic, bg_test$statistic), 4),

  P_Value = format.pval(c(jb_test$p.value, bp_test$p.value, bg_test$p.value), digits = 4),

  Status_Asumsi = ifelse(

    c(jb_test$p.value, bp_test$p.value, bg_test$p.value) > 0.05,

    "Terpenuhi (Lolos Uji)",

    "Terlanggar (Perlu Estimasi Robust)"

  )

)



kable(tabel_asumsi, row.names = FALSE, caption = paste("Tabel 8. Hasil Uji Asumsi Klasik pada", nama_terpilih))
Tabel 8. Hasil Uji Asumsi Klasik pada Random Effect Model (REM)
Jenis_Uji Statistik P_Value Status_Asumsi
Normalitas Residual (Jarque-Bera) 42.7918 5.104e-10 Terlanggar (Perlu Estimasi Robust)
Heteroskedastisitas (Breusch-Pagan) 19.6975 0.0001961 Terlanggar (Perlu Estimasi Robust)
Autokorelasi (Breusch-Godfrey / Wooldridge) 137.2654 < 2.2e-16 Terlanggar (Perlu Estimasi Robust)

7 Estimasi Akhir dengan Robust Standard Errors

# 1. Robust Arellano

rob_arellano <- coeftest(model_terpilih, vcov = vcovHC(model_terpilih, method = "arellano", type = "HC3"))



# 2. Robust Driscoll-Kraay

rob_dk <- coeftest(model_terpilih, vcov = vcovSCC(model_terpilih, type = "HC3"))



cat("=== ESTIMASI ROBUST ARELLANO (", nama_terpilih, ") ===\n", sep = "")
=== ESTIMASI ROBUST ARELLANO (Random Effect Model (REM)) ===
print(rob_arellano)

t test of coefficients:

             Estimate Std. Error t value  Pr(>|t|)    
(Intercept) 31.375516   3.386714  9.2643 < 2.2e-16 ***
X1          -0.167271   0.092563 -1.8071 0.0720537 .  
X2          -0.148625   0.036652 -4.0551 6.863e-05 ***
X3           0.359311   0.098919  3.6324 0.0003463 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
cat("\n=== ESTIMASI ROBUST DRISCOLL-KRAAY (", nama_terpilih, ") ===\n", sep = "")

=== ESTIMASI ROBUST DRISCOLL-KRAAY (Random Effect Model (REM)) ===
print(rob_dk)

t test of coefficients:

             Estimate Std. Error t value  Pr(>|t|)    
(Intercept) 31.375516   2.567349 12.2210 < 2.2e-16 ***
X1          -0.167271   0.048085 -3.4786 0.0006026 ***
X2          -0.148625   0.039344 -3.7776 0.0002017 ***
X3           0.359311   0.137795  2.6076 0.0097152 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tabel_akhir <- data.frame(

  Variabel = rownames(rob_dk),

  Koefisien = round(rob_dk[, 1], 4),

  Robust_Std_Error = round(rob_dk[, 2], 4),

  T_Statistik = round(rob_dk[, 3], 4),

  P_Value = round(rob_dk[, 4], 4),

  Signifikansi = ifelse(rob_dk[, 4] < 0.01, "Signifikan (1%)",

                 ifelse(rob_dk[, 4] < 0.05, "Signifikan (5%)",

                 ifelse(rob_dk[, 4] < 0.10, "Signifikan (10%)", "Tidak Signifikan")))

)



kable(tabel_akhir, row.names = FALSE, caption = paste("Tabel 9. Hasil Akhir Regresi Robust Driscoll-Kraay -", nama_terpilih))
Tabel 9. Hasil Akhir Regresi Robust Driscoll-Kraay - Random Effect Model (REM)
Variabel Koefisien Robust_Std_Error T_Statistik P_Value Signifikansi
(Intercept) 31.3755 2.5673 12.2210 0.0000 Signifikan (1%)
X1 -0.1673 0.0481 -3.4786 0.0006 Signifikan (1%)
X2 -0.1486 0.0393 -3.7776 0.0002 Signifikan (1%)
X3 0.3593 0.1378 2.6076 0.0097 Signifikan (1%)