LOAD DATA


Tujuan

membaca data Tingkat Pengangguran Terbuka (TPT) dan data spasial batas administrasi kabupaten/kota di Provinsi Jawa Barat serta melakukan penyesuaian nama wilayah agar kedua data dapat diintegrasikan.

## # A tibble: 27 × 5
##    KAB_KOTA      TPT  TPAK   PDRB PENGELUARAN
##    <chr>       <dbl> <dbl>  <dbl>       <dbl>
##  1 Bogor        7.69  64.7 34188.       11933
##  2 Sukabumi     7.23  69.7 20649.       10244
##  3 Cianjur      6.17  68.9 15479.        9173
##  4 Bandung      6.68  67   27403.       11619
##  5 Garut        6.54  68.3 17836.        9479
##  6 Tasikmalaya  3.69  69.2 15726.        9258
##  7 Ciamis       4.08  66.2 21935.       10406
##  8 Kuningan     7.59  69.3 17901.       10707
##  9 Cirebon      6.42  69.3 17348.       11769
## 10 Majalengka   3.62  72.6 21500.       11094
## # ℹ 17 more rows
## Simple feature collection with 27 features and 6 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 106.3703 ymin: -7.82099 xmax: 108.8468 ymax: -5.806538
## Geodetic CRS:  WGS 84
## First 10 features:
##    KDPKAB KDPPUM      WADMKK     WADMPR
## 1   32.01     32       Bogor Jawa Barat
## 2   32.02     32    Sukabumi Jawa Barat
## 3   32.03     32     Cianjur Jawa Barat
## 4   32.04     32     Bandung Jawa Barat
## 5   32.05     32       Garut Jawa Barat
## 6   32.06     32 Tasikmalaya Jawa Barat
## 7   32.07     32      Ciamis Jawa Barat
## 8   32.08     32    Kuningan Jawa Barat
## 9   32.09     32     Cirebon Jawa Barat
## 10  32.10     32  Majalengka Jawa Barat
##                                    METADATA          UPDATED
## 1  TASWIL1000020230928_DATA_BATAS_KABUPATEN Lapak GIS - 2024
## 2  TASWIL1000020230928_DATA_BATAS_KABUPATEN Lapak GIS - 2024
## 3  TASWIL1000020230928_DATA_BATAS_KABUPATEN Lapak GIS - 2024
## 4  TASWIL1000020230928_DATA_BATAS_KABUPATEN Lapak GIS - 2024
## 5  TASWIL1000020230928_DATA_BATAS_KABUPATEN Lapak GIS - 2024
## 6  TASWIL1000020230928_DATA_BATAS_KABUPATEN Lapak GIS - 2024
## 7  TASWIL1000020230928_DATA_BATAS_KABUPATEN Lapak GIS - 2024
## 8  TASWIL1000020230928_DATA_BATAS_KABUPATEN Lapak GIS - 2024
## 9  TASWIL1000020230928_DATA_BATAS_KABUPATEN Lapak GIS - 2024
## 10 TASWIL1000020230928_DATA_BATAS_KABUPATEN Lapak GIS - 2024
##                          geometry
## 1  MULTIPOLYGON (((106.9709 -6...
## 2  MULTIPOLYGON (((106.581 -7....
## 3  MULTIPOLYGON (((107.2302 -6...
## 4  MULTIPOLYGON (((107.75 -6.8...
## 5  MULTIPOLYGON (((107.8994 -7...
## 6  MULTIPOLYGON (((108.3231 -7...
## 7  MULTIPOLYGON (((108.358 -7....
## 8  MULTIPOLYGON (((108.4456 -6...
## 9  MULTIPOLYGON (((108.5391 -6...
## 10 MULTIPOLYGON (((108.1225 -6...

GRID PETA


Tujuan

menggabungkan data atribut dengan data spasial sehingga diperoleh objek spasial yang memuat informasi karakteristik setiap wilayah beserta koordinat pusat wilayah yang digunakan dalam visualisasi.

PETA = merge(
  shp,
  TPT,
  by = "KAB_KOTA"
)

koordinat = st_coordinates(
  st_centroid(
    st_geometry(PETA)
  )
)

PETA$X = koordinat[,1]
PETA$Y = koordinat[,2]
PETA$NOMOR = 1:nrow(PETA)

