title: “Analisis Regresi Data Panel (WDI 15 Negara)”

author: “Brithney Manopo”

date: “2026-11-19”

output:

html_document:

toc: true

toc_float: true

theme: cosmo

highlight: tango

pkgs <- c("readxl", "dplyr", "tidyr", "plm", "lmtest", "car", "tseries", "knitr")

for (p in pkgs) if (!requireNamespace(p, quietly = TRUE)) install.packages(p)

library(readxl); library(dplyr); library(tidyr); library(plm); library(lmtest); library(car); library(tseries); library(knitr)

file_path <- "C:/Users/a s u s/Downloads/Data WDI 15 Negara.xlsx"

if (!file.exists(file_path)) file_path <- file.choose()

tmp_xlsx <- tempfile(fileext = ".xlsx")

file.copy(file_path, tmp_xlsx, overwrite = TRUE)

[1] TRUE

sheets_avail <- excel_sheets(tmp_xlsx)

target_sheet <- if ("Data" %in% sheets_avail) "Data" else sheets_avail[1]

raw_scan <- read_excel(tmp_xlsx, sheet = target_sheet, col_names = FALSE)

hdr_row <- which(apply(raw_scan, 1, function(r) grepl("Country|Series|Indicator|Tahun|Year|2000|2001|2010|2020", paste(na.omit(as.character(r)), collapse = " "), ignore.case = TRUE)))[1]

if (is.na(hdr_row)) hdr_row <- 1

raw_data <- read_excel(tmp_xlsx, sheet = target_sheet, skip = hdr_row - 1)

raw_data <- raw_data[, !grepl("^\\.\\.\\.[0-9]+$", names(raw_data)) | apply(raw_data, 2, function(c) any(!is.na(c)))]

cat("## 1. Tampilan Data Mentah & Struktur Awal\n\n")

1. Tampilan Data Mentah & Struktur Awal

cat("- **Sheet Aktif:** `", target_sheet, "` | **Baris Awal:** ", nrow(raw_data), " | **Kolom Awal:** ", ncol(raw_data), "\n\n")
  • Sheet Aktif: Data | Baris Awal: 65 | Kolom Awal: 27
print(kable(head(raw_data, 8), digits = 4, caption = "Cuplikan 8 Baris Pertama Data Mentah Excel"))
Cuplikan 8 Baris Pertama Data Mentah Excel
Negara Indikator 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024
Indonesia Domestic credit to private sector (% of GDP) .. .. .. .. .. .. .. .. .. 27.6587 27.2530 30.0822 33.4342 36.0581 36.4235 39.1188 39.4024 38.7323 38.805449666563831 38.372693951660935 38.679539089145287 36.990827055625317 35.288432963268846 36.012951258869037 36.392406709514056
Indonesia Employment in services (% of total employment) (modeled ILO estimate) 38.352998056901001 38.612238771833802 38.0265807831709 36.983998538692298 39.788658362821202 38.364835090415198 40.503824263964702 41.1092215565331 41.210525183387702 42.0006 42.9721 43.5903 43.7825 44.2425 44.4970 45.1011 46.6339 47.3558 48.168762274452902 49.135632900147499 49.056846345277101 49.2513693430476 48.847168554459202 49.2692149419358 49.753752667753602
Indonesia Mortality rate, under-5 (per 1,000 live births) 51.4 49 46.7 44.6 48.6 40.700000000000003 38.9 37.200000000000003 35.6 34.1000 32.6000 31.2000 29.9000 28.6000 27.3000 26.1000 25.0000 23.8000 22.8 21.8 20.8 19.899999999999999 19.100000000000001 18.399999999999999 17.7
Indonesia Agricultural land (% of land area) 23.764340067930071 24.202684500130225 24.522255167590849 24.788564057141365 24.837367824240395 24.939433369249524 25.520854915449593 26.049014683739554 26.204342006658788 26.5727 26.5683 27.0964 27.0920 27.3538 27.5091 27.6112 27.8731 27.7599 28.411834980098739 28.750329557250819 28.96499050076191 28.955848781541921 29.007381817864786 28.905172451284066 28.933374430838221
Japan Domestic credit to private sector (% of GDP) 205.74957655097177 177.60004048631029 175.27391532686138 175.44585013008009 169.10028746763442 169.44439482144281 167.53837644246957 161.49252136222432 159.38351800694247 166.6337 158.5368 157.8460 157.9136 161.2470 160.8807 159.3376 160.5418 165.3776 164.29156633491669 172.1615037825398 189.48144870075211 187.9810756791513 186.54834684731048 186.42343835476348 187.97215818966743
Japan Employment in services (% of total employment) (modeled ILO estimate) 64.1185656445506 65.122478810294893 66.219783125694505 66.302120093188705 67.238696018052195 67.841607204856103 67.887146650735801 68.121489386786294 68.652490446501005 69.3381 70.0547 70.4131 70.6286 70.9248 71.0613 71.3122 71.7448 71.8208 72.038844415274696 72.398807561451903 72.811017042505199 73.136394730663497 73.282831534033704 73.286015838644204 73.772706405057903
Japan Mortality rate, under-5 (per 1,000 live births) 4.5 4.3 4.0999999999999996 4 3.9 3.7 3.6 3.5 3.4 3.4000 3.3000 3.3000 3.1000 3.0000 2.9000 2.8000 2.7000 2.6000 2.5 2.5 2.4 2.4 2.4 2.4 2.4
Japan Agricultural land (% of land area) 14.425240054869684 14.301783264746229 14.19753086419753 14.101508916323732 14.01920438957476 13.936899862825788 13.863923182441701 13.790946502057613 13.715226337448561 13.6477 13.5885 13.4952 13.4568 13.4211 13.3608 13.2949 13.2044 13.1084 13.020576131687243 12.935528120713306 12.844993141289438 12.781893004115227 12.716049382716049 12.63923182441701 12.570644718792867
nms <- names(raw_data)

