Data yang digunakan pada penelitian ini merupakan data sekunder yang diperoleh dari Dinas Kesehatan Kabupaten Sidoarjo dan Pemerintah Kabupaten Sidoarjo. Data yang digunakan mencakup data mengenai penderita tuberkulosis di Kabupaten Sidoarjo dan faktor-faktor yang diduga mempengaruhi jumlah kasus penyakit tuberkulosis.
| Simbol | Variabel | Keterangan | Skala Pengukuran |
|---|---|---|---|
| Y | Jumlah TB | Jumlah seluruh kasus TB | Rasio |
| X1 | Kepadatan Penduduk | Kepadatan penduduk (per km2) | Rasio |
| X2 | PHBS | Persentase RT Berperilaku Hidup Bersih dan Sehat | Rasio |
| X3 | Rumah Sehat | Persentase Rumah Sehat | Rasio |
| X4 | TTU | Tempat-Tempat Umum memenuhi syarat kesehatan | Rasio |
Berikut merupakan syntax untuk memasukkan data di R
data <- read.csv('E:/00. Kuliah/SEMESTER 7/Statistika Spasial/[] TUGAS 2/data.csv')
data
## Kecamatan Jumlah.TB Kepadatan PHBS Rumah.Sehat TTU x
## 1 TARIK 30 1878.20 51.10 79.72 100 112.5140
## 2 PRAMBON 42 2318.84 79.50 46.51 87 112.5909
## 3 KREMBUNG 72 2386.06 77.53 52.85 59 112.6449
## 4 PORONG 70 2997.82 100.93 153.79 154 112.7428
## 5 JABON 43 725.61 88.88 64.95 69 112.7839
## 6 TANGGULANGIN 66 3303.84 85.41 76.38 100 112.7342
## 7 CANDI 69 3638.92 70.59 78.65 86 112.7450
## 8 TULANGAN 89 3018.78 163.10 176.00 191 112.6551
## 9 WONOAYU 74 2418.57 57.35 88.74 100 112.6334
## 10 SUKODONO 139 3594.65 50.27 95.96 98 112.6607
## 11 SIDOARJO 169 3364.88 147.02 214.87 200 112.7360
## 12 BUDURAN 52 2392.86 71.20 95.23 80 112.7577
## 13 SEDATI 67 1243.91 72.44 72.40 100 112.7874
## 14 WARU 209 7492.65 113.76 122.78 199 112.7675
## 15 GEDANGAN 80 5217.79 106.82 165.78 170 112.7225
## 16 TAMAN 146 6923.56 125.89 98.11 188 112.6701
## 17 KRIAN 120 3852.08 127.12 138.93 137 112.5999
## 18 BALONGBENDO 36 2374.59 64.25 66.05 56 112.5277
## y
## 1 -7.452713
## 2 -7.474095
## 3 -7.512280
## 4 -7.533947
## 5 -7.546609
## 6 -7.510110
## 7 -7.491485
## 8 -7.486528
## 9 -7.434596
## 10 -7.408946
## 11 -7.460110
## 12 -7.445887
## 13 -7.419136
## 14 -7.354673
## 15 -7.402977
## 16 -7.369478
## 17 -7.410815
## 18 -7.417223
Dalam regresi, kita mengenal istilah variabel dependen (terikat) dan variabel independen (bebas), dimana variabel dependen dipengaruhi oleh variabel independen.
. \[\begin{array}{cccc} Y_1&=&\beta_0 + \beta_1 X_1+\epsilon_1& \\ \vdots & \vdots & \vdots& \\ Y_i&=&\beta_0 + \beta_1 X_i+\epsilon_i&\\ \vdots & \vdots & \vdots& \\ Y_n&=&\beta_0 + \beta_1 X_n+\epsilon_n & \end{array}\]
dimana,
\(Y_i\) : variabel dependen
\(X_i\) : variabel independen
\(\epsilon_i\) : residual
Berikut merupakan syntax pada software R untuk mendapatkan model regresi berganda
fit <- lm(Jumlah.TB~Kepadatan+PHBS+Rumah.Sehat+TTU, data=data)
summary(fit)
##
## Call:
## lm(formula = Jumlah.TB ~ Kepadatan + PHBS + Rumah.Sehat + TTU,
## data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -58.03 -15.69 -11.28 19.48 52.76
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6.533576 24.554507 -0.266 0.7943
## Kepadatan 0.015553 0.007654 2.032 0.0631 .
## PHBS -0.022399 0.446198 -0.050 0.9607
## Rumah.Sehat 0.145052 0.358741 0.404 0.6925
## TTU 0.245617 0.502171 0.489 0.6329
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 32.63 on 13 degrees of freedom
## Multiple R-squared: 0.6689, Adjusted R-squared: 0.567
## F-statistic: 6.566 on 4 and 13 DF, p-value: 0.004054
Berikut merupakan syntax untuk mendapatkan koefisien, confidence interval, predicted value, residual, tabel anova, matrix kovarian
coefficients(fit) # Model Coeffeicients
## (Intercept) Kepadatan PHBS Rumah.Sehat TTU
## -6.53357606 0.01555278 -0.02239910 0.14505179 0.24561713
confint(fit, level=0.95) # Confidence Interval
## 2.5 % 97.5 %
## (Intercept) -5.958036e+01 46.51321081
## Kepadatan -9.816048e-04 0.03208717
## PHBS -9.863502e-01 0.94155201
## Rumah.Sehat -6.299604e-01 0.92006403
## TTU -8.392584e-01 1.33049266
fitted(fit) # Predicted value
## 1 2 3 4 5 6 7
## 57.65831 55.86516 50.99709 97.96268 29.12954 78.57799 81.01200
## 8 9 10 11 12 13 14
## 109.20555 67.23094 86.23688 122.79726 62.54989 46.25356 174.13713
## 15 16 17 18
## 138.02651 158.73428 104.33121 52.29400
resids <- residuals(fit) #Residuals
anova(fit) # Anova Table
## Analysis of Variance Table
##
## Response: Jumlah.TB
## Df Sum Sq Mean Sq F value Pr(>F)
## Kepadatan 1 24591.1 24591.1 23.0898 0.0003436 ***
## PHBS 1 2021.4 2021.4 1.8980 0.1915590
## Rumah.Sehat 1 1103.8 1103.8 1.0364 0.3272370
## TTU 1 254.8 254.8 0.2392 0.6329123
## Residuals 13 13845.2 1065.0
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
vcov(fit) # Covariance Matrix
## (Intercept) Kepadatan PHBS Rumah.Sehat
## (Intercept) 602.92380417 -5.428789e-02 -5.4390222296 -1.326453204
## Kepadatan -0.05428789 5.857611e-05 0.0007637518 0.001345684
## PHBS -5.43902223 7.637518e-04 0.1990922163 -0.017996356
## Rumah.Sehat -1.32645320 1.345684e-03 -0.0179963564 0.128694914
## TTU 2.26250773 -2.893317e-03 -0.1115125150 -0.123688581
## TTU
## (Intercept) 2.262507727
## Kepadatan -0.002893317
## PHBS -0.111512515
## Rumah.Sehat -0.123688581
## TTU 0.252176200
Berikut merupakan syntax untuk mendapatkan residual plot
layout(matrix(c(1,2,3,4),2,2))
plot(fit)
Model Geographically Weighted Regression (GWR) adalah pengembangan dari model regresi dimana setiap parameter dihitung pada setiap titik lokasi, sehingga setiap titik lokasi geografis mempunyai nilai parameter regresi yang berbeda-beda.
library(spgwr)
## Loading required package: sp
## Loading required package: spData
## To access larger datasets in this package, install the spDataLarge
## package with: `install.packages('spDataLarge',
## repos='https://nowosad.github.io/drat/', type='source'))`
## NOTE: This package does not constitute approval of GWR
## as a method of spatial analysis; see example(gwr)
library(ggplot2)
library(maptools)
## Checking rgeos availability: FALSE
## Note: when rgeos is not available, polygon geometry computations in maptools depend on gpclib,
## which has a restricted licence. It is disabled by default;
## to enable gpclib, type gpclibPermit()
colours <- c("dark blue","blue","red","dark red")
map.resids <- SpatialPointsDataFrame(data=data.frame(resids), coords=cbind(data$x,data$y))
spplot(map.resids, cuts=quantile(resids), col.region=colours, cex=1)
GWRbandwidth <- gwr.sel(Jumlah.TB~Kepadatan+PHBS+Rumah.Sehat+TTU,data=data,coords=cbind(data$x,data$y),adapt=TRUE)
## Adaptive q: 0.381966 CV score: 33295.85
## Adaptive q: 0.618034 CV score: 32037.62
## Adaptive q: 0.763932 CV score: 31830.35
## Adaptive q: 0.7603846 CV score: 31824.57
## Adaptive q: 0.7241316 CV score: 31756.41
## Adaptive q: 0.6836059 CV score: 31865.75
## Adaptive q: 0.7086522 CV score: 31790.81
## Adaptive q: 0.7304035 CV score: 31769.48
## Adaptive q: 0.7220039 CV score: 31752.92
## Adaptive q: 0.716904 CV score: 31767.23
## Adaptive q: 0.7217347 CV score: 31753.67
## Adaptive q: 0.7226237 CV score: 31753.18
## Adaptive q: 0.7222407 CV score: 31752.35
## Adaptive q: 0.7222855 CV score: 31752.45
## Adaptive q: 0.7221964 CV score: 31752.39
## Adaptive q: 0.7222407 CV score: 31752.35
gwr.model = gwr(Jumlah.TB~Kepadatan+PHBS+Rumah.Sehat+TTU,data=data,coords=cbind(data$x,data$y),adapt=GWRbandwidth,hatmatrix=TRUE,se.fit=TRUE)
gwr.model
## Call:
## gwr(formula = Jumlah.TB ~ Kepadatan + PHBS + Rumah.Sehat + TTU,
## data = data, coords = cbind(data$x, data$y), adapt = GWRbandwidth,
## hatmatrix = TRUE, se.fit = TRUE)
## Kernel function: gwr.Gauss
## Adaptive quantile: 0.7222407 (about 13 of 18 data points)
## Summary of GWR coefficient estimates at data points:
## Min. 1st Qu. Median 3rd Qu. Max.
## X.Intercept. -9.00579382 -2.51201235 0.47332953 2.07184558 5.64828755
## Kepadatan 0.01048460 0.01224336 0.01398389 0.01679369 0.01810428
## PHBS -0.24154825 -0.20263460 -0.10037461 -0.05222137 -0.01455769
## Rumah.Sehat -0.00079279 0.07473275 0.14288525 0.27137548 0.31821910
## TTU 0.02689594 0.10574226 0.31579179 0.46988987 0.57049286
## Global
## X.Intercept. -6.5336
## Kepadatan 0.0156
## PHBS -0.0224
## Rumah.Sehat 0.1451
## TTU 0.2456
## Number of data points: 18
## Effective number of parameters (residual: 2traceS - traceS'S): 7.420515
## Effective degrees of freedom (residual: 2traceS - traceS'S): 10.57949
## Sigma (residual: 2traceS - traceS'S): 33.16986
## Effective number of parameters (model: traceS): 6.378314
## Effective degrees of freedom (model: traceS): 11.62169
## Sigma (model: traceS): 31.64764
## Sigma (ML): 25.4296
## AICc (GWR p. 61, eq 2.33; p. 96, eq. 4.21): 195.181
## AIC (GWR p. 96, eq. 4.22): 173.953
## Residual sum of squares: 11639.97
## Quasi-global R2: 0.7216403
result <- as.data.frame(gwr.model$SDF)
coefresult <- data.frame(result$Kepadatan,result$PHBS,result$Rumah.Sehat,result$TTU)
coefresult
## result.Kepadatan result.PHBS result.Rumah.Sehat result.TTU
## 1 0.01783067 -0.01455769 0.2706999619 0.07973598
## 2 0.01810428 -0.03355242 0.3182191033 0.02689594
## 3 0.01645718 -0.03129216 0.2758566641 0.07796480
## 4 0.01333893 -0.05373267 0.1180410837 0.30479106
## 5 0.01310482 -0.05171760 0.0846326212 0.34645118
## 6 0.01305021 -0.08194452 0.1173986841 0.32679252
## 7 0.01219369 -0.11738756 0.0835515729 0.39937128
## 8 0.01610247 -0.08331338 0.2938652591 0.09018505
## 9 0.01690586 -0.12508812 0.2943398198 0.11726901
## 10 0.01511836 -0.18792195 0.2158096403 0.26149813
## 11 0.01058623 -0.21258465 0.0521316410 0.51773029
## 12 0.01048460 -0.21618349 0.0108284625 0.57049286
## 13 0.01106262 -0.20397037 -0.0007927931 0.56925451
## 14 0.01239236 -0.20491699 0.0436116461 0.50331320
## 15 0.01207436 -0.24154825 0.0717931423 0.49339607
## 16 0.01462885 -0.19862731 0.1677294256 0.33172606
## 17 0.01732398 -0.08336165 0.2716006550 0.12287629
## 18 0.01766362 -0.03206878 0.2630283911 0.10190001