GRID = ggplot(data = PETA) +
  geom_sf(
    fill  = "#F5F5F5",
    color = "black",
    linewidth = 0.3
  ) +
  geom_text(
    aes(
      x = X,
      y = Y,
      label = NOMOR
    ),
    color = "#1D3557",
    fontface = "bold",
    size = 4
  ) +
  theme_minimal() +
  theme(
    panel.border = element_rect(
      colour = "black",
      fill = NA,
      linewidth = 0.6
    )
  ) +
  labs(
    title = "Peta Batas Wilayah Kabupaten/Kota Jawa Barat",
    x = NULL,
    y = NULL
  )

GRID


PETA VARIABEL


Tujuan

menggambarkan sebaran spasial variabel penelitian sehingga dapat diketahui pola distribusi Tingkat Pengangguran Terbuka (TPT), Tingkat Partisipasi Angkatan Kerja (TPAK), Produk Domestik Regional Bruto (PDRB), dan Pengeluaran Riil Per Kapita pada masing-masing kabupaten/kota.

buat_peta = function(data, variabel, judul, legenda){
  
  ggplot(data = data) +
    geom_sf(
      aes(fill = .data[[variabel]]),
      color = "black",
      linewidth = 0.2
    ) +
    scale_fill_viridis_c(
      option = "mako",
      name = legenda
    ) +
    geom_text(
      aes(
        x = X,
        y = Y,
        label = NOMOR
      ),
      color = "white",
      fontface = "bold",
      size = 2.5
    ) +
    theme_minimal() +
    theme(
      legend.position = "right",
      plot.title = element_text(
        size = 10,
        face = "bold"
      ),
      panel.border = element_rect(
        color = "black",
        fill = NA,
        linewidth = 0.5
      )
    ) +
    labs(
      title = judul,
      x = NULL,
      y = NULL
    )
}

p_tpt = buat_peta(
  PETA,
  "TPT",
  "A. Tingkat Pengangguran Terbuka (TPT)",
  "%"
)

p_tpak = buat_peta(
  PETA,
  "TPAK",
  "B. Tingkat Partisipasi Angkatan Kerja (TPAK)",
  "%"
)

p_pdrb = buat_peta(
  PETA,
  "PDRB",
  "C. Produk Domestik Regional Bruto (PDRB)",
  "Nilai"
)

p_pengeluaran = buat_peta(
  PETA,
  "PENGELUARAN",
  "D. Pengeluaran Riil Per Kapita",
  "Nilai"
)

(p_tpt + p_tpak) /
  (p_pdrb + p_pengeluaran) + 
  plot_layout(
    widths  = c(1, 1),   
    heights = c(1, 1)   
  )


KETETANGGAAN


Tujuan

mendefinisikan hubungan spasial antarwilayah menggunakan Queen Contiguity yang selanjutnya digunakan dalam pembentukan matriks bobot spasial.

tetangga = poly2nb(
  PETA,
  queen = TRUE
)

W_matriks <- nb2listw(
  tetangga,
  style = "W",
  zero.policy = TRUE
)