yr_wdi <- grep("\\[YR[0-9]{4}\\]$", nms, value = TRUE)

yr_num <- nms[suppressWarnings(!is.na(as.numeric(nms))) & suppressWarnings(as.numeric(nms)) >= 1960 & suppressWarnings(as.numeric(nms)) <= 2030]

if (length(yr_wdi) > 0 && any(c("Series Code", "Series Name", "Indicator Code", "Indicator Name") %in% nms)) {

  ind_col <- intersect(c("Series Code", "Series Name", "Indicator Code", "Indicator Name"), nms)[1]

  cnt_col <- if ("Country Name" %in% nms) "Country Name" else nms[1]

  df_panel <- raw_data %>%

    pivot_longer(cols = all_of(yr_wdi), names_to = "thn_raw", values_to = "val_raw", values_transform = list(val_raw = as.character)) %>%

    mutate(negara = trimws(as.character(.data[[cnt_col]])), indikator = trimws(as.character(.data[[ind_col]])), tahun = suppressWarnings(as.integer(sub(".*\\[YR([0-9]{4})\\]$", "\\1", thn_raw))), nilai = suppressWarnings(as.numeric(ifelse(trimws(val_raw) %in% c("", "..", "NA", "-"), NA, trimws(val_raw))))) %>%

    filter(!is.na(negara), negara != "", !grepl("Data from database|Last Updated|Source:", negara, ignore.case = TRUE), !is.na(indikator), indikator != "", !is.na(tahun)) %>%

    group_by(negara, tahun, indikator) %>% summarise(nilai = if (all(is.na(nilai))) NA_real_ else mean(nilai, na.rm = TRUE), .groups = "drop") %>%

    pivot_wider(names_from = indikator, values_from = nilai)

} else if (length(yr_num) > 0) {

  cnt_col <- nms[1]; ind_col <- if (length(nms) > 2 && !nms[2] %in% yr_num) nms[2] else NULL

  if (!is.null(ind_col)) {

    df_panel <- raw_data %>%

      pivot_longer(cols = all_of(yr_num), names_to = "tahun", values_to = "val_raw", values_transform = list(val_raw = as.character)) %>%

      mutate(negara = trimws(as.character(.data[[cnt_col]])), indikator = trimws(as.character(.data[[ind_col]])), tahun = suppressWarnings(as.integer(tahun)), nilai = suppressWarnings(as.numeric(ifelse(trimws(val_raw) %in% c("", "..", "NA", "-"), NA, trimws(val_raw))))) %>%

      filter(!is.na(negara), negara != "", !grepl("Data from database|Last Updated|Source:", negara, ignore.case = TRUE), !is.na(indikator), indikator != "", !is.na(tahun)) %>%

      group_by(negara, tahun, indikator) %>% summarise(nilai = if (all(is.na(nilai))) NA_real_ else mean(nilai, na.rm = TRUE), .groups = "drop") %>%

      pivot_wider(names_from = indikator, values_from = nilai)

  } else {

    df_panel <- raw_data %>% pivot_longer(cols = all_of(yr_num), names_to = "tahun", values_to = "val_raw", values_transform = list(val_raw = as.character)) %>% mutate(negara = trimws(as.character(.data[[cnt_col]])), tahun = suppressWarnings(as.integer(tahun)), nilai = suppressWarnings(as.numeric(ifelse(trimws(val_raw) %in% c("", "..", "NA", "-"), NA, trimws(val_raw))))) %>% filter(!is.na(negara), negara != "", !is.na(tahun))

  }

} else {

  df_panel <- raw_data; names(df_panel)[1:2] <- c("negara", "tahun")

  df_panel <- df_panel %>% fill(negara, .direction = "down") %>% mutate(negara = trimws(as.character(negara)), tahun = suppressWarnings(as.integer(as.character(tahun))), across(-c(negara, tahun), ~ suppressWarnings(as.numeric(as.character(.)))))

}