W_sparse <- as(W_matriks, "CsparseMatrix")
W_sparse
## 27 x 27 sparse Matrix of class "dgCMatrix"
##                                                                         
## 1  .         0.1428571 .         .         .         0.1428571 .        
## 2  0.1666667 .         .         .         .         0.1666667 .        
## 3  .         .         .         0.3333333 .         .         .        
## 4  .         .         0.1250000 .         .         0.1250000 .        
## 5  .         .         .         .         .         .         .        
## 6  0.1666667 0.1666667 .         0.1666667 .         .         .        
## 7  .         .         .         .         .         .         .        
## 8  0.2500000 .         .         .         .         0.2500000 .        
## 9  .         .         .         .         .         .         0.2500000
## 10 .         .         0.2500000 0.2500000 .         .         .        
## 11 0.3333333 0.3333333 .         .         .         .         .        
## 12 .         .         .         .         1.0000000 .         .        
## 13 .         .         0.3333333 0.3333333 .         .         .        
## 14 .         .         .         1.0000000 .         .         .        
## 15 0.3333333 0.3333333 .         .         .         .         .        
## 16 .         .         .         .         .         .         1.0000000
## 17 .         .         .         0.5000000 .         .         .        
## 18 .         .         .         .         .         .         .        
## 19 .         .         .         .         0.5000000 .         .        
## 20 .         .         .         .         0.3333333 .         0.3333333
## 21 .         .         .         .         0.1666667 .         0.1666667
## 22 .         .         .         .         0.5000000 .         .        
## 23 .         0.2000000 .         0.2000000 .         0.2000000 .        
## 24 0.1666667 0.1666667 .         .         .         .         .        
## 25 .         .         .         0.3333333 .         0.3333333 .        
## 26 0.1666667 .         .         .         .         .         .        
## 27 .         .         .         .         0.1666667 .         .        
##                                                                               
## 1  0.1428571 .         .         0.1428571 .         .         .     0.1428571
## 2  .         .         .         0.1666667 .         .         .     0.1666667
## 3  .         .         0.3333333 .         .         0.3333333 .     .        
## 4  .         .         0.1250000 .         .         0.1250000 0.125 .        
## 5  .         .         .         .         0.1666667 .         .     .        
## 6  0.1666667 .         .         .         .         .         .     .        
## 7  .         0.2500000 .         .         .         .         .     .        
## 8  .         .         .         .         .         .         .     .        
## 9  .         .         .         .         .         .         .     .        
## 10 .         .         .         .         .         .         .     .        
## 11 .         .         .         .         .         .         .     0.3333333
## 12 .         .         .         .         .         .         .     .        
## 13 .         .         .         .         .         .         .     .        
## 14 .         .         .         .         .         .         .     .        
## 15 .         .         .         0.3333333 .         .         .     .        
## 16 .         .         .         .         .         .         .     .        
## 17 .         .         .         .         .         0.5000000 .     .        
## 18 .         .         .         .         .         .         .     .        
## 19 .         .         .         .         .         .         .     .        
## 20 .         .         .         .         .         .         .     .        
## 21 .         0.1666667 .         .         .         .         .     .        
## 22 .         .         .         .         .         .         .     .        
## 23 .         .         0.2000000 .         .         .         .     .        
## 24 .         0.1666667 0.1666667 .         .         .         .     .        
## 25 .         .         .         .         .         .         .     .        
## 26 0.1666667 0.1666667 .         .         .         .         .     .        
## 27 0.1666667 .         .         .         .         .         .     .        
##                                                                              
## 1  .    .         .         .         .         .         .         .        
## 2  .    .         .         .         .         .         .         0.1666667
## 3  .    .         .         .         .         .         .         .        
## 4  .    0.1250000 .         .         .         .         .         0.1250000
## 5  .    .         .         0.1666667 0.1666667 0.1666667 0.1666667 .        
## 6  .    .         .         .         .         .         .         0.1666667
## 7  0.25 .         .         .         0.2500000 0.2500000 .         .        
## 8  .    .         .         .         .         .         .         .        
## 9  .    .         .         .         .         0.2500000 .         .        
## 10 .    .         .         .         .         .         .         0.2500000
## 11 .    .         .         .         .         .         .         .        
## 12 .    .         .         .         .         .         .         .        
## 13 .    0.3333333 .         .         .         .         .         .        
## 14 .    .         .         .         .         .         .         .        
## 15 .    .         .         .         .         .         .         .        
## 16 .    .         .         .         .         .         .         .        
## 17 .    .         .         .         .         .         .         .        
## 18 .    .         .         .         .         .         .         .        
## 19 .    .         .         .         .         .         .         .        
## 20 .    .         .         .         .         0.3333333 .         .        
## 21 .    .         .         .         0.1666667 .         .         .        
## 22 .    .         .         .         .         .         .         .        
## 23 .    .         .         .         .         .         .         .        
## 24 .    .         .         .         .         .         .         0.1666667
## 25 .    .         0.3333333 .         .         .         .         .        
## 26 .    .         .         .         .         0.1666667 .         .        
## 27 .    .         .         0.1666667 .         0.1666667 0.1666667 .        
##                                           
## 1  0.1428571 .         0.1428571 .        
## 2  0.1666667 .         .         .        
## 3  .         .         .         .        
## 4  .         0.1250000 .         .        
## 5  .         .         .         0.1666667
## 6  .         0.1666667 .         .        
## 7  .         .         .         .        
## 8  .         .         0.2500000 0.2500000
## 9  0.2500000 .         0.2500000 .        
## 10 0.2500000 .         .         .        
## 11 .         .         .         .        
## 12 .         .         .         .        
## 13 .         .         .         .        
## 14 .         .         .         .        
## 15 .         .         .         .        
## 16 .         .         .         .        
## 17 .         .         .         .        
## 18 .         1.0000000 .         .        
## 19 .         .         .         0.5000000
## 20 .         .         .         .        
## 21 .         .         0.1666667 0.1666667
## 22 .         .         .         0.5000000
## 23 0.2000000 .         .         .        
## 24 .         .         0.1666667 .        
## 25 .         .         .         .        
## 26 0.1666667 .         .         0.1666667
## 27 .         .         0.1666667 .
edges = lapply(1:length(tetangga), function(i) {
  tetangga_i <- tetangga[[i]]
  if(tetangga_i[1] > 0) {
    data.frame(
      x = PETA$X[i],
      y = PETA$Y[i],
      xend = PETA$X[tetangga_i],
      yend = PETA$Y[tetangga_i]
    )
  }
}) %>% do.call(rbind, .)

TETANGGA = ggplot(data = PETA) +
  geom_sf(
    fill = "#F5F5F5",
    color = "black",
    linewidth = 0.3
  ) +

  geom_segment(
    data = edges,
    aes(x = x, y = y, xend = xend, yend = yend),
    color = "grey40",
    linewidth = 0.6,
    alpha = 0.8
  ) +

  geom_text(
    aes(
      x = X,
      y = Y,
      label = NOMOR
    ),
    color = "#1D3557",
    fontface = "bold",
    size = 4,
    vjust = -0.5 
  ) +
  theme_minimal() +
  theme(
    panel.border = element_rect(
      colour = "black",
      fill = NA,
      linewidth = 0.6
    )
  ) +
  labs(
    title = "Matriks Ketetanggaan (Queen Contiguity) Jawa Barat",
    x = NULL,
    y = NULL
  )

TETANGGA


OLS


Tujuan

memperoleh model regresi linier awal yang menggambarkan hubungan antara Tingkat Pengangguran Terbuka (TPT) dengan variabel-variabel prediktor yang digunakan dalam penelitian.

TPT_OLS = lm(
    TPT ~ TPAK +
    scale(PDRB) +
    scale(PENGELUARAN),
  data = PETA
)

summary(TPT_OLS)
## 
## Call:
## lm(formula = TPT ~ TPAK + scale(PDRB) + scale(PENGELUARAN), data = PETA)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.6628 -0.5925  0.0339  0.7178  1.8770 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)        26.14133    5.40361   4.838 6.98e-05 ***
## TPAK               -0.28998    0.07977  -3.635  0.00139 ** 
## scale(PDRB)         0.52449    0.29159   1.799  0.08520 .  
## scale(PENGELUARAN) -0.10086    0.31523  -0.320  0.75190    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.184 on 23 degrees of freedom
## Multiple R-squared:  0.5253, Adjusted R-squared:  0.4634 
## F-statistic: 8.484 on 3 and 23 DF,  p-value: 0.000563

DIAGNOSTIK


Tujuan

mengevaluasi pemenuhan asumsi klasik model regresi yang meliputi normalitas residual, homoskedastisitas, tidak adanya multikolinearitas, dan tidak adanya autokorelasi.

shapiro.test(
  residuals(TPT_OLS)
)
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(TPT_OLS)
## W = 0.9762, p-value = 0.7683
bptest(
  TPT_OLS
)
## 
##  studentized Breusch-Pagan test
## 
## data:  TPT_OLS
## BP = 3.3723, df = 3, p-value = 0.3377
vif(
  TPT_OLS
)
##               TPAK        scale(PDRB) scale(PENGELUARAN) 
##           1.299502           1.576261           1.842194
durbinWatsonTest(
  TPT_OLS
)
##  lag Autocorrelation D-W Statistic p-value
##    1     -0.04577525      1.959047   0.768
##  Alternative hypothesis: rho != 0

MORAN I


Tujuan

mengidentifikasi keberadaan autokorelasi spasial secara global pada residual model OLS sehingga dapat diketahui apakah terdapat ketergantungan spasial antarwilayah.

MORAN = lm.morantest(
  TPT_OLS,
  W_matriks,
  zero.policy = TRUE
)

MORAN
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = TPT ~ TPAK + scale(PDRB) + scale(PENGELUARAN), data
## = PETA)
## weights: W_matriks
## 
## Moran I statistic standard deviate = 2.6847, p-value = 0.00363
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##        0.3135718       -0.0585038        0.0192082
moran.plot(
  residuals(TPT_OLS),
  W_matriks,
  labels = PETA$KAB_KOTA,
  zero.policy = TRUE
)


LISA


Tujuan

mengidentifikasi pola autokorelasi spasial lokal serta mendeteksi klaster wilayah High-High, Low-Low, High-Low, dan Low-High berdasarkan nilai Tingkat Pengangguran Terbuka.