names(df_panel) <- make.names(names(df_panel), unique = TRUE)

df_panel <- df_panel %>% fill(negara, .direction = "down") %>% filter(!is.na(negara), negara != "", !is.na(tahun))

num_cols <- names(df_panel)[sapply(df_panel, is.numeric) & names(df_panel) != "tahun"]

vars_uji <- num_cols[1:min(4, length(num_cols))]

df_clean <- df_panel %>% select(negara, tahun, all_of(vars_uji)) %>% filter(if_all(all_of(vars_uji), ~ is.finite(.x))) %>% mutate(negara = as.factor(negara))

cat("\n\n## 2. Data Panel Bersih & Statistik Deskriptif\n\n")

2. Data Panel Bersih & Statistik Deskriptif

cat("- **Variabel Analisis:** `", paste(vars_uji, collapse = "`, `"), "` | **Observasi Valid:** ", nrow(df_clean), " | **Negara:** ", length(unique(df_clean$negara)), " | **Periode:** ", min(df_clean$tahun), "-", max(df_clean$tahun), "\n\n")
  • Variabel Analisis: Agricultural.land....of.land.area., Domestic.credit.to.private.sector....of.GDP., Employment.in.services....of.total.employment...modeled.ILO.estimate., Mortality.rate..under.5..per.1.000.live.births. | Observasi Valid: 336 | Negara: 15 | Periode: 2000 - 2024
print(kable(head(df_clean, 10), digits = 4, caption = "Cuplikan 10 Baris Data Panel Siap Analisis"))
Cuplikan 10 Baris Data Panel Siap Analisis
negara tahun Agricultural.land….of.land.area. Domestic.credit.to.private.sector….of.GDP. Employment.in.services….of.total.employment…modeled.ILO.estimate. Mortality.rate..under.5..per.1.000.live.births.
Brunei Darussalam 2006 2.2524 31.7046 79.0835 9.5
Brunei Darussalam 2007 2.2713 34.2004 79.6101 9.6
Brunei Darussalam 2008 2.5180 31.7685 79.7217 9.6
Brunei Darussalam 2009 2.5180 40.1018 80.1785 9.7
Brunei Darussalam 2010 2.5180 36.9083 80.2978 9.9
Brunei Darussalam 2011 2.5180 28.1209 80.1145 10.0
Brunei Darussalam 2012 2.6812 27.9921 80.1688 10.2
Brunei Darussalam 2013 2.6812 31.1924 80.4935 10.4
Brunei Darussalam 2014 2.6812 33.2080 80.7192 10.6
Brunei Darussalam 2015 2.6812 41.4363 81.3408 10.7
desk_tbl <- lapply(vars_uji, function(v) {

  x <- df_clean[[v]]

  data.frame(Variabel = v, N = length(x), Rata_Rata = mean(x), Simpangan_Baku = sd(x), Minimum = min(x), Median = median(x), Maksimum = max(x))

}) %>% bind_rows()