LISA = localmoran(
  PETA$TPT,
  W_matriks,
  zero.policy = TRUE
)

PETA$LOCAL_I = LISA[,1]
PETA$P_VALUE = LISA[,5]

mean_tpt = mean(PETA$TPT)

lag_tpt  = lag.listw(
  W_matriks,
  PETA$TPT,
  zero.policy = TRUE
)

mean_lag = mean(lag_tpt)

PETA$QUADRANT = "Not Significant"

# High-High
PETA$QUADRANT[
  PETA$TPT > mean_tpt &
  lag_tpt > mean_lag &
  PETA$P_VALUE < 0.05
] <- "High-High"

# Low-Low
PETA$QUADRANT[
  PETA$TPT < mean_tpt &
  lag_tpt < mean_lag &
  PETA$P_VALUE < 0.05
] <- "Low-Low"

# High-Low
PETA$QUADRANT[
  PETA$TPT > mean_tpt &
  lag_tpt < mean_lag &
  PETA$P_VALUE < 0.05
] <- "High-Low"

# Low-High
PETA$QUADRANT[
  PETA$TPT < mean_tpt &
  lag_tpt > mean_lag &
  PETA$P_VALUE < 0.05
] <- "Low-High"

table(PETA$QUADRANT)
## 
##       High-High        High-Low         Low-Low Not Significant 
##               1               1               4              21
PETA %>%
  filter(
    QUADRANT != "Not Significant"
  ) %>%
  st_drop_geometry() %>%
  select(
    KAB_KOTA,
    QUADRANT,
    LOCAL_I,
    P_VALUE
  ) %>%
  arrange(QUADRANT)
##           KAB_KOTA  QUADRANT     LOCAL_I      P_VALUE
## 1            Bogor High-High  0.43020037 0.0437556311
## 2         Kuningan  High-Low -0.77204368 0.0462754869
## 3           Ciamis   Low-Low  1.70986328 0.0009520995
## 4 Kota Tasikmalaya   Low-Low  0.09022557 0.0186530299
## 5      Pangandaran   Low-Low  4.81603181 0.0022858464
## 6      Tasikmalaya   Low-Low  1.95362951 0.0008325864
PETA_LISA <- ggplot(PETA) +
  geom_sf(
    aes(fill = QUADRANT),
    color = "black",
    linewidth = 0.3
  ) +
  scale_fill_manual(
    values = c(
      "High-High" = "#3F4A80",
      "Low-Low"   = "#75D0B3",
      "High-Low"  = "#359FB1",
      "Low-High"  = "#1A102F",
      "Not Significant" = "#F1F1F1"
    ),
    name = "Klaster"
  ) +
  geom_text(
    aes(
      x = X,
      y = Y,
      label = NOMOR
    ),
    color = "black",
    fontface = "bold",
    size = 3
  ) +
  theme_minimal() +
  theme(
    legend.position = "right",
    panel.border = element_rect(
      colour = "black",
      fill = NA,
      linewidth = 0.5
    )
  ) +
  labs(
    title = "Peta Klaster Local Moran's I (LISA)",
    x = NULL,
    y = NULL
  )

PETA_LISA


RAO-SCORE TEST


Tujuan

menentukan bentuk ketergantungan spasial yang terdapat pada data serta memberikan dasar pemilihan model regresi spasial yang sesuai.

LMTEST = lm.RStests(
  TPT_OLS,
  W_matriks,
  test = "all"
)

summary(LMTEST)
##  Rao's score (a.k.a Lagrange multiplier) diagnostics for spatial
##  dependence
## data:  
## model: lm(formula = TPT ~ TPAK + scale(PDRB) + scale(PENGELUARAN), data
## = PETA)
## test weights: W_matriks
##  
##          statistic parameter p.value  
## RSerr    4.2831405         1 0.03849 *
## RSlag    6.0156207         1 0.01418 *
## adjRSerr 0.0045095         1 0.94646  
## adjRSlag 1.7369898         1 0.18752  
## SARMA    6.0201302         2 0.04929 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

PEMODELAN


Tahap ini bertujuan untuk membentuk model Spatial Autoregressive (SAR), Spatial Error Model (SEM), Spatial Autoregressive Combined (SAC), dan Spatial Durbin Model (SDM) untuk memenuhi pengaruh spasial antarwilayah.

SAR

TPT_SAR = lagsarlm(
  TPT ~ TPAK +
    scale(PDRB) +
    scale(PENGELUARAN),
  data = PETA,
  listw = W_matriks,
  zero.policy = TRUE
)

summary(TPT_SAR)
## 
## Call:lagsarlm(formula = TPT ~ TPAK + scale(PDRB) + scale(PENGELUARAN), 
##     data = PETA, listw = W_matriks, zero.policy = TRUE)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -2.035997 -0.435911 -0.021032  0.534446  2.319424 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##                     Estimate Std. Error z value  Pr(>|z|)
## (Intercept)        19.428194   4.743095  4.0961 4.202e-05
## TPAK               -0.231240   0.065302 -3.5411 0.0003985
## scale(PDRB)         0.378373   0.235215  1.6086 0.1076979
## scale(PENGELUARAN) -0.182870   0.256321 -0.7134 0.4755733
## 
## Rho: 0.43289, LR test value: 5.9196, p-value: 0.014974
## Asymptotic standard error: 0.16582
##     z-value: 2.6105, p-value: 0.0090408
## Wald statistic: 6.8147, p-value: 0.0090408
## 
## Log likelihood: -37.75272 for lag model
## ML residual variance (sigma squared): 0.91115, (sigma: 0.95454)
## Number of observations: 27 
## Number of parameters estimated: 6 
## AIC: 87.505, (AIC for lm: 91.425)
## LM test for residual autocorrelation
## test value: 0.038646, p-value: 0.84415
moran.test(
  residuals(TPT_SAR),
  W_matriks,
  zero.policy = TRUE
)
## 
##  Moran I test under randomisation
## 
## data:  residuals(TPT_SAR)  
## weights: W_matriks    
## 
## Moran I statistic standard deviate = 0.15721, p-value = 0.4375
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       -0.01678608       -0.03846154        0.01901038

SEM

TPT_SEM = errorsarlm(
  TPT ~ TPAK +
    scale(PDRB) +
    scale(PENGELUARAN),
  data = PETA,
  listw = W_matriks,
  zero.policy = TRUE
)

summary(TPT_SEM)
## 
## Call:errorsarlm(formula = TPT ~ TPAK + scale(PDRB) + scale(PENGELUARAN), 
##     data = PETA, listw = W_matriks, zero.policy = TRUE)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.38417 -0.53169  0.16709  0.55395  2.10661 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##                     Estimate Std. Error z value  Pr(>|z|)
## (Intercept)        22.123945   4.413107  5.0132 5.352e-07
## TPAK               -0.228354   0.064683 -3.5304  0.000415
## scale(PDRB)         0.310849   0.250608  1.2404  0.214834
## scale(PENGELUARAN) -0.070947   0.266434 -0.2663  0.790022
## 
## Lambda: 0.43773, LR test value: 4.1157, p-value: 0.042488
## Asymptotic standard error: 0.19465
##     z-value: 2.2488, p-value: 0.024523
## Wald statistic: 5.0573, p-value: 0.024523
## 
## Log likelihood: -38.65467 for error model
## ML residual variance (sigma squared): 0.97287, (sigma: 0.98634)
## Number of observations: 27 
## Number of parameters estimated: 6 
## AIC: 89.309, (AIC for lm: 91.425)
moran.test(
  residuals(TPT_SEM),
  W_matriks,
  zero.policy = TRUE
)
## 
##  Moran I test under randomisation
## 
## data:  residuals(TPT_SEM)  
## weights: W_matriks    
## 
## Moran I statistic standard deviate = 0.12217, p-value = 0.4514
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       -0.02158913       -0.03846154        0.01907215

SAC

TPT_SAC = sacsarlm(
  TPT ~ TPAK +
    scale(PDRB) +
    scale(PENGELUARAN),
  data = PETA,
  listw = W_matriks,
  zero.policy = TRUE
)