print(kable(desk_tbl, digits = 4, row.names = FALSE, caption = "Ringkasan Statistik Deskriptif"))
Ringkasan Statistik Deskriptif
Variabel N Rata_Rata Simpangan_Baku Minimum Median Maksimum
Agricultural.land….of.land.area. 336 32.6147 19.9336 0.9201 30.9652 80.8488
Domestic.credit.to.private.sector….of.GDP. 336 78.3224 54.1151 3.1211 54.9327 205.7496
Employment.in.services….of.total.employment…modeled.ILO.estimate. 336 50.0159 18.3955 17.9876 47.3276 85.0623
Mortality.rate..under.5..per.1.000.live.births. 336 27.1143 26.6180 2.4000 18.4500 107.9000
pdata <- pdata.frame(df_clean, index = c("negara", "tahun"), drop.index = FALSE)

cat("\n\n## 3. Uji Stasioneritas (CIPS) & Uji Cross-Sectional Independence (Pesaran CD)\n\n")

3. Uji Stasioneritas (CIPS) & Uji Cross-Sectional Independence (Pesaran CD)

has_cips <- exists("cipstest", where = asNamespace("plm"), mode = "function")

uji_awal <- lapply(vars_uji, function(v) {

  s0 <- pdata[[v]]; s1 <- tryCatch(diff(s0), error = function(e) NULL)

  c0 <- if (has_cips) tryCatch(as.numeric(plm::cipstest(s0, lags = 1, type = "drift")$p.value), error = function(e) NA_real_) else NA_real_

  c1 <- if (has_cips && !is.null(s1)) tryCatch(as.numeric(plm::cipstest(s1, lags = 1, type = "drift")$p.value), error = function(e) NA_real_) else NA_real_

  ip0 <- tryCatch(as.numeric(purtest(s0, test = "ips", exo = "intercept", lags = 1)$statistic$p.value), error = function(e) NA_real_)

  cd0 <- tryCatch(pcdtest(s0, test = "cd"), error = function(e) NULL)

  data.frame(Variabel = v, CIPS_Level_p = c0, CIPS_Diff1_p = c1, IPS_Level_p = ip0, Pesaran_CD_Stat = if (!is.null(cd0)) as.numeric(cd0$statistic) else NA_real_, Pesaran_CD_p = if (!is.null(cd0)) as.numeric(cd0$p.value) else NA_real_, Stasioneritas = ifelse(!is.na(c0) & c0 <= 0.05, "Stasioner I(0)", ifelse(!is.na(c1) & c1 <= 0.05, "Stasioner I(1)", "Cek Lag")), Cross_Section = if (!is.null(cd0)) ifelse(cd0$p.value <= 0.05, "Ada Dependensi (p <= 0.05)", "Independen (p > 0.05)") else "N/A")

}) %>% bind_rows()

print(kable(uji_awal, digits = 4, row.names = FALSE, caption = "Hasil Uji Stasioneritas CIPS/IPS dan Cross-Sectional Independence"))
Hasil Uji Stasioneritas CIPS/IPS dan Cross-Sectional Independence
Variabel CIPS_Level_p CIPS_Diff1_p IPS_Level_p Pesaran_CD_Stat Pesaran_CD_p Stasioneritas Cross_Section
Agricultural.land….of.land.area. 0.1000 0.0464 0.3200 -1.7561 0.0791 Stasioner I(1) Independen (p > 0.05)
Domestic.credit.to.private.sector….of.GDP. 0.0837 0.0486 0.6002 14.3202 0.0000 Stasioner I(1) Ada Dependensi (p <= 0.05)
Employment.in.services….of.total.employment…modeled.ILO.estimate. 0.1000 0.0100 0.9294 31.5902 0.0000 Stasioner I(1) Ada Dependensi (p <= 0.05)
Mortality.rate..under.5..per.1.000.live.births. 0.0100 0.0319 0.0000 32.4830 0.0000 Stasioner I(0) Ada Dependensi (p <= 0.05)
if (length(vars_uji) >= 2) {

  f_panel <- as.formula(paste(vars_uji[1], "~", paste(vars_uji[-1], collapse = " + ")))

  cat("\n\n## 4. Uji Heterogenitas\n\n```\n")

  print(tryCatch(pooltest(f_panel, data = pdata, model = "within"), error = function(e) e$message))

  print(tryCatch(summary(pvcm(f_panel, data = pdata, model = "within")), error = function(e) e$message))

  cat("```\n\n## 5. Pemilihan Model & Estimasi\n\n```\n")

  cem <- plm(f_panel, data = pdata, model = "pooling"); fem <- plm(f_panel, data = pdata, model = "within"); rem <- tryCatch(plm(f_panel, data = pdata, model = "random"), error = function(e) NULL)

  print(pFtest(fem, cem)); if (!is.null(rem)) print(tryCatch(phtest(fem, rem), error = function(e) e$message)); print(tryCatch(plmtest(cem, type = "bp"), error = function(e) e$message)); print(summary(fem))

  cat("```\n\n### 6. Uji Asumsi Model\n\n```\n")

  print(pbgtest(fem)); print(bptest(lm(update(f_panel, . ~ . + factor(negara)), data = df_clean))); print(tryCatch(pcdtest(fem, test = "cd"), error = function(e) e$message))

  if (length(vars_uji) > 2) print(vif(lm(f_panel, data = df_clean)))

  res_e <- as.numeric(residuals(fem)); print(shapiro.test(res_e)); print(jarque.bera.test(res_e))

  cat("```\n\n### 7. Estimasi Driscoll-Kraay Robust Standard Errors\n\n```\n")

  print(coeftest(fem, vcov = function(x) vcovSCC(x, type = "HC0", cluster = "group")))

  cat("```\n\n")

}

4. Uji Heterogenitas


    F statistic

data:  f_panel
F = 62.539, df1 = 42, df2 = 276, p-value < 2.2e-16
alternative hypothesis: unstability

Oneway (individual) effect No-pooling model

Call:
pvcm(formula = f_panel, data = pdata, model = "within")

Unbalanced Panel: n = 15, T = 16-25, N = 336

Residuals:
     Min.   1st Qu.    Median   3rd Qu.      Max. 
-1.864920 -0.147546 -0.005048  0.128867  2.124958 

Coefficients:
  (Intercept)     Domestic.credit.to.private.sector....of.GDP.
 Min.   :-8.404   Min.   :-0.1342785                          
 1st Qu.:11.170   1st Qu.:-0.0103240                          
 Median :30.699   Median :-0.0004938                          
 Mean   :30.889   Mean   :-0.0033566                          
 3rd Qu.:49.511   3rd Qu.: 0.0162772                          
 Max.   :82.343   Max.   : 0.0772170                          
 Employment.in.services....of.total.employment...modeled.ILO.estimate.
 Min.   :-0.27432                                                     
 1st Qu.:-0.03333                                                     
 Median : 0.03819                                                     
 Mean   : 0.09028                                                     
 3rd Qu.: 0.16869                                                     
 Max.   : 0.60208                                                     
 Mortality.rate..under.5..per.1.000.live.births.
 Min.   :-1.423628                              
 1st Qu.:-0.064806                              
 Median : 0.001513                              
 Mean   : 0.031102                              
 3rd Qu.: 0.331170                              
 Max.   : 1.282442                              

Total Sum of Squares: 2e+06
Residual Sum of Squares: 62.046
Multiple R-Squared: 0.99997

5. Pemilihan Model & Estimasi


    F test for individual effects

data:  f_panel
F = 3601.9, df1 = 14, df2 = 318, p-value < 2.2e-16
alternative hypothesis: significant effects


    Hausman Test

data:  f_panel
chisq = 6.7266, df = 3, p-value = 0.08114
alternative hypothesis: one model is inconsistent


    Lagrange Multiplier Test - (Breusch-Pagan)

data:  f_panel
chisq = 2553.1, df = 1, p-value < 2.2e-16
alternative hypothesis: significant effects