summary(TPT_SAC)
## 
## Call:sacsarlm(formula = TPT ~ TPAK + scale(PDRB) + scale(PENGELUARAN), 
##     data = PETA, listw = W_matriks, zero.policy = TRUE)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -1.979060 -0.442427 -0.066581  0.522966  2.326151 
## 
## Type: sac 
## Coefficients: (asymptotic standard errors) 
##                     Estimate Std. Error z value  Pr(>|z|)
## (Intercept)        19.187866   5.484516  3.4986 0.0004678
## TPAK               -0.230693   0.068013 -3.3919 0.0006941
## scale(PDRB)         0.387707   0.233379  1.6613 0.0966584
## scale(PENGELUARAN) -0.195611   0.257973 -0.7583 0.4482952
## 
## Rho: 0.46289
## Asymptotic standard error: 0.27155
##     z-value: 1.7046, p-value: 0.088267
## Lambda: -0.060144
## Asymptotic standard error: 0.42001
##     z-value: -0.1432, p-value: 0.88613
## 
## LR test value: 5.9472, p-value: 0.051119
## 
## Log likelihood: -37.73892 for sac model
## ML residual variance (sigma squared): 0.90198, (sigma: 0.94973)
## Number of observations: 27 
## Number of parameters estimated: 7 
## AIC: 89.478, (AIC for lm: 91.425)
moran.test(
  residuals(TPT_SAC),
  W_matriks,
  zero.policy = TRUE
)
## 
##  Moran I test under randomisation
## 
## data:  residuals(TPT_SAC)  
## weights: W_matriks    
## 
## Moran I statistic standard deviate = 0.28083, p-value = 0.3894
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.0002702349     -0.0384615385      0.0190217610

SDM

TPT_SDM = lagsarlm(
  TPT ~ TPAK +
    scale(PDRB) +
    scale(PENGELUARAN),
  data = PETA,
  listw = W_matriks,
  type = "mixed",
  zero.policy = TRUE
)

summary(TPT_SDM)
## 
## Call:lagsarlm(formula = TPT ~ TPAK + scale(PDRB) + scale(PENGELUARAN), 
##     data = PETA, listw = W_matriks, type = "mixed", zero.policy = TRUE)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -2.043563 -0.544727 -0.080524  0.451277  2.474128 
## 
## Type: mixed 
## Coefficients: (asymptotic standard errors) 
##                         Estimate Std. Error z value  Pr(>|z|)
## (Intercept)            17.491587  11.696307  1.4955 0.1347894
## TPAK                   -0.241868   0.067840 -3.5653 0.0003635
## scale(PDRB)             0.290252   0.242726  1.1958 0.2317730
## scale(PENGELUARAN)     -0.099007   0.267809 -0.3697 0.7116129
## lag.TPAK                0.045712   0.144609  0.3161 0.7519217
## lag.scale(PDRB)         1.118844   0.718284  1.5577 0.1193134
## lag.scale(PENGELUARAN) -0.690133   0.674381 -1.0234 0.3061386
## 
## Rho: 0.3714, LR test value: 3.4007, p-value: 0.065167
## Asymptotic standard error: 0.20092
##     z-value: 1.8485, p-value: 0.064531
## Wald statistic: 3.4169, p-value: 0.064531
## 
## Log likelihood: -36.62262 for mixed model
## ML residual variance (sigma squared): 0.85029, (sigma: 0.92211)
## Number of observations: 27 
## Number of parameters estimated: 9 
## AIC: 91.245, (AIC for lm: 92.646)
## LM test for residual autocorrelation
## test value: 0.059237, p-value: 0.80771
moran.test(
  residuals(TPT_SDM),
  W_matriks,
  zero.policy = TRUE
)
## 
##  Moran I test under randomisation
## 
## data:  residuals(TPT_SDM)  
## weights: W_matriks    
## 
## Moran I statistic standard deviate = 0.2034, p-value = 0.4194
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       -0.01070172       -0.03846154        0.01862671

PERBANDINGAN MODEL


Tujuan

menentukan model yang memiliki kemampuan terbaik dalam menjelaskan variasi Tingkat Pengangguran Terbuka berdasarkan kriteria pemilihan model yang digunakan.

PERBANDINGAN = data.frame(
  Model = c(
    "OLS",
    "SAR",
    "SEM",
    "SAC",
    "SDM"
  ),
  
  AIC = c(
    AIC(TPT_OLS),
    AIC(TPT_SAR),
    AIC(TPT_SEM),
    AIC(TPT_SAC),
    AIC(TPT_SDM)
  ),
  
  BIC = c(
    BIC(TPT_OLS),
    BIC(TPT_SAR),
    BIC(TPT_SEM),
    BIC(TPT_SAC),
    BIC(TPT_SDM)
  ),
  
  LogLik = c(
    as.numeric(logLik(TPT_OLS)),
    as.numeric(logLik(TPT_SAR)),
    as.numeric(logLik(TPT_SEM)),
    as.numeric(logLik(TPT_SAC)),
    as.numeric(logLik(TPT_SDM))
  )
)

PERBANDINGAN
##   Model      AIC       BIC    LogLik
## 1   OLS 91.42502  97.90420 -40.71251
## 2   SAR 87.50545  95.28047 -37.75272
## 3   SEM 89.30935  97.08437 -38.65467
## 4   SAC 89.47783  98.54869 -37.73892
## 5   SDM 91.24525 102.90778 -36.62262
AIC_BEST     = PERBANDINGAN[which.min(PERBANDINGAN$AIC), "Model"]
BIC_BEST     = PERBANDINGAN[which.min(PERBANDINGAN$BIC), "Model"]
LOGLIK_BEST  = PERBANDINGAN[which.max(PERBANDINGAN$LogLik), "Model"]

KESIMPULAN_MODEL <- data.frame(
  Kriteria = c(
    "AIC", 
    "BIC", 
    "LogLik"
  ),
  Model_Terpilih = c(
    AIC_BEST, 
    BIC_BEST, 
    LOGLIK_BEST
  )
)

KESIMPULAN_MODEL
##   Kriteria Model_Terpilih
## 1      AIC            SAR
## 2      BIC            SAR
## 3   LogLik            SDM
BEST_MODEL = names(which.max(table(c(AIC_BEST, BIC_BEST, LOGLIK_BEST))))
BEST_MODEL
## [1] "SAR"

EFEK MODEL


Tujuan

menginterpretasikan pengaruh langsung (direct effect), pengaruh tidak langsung (indirect effect), dan pengaruh total (total effect) dari variabel-variabel prediktor terhadap Tingkat Pengangguran Terbuka.

OBJEK           = paste0("TPT_", BEST_MODEL)
MODEL_TERPILIH  = get(OBJEK)

if (BEST_MODEL %in% c("SAR", "SAC", "SDM")) {
  
  EFEK <- impacts(
    MODEL_TERPILIH,
    listw = W_matriks,
    R = 1000
  )
  
  summary(
    EFEK,
    zstats = TRUE,
    short = TRUE
  )
  
} else if (BEST_MODEL == "SEM") {
  
  summary(MODEL_TERPILIH)
  
} else {
  
  summary(MODEL_TERPILIH)
  
}
## Impact measures (lag, exact):
##                              Direct   Indirect      Total
## TPAK dy/dx               -0.2443203 -0.1634285 -0.4077488
## scale(PDRB) dy/dx         0.3997751  0.2674139  0.6671890
## scale(PENGELUARAN) dy/dx -0.1932137 -0.1292427 -0.3224564
## ========================================================
## Simulation results ( variance matrix):
## ========================================================
## Simulated standard errors
##                              Direct  Indirect     Total
## TPAK dy/dx               0.06804577 0.1512811 0.1890925
## scale(PDRB) dy/dx        0.25908873 0.3825364 0.5841754
## scale(PENGELUARAN) dy/dx 0.28079700 0.3261582 0.5693486
## 
## Simulated z-values:
##                              Direct   Indirect     Total
## TPAK dy/dx               -3.5988350 -1.2490829 -2.294370
## scale(PDRB) dy/dx         1.5451488  0.8368064  1.233259
## scale(PENGELUARAN) dy/dx -0.6561403 -0.5159745 -0.619184
## 
## Simulated p-values:
##                          Direct     Indirect Total   
## TPAK dy/dx               0.00031965 0.21163  0.021769
## scale(PDRB) dy/dx        0.12231027 0.40270  0.217479
## scale(PENGELUARAN) dy/dx 0.51173387 0.60587  0.535795

PETA RESIDUAL


Tujuan

memvisualisasikan sebaran residual model terbaik sehingga dapat diketahui wilayah yang masih memiliki galat prediksi relatif besar maupun kecil.

PETA$RESIDUAL_TERBAIK <- residuals(MODEL_TERPILIH)

PETA_RESIDUAL = ggplot(data = PETA) +
  geom_sf(
    aes(
      fill = RESIDUAL_TERBAIK
    ),
    color = "black",
    linewidth = 0.3
  ) +
  scale_fill_viridis_c(
    option = "mako",
    name = "Residual"
  ) +
  geom_text(
    aes(
      x = X,
      y = Y,
      label = NOMOR
    ),
    color = "white",
    fontface = "bold",
    size = 2.5
  ) +
  theme_minimal() +
  theme(
    legend.position = "right",
    panel.border = element_rect(
      colour = "black",
      fill = NA,
      linewidth = 0.6
    )
  ) +
  labs(
    title = paste("Peta Residual (Model:", BEST_MODEL, ")"),
    x = NULL,
    y = NULL
  )

PETA_RESIDUAL