Oneway (individual) effect Within Model

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

Unbalanced Panel: n = 15, T = 16-25, N = 336

Residuals:
   Min. 1st Qu.  Median 3rd Qu.    Max. 
-5.0621 -0.5977  0.0233  0.6740  4.1554 

Coefficients:
                                                                        Estimate
Domestic.credit.to.private.sector....of.GDP.                           0.0122373
Employment.in.services....of.total.employment...modeled.ILO.estimate.  0.0404381
Mortality.rate..under.5..per.1.000.live.births.                       -0.0198719
                                                                      Std. Error
Domestic.credit.to.private.sector....of.GDP.                           0.0060062
Employment.in.services....of.total.employment...modeled.ILO.estimate.  0.0339089
Mortality.rate..under.5..per.1.000.live.births.                        0.0090822
                                                                      t-value
Domestic.credit.to.private.sector....of.GDP.                           2.0374
Employment.in.services....of.total.employment...modeled.ILO.estimate.  1.1926
Mortality.rate..under.5..per.1.000.live.births.                       -2.1880
                                                                      Pr(>|t|)
Domestic.credit.to.private.sector....of.GDP.                           0.04243
Employment.in.services....of.total.employment...modeled.ILO.estimate.  0.23393
Mortality.rate..under.5..per.1.000.live.births.                        0.02940
                                                                       
Domestic.credit.to.private.sector....of.GDP.                          *
Employment.in.services....of.total.employment...modeled.ILO.estimate.  
Mortality.rate..under.5..per.1.000.live.births.                       *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:    740.78
Residual Sum of Squares: 652.52
R-Squared:      0.11914
Adj. R-Squared: 0.07205
F-statistic: 14.337 on 3 and 318 DF, p-value: 8.7518e-09

6. Uji Asumsi Model


    Breusch-Godfrey/Wooldridge test for serial correlation in panel models

data:  f_panel
chisq = 274.98, df = 16, p-value < 2.2e-16
alternative hypothesis: serial correlation in idiosyncratic errors


    studentized Breusch-Pagan test

data:  lm(update(f_panel, . ~ . + factor(negara)), data = df_clean)
BP = 182.58, df = 17, p-value < 2.2e-16


    Pesaran CD test for cross-sectional dependence in panels

data:  Agricultural.land....of.land.area. ~ Domestic.credit.to.private.sector....of.GDP. +     Employment.in.services....of.total.employment...modeled.ILO.estimate. +     Mortality.rate..under.5..per.1.000.live.births.
z = -2.3107, p-value = 0.02085
alternative hypothesis: cross-sectional dependence

                         Domestic.credit.to.private.sector....of.GDP. 
                                                             2.027921 
Employment.in.services....of.total.employment...modeled.ILO.estimate. 
                                                             2.063303 
                      Mortality.rate..under.5..per.1.000.live.births. 
                                                             3.412500 

    Shapiro-Wilk normality test

data:  res_e
W = 0.96254, p-value = 1.378e-07


    Jarque Bera Test

data:  res_e
X-squared = 25.489, df = 2, p-value = 2.918e-06

7. Estimasi Driscoll-Kraay Robust Standard Errors


t test of coefficients:

                                                                       Estimate
Domestic.credit.to.private.sector....of.GDP.                           0.012237
Employment.in.services....of.total.employment...modeled.ILO.estimate.  0.040438
Mortality.rate..under.5..per.1.000.live.births.                       -0.019872
                                                                      Std. Error
Domestic.credit.to.private.sector....of.GDP.                            0.019353
Employment.in.services....of.total.employment...modeled.ILO.estimate.   0.136378
Mortality.rate..under.5..per.1.000.live.births.                         0.022785
                                                                      t value
Domestic.credit.to.private.sector....of.GDP.                           0.6323
Employment.in.services....of.total.employment...modeled.ILO.estimate.  0.2965
Mortality.rate..under.5..per.1.000.live.births.                       -0.8722
                                                                      Pr(>|t|)
Domestic.credit.to.private.sector....of.GDP.                            0.5276
Employment.in.services....of.total.employment...modeled.ILO.estimate.   0.7670
Mortality.rate..under.5..per.1.000.live.births.                         0.3838