##Pemodelan Regresi Data Panel terhadap Faktor-Faktor yang Mempengaruhi Tingkat Pengangguran Terbuka di Kab/Kota Provinsi Sumatera Barat Tahun 2018-2023## #Data
library(readxl)
Data_Projek_ADP <- read_excel("C:/Users/asus/Downloads/Data Projek ADP.xlsx")
Data_Projek_ADP$`Kabupaten/Kota`<-as.factor(Data_Projek_ADP$`Kabupaten/Kota`)
Data_Projek_ADP$Tahun<-as.factor(Data_Projek_ADP$Tahun)
Data_Projek_ADP$Y<-Data_Projek_ADP$TPT
Data_Projek_ADP$X1<-Data_Projek_ADP$IPM
Data_Projek_ADP$X2<-Data_Projek_ADP$PDRB
Data_Projek_ADP$X3<-Data_Projek_ADP$`Gini Ratio`
Data_Projek_ADP<-Data_Projek_ADP[,-c(3:6)]
dim(Data_Projek_ADP)
## [1] 114 6
#Eksplorasi Data
library(psych)
YTahun <- describeBy(Data_Projek_ADP$Y, group = Data_Projek_ADP$Tahun)
YTahun
##
## Descriptive statistics by group
## group: 2018
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 19 5.22 1.74 5.82 5.16 1.79 2.31 9.29 6.98 0.24 -0.44 0.4
## ------------------------------------------------------------
## group: 2019
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 19 5.08 1.55 4.91 5.03 1.65 2.3 8.74 6.44 0.33 -0.23 0.36
## ------------------------------------------------------------
## group: 2020
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 19 6.29 2.34 5.62 6.05 1.57 3.03 13.64 10.61 1.45 2.48 0.54
## ------------------------------------------------------------
## group: 2021
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 19 5.56 2.33 5.02 5.29 1.41 2.25 13.37 11.12 1.8 4.09 0.54
## ------------------------------------------------------------
## group: 2022
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 19 5.28 1.95 5 5.13 1.32 1.39 11.69 10.3 1.41 4.01 0.45
## ------------------------------------------------------------
## group: 2023
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 19 5.11 1.86 4.99 5 0.74 1.33 10.86 9.53 0.98 2.88 0.43
YKabKota <- describeBy(Data_Projek_ADP$Y, group = Data_Projek_ADP$`Kabupaten/Kota`)
YKabKota
##
## Descriptive statistics by group
## group: Kab Agam
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 4.88 0.16 4.93 4.88 0.12 4.61 5.06 0.45 -0.56 -1.33 0.06
## ------------------------------------------------------------
## group: Kab Dharmasraya
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 5.31 0.84 5.18 5.31 0.9 4.02 6.23 2.21 -0.18 -1.58 0.34
## ------------------------------------------------------------
## group: Kab Kepulauan Mentawai
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 2.45 1.01 2.55 2.45 1.13 1.33 3.98 2.65 0.18 -1.65 0.41
## ------------------------------------------------------------
## group: Kab Lima Puluh Kota
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 3 0.71 2.88 3 0.9 2.25 3.95 1.7 0.22 -1.94 0.29
## ------------------------------------------------------------
## group: Kab Padang Pariaman
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 7.16 0.92 6.86 7.16 0.77 6.08 8.41 2.33 0.29 -1.87 0.38
## ------------------------------------------------------------
## group: Kab Pasaman
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 5.29 0.4 5.19 5.29 0.25 4.92 6.04 1.12 0.88 -0.85 0.16
## ------------------------------------------------------------
## group: Kab Pasaman Barat
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 5.03 1.06 4.88 5.03 0.98 3.36 6.33 2.97 -0.21 -1.49 0.43
## ------------------------------------------------------------
## group: Kab Pesisir Selatan
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 5.73 0.9 5.99 5.73 0.77 4.61 7 2.39 -0.05 -1.71 0.37
## ------------------------------------------------------------
## group: Kab Sijunjung
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 4.22 0.85 4.18 4.22 0.96 3.22 5.3 2.08 0.05 -2.06 0.35
## ------------------------------------------------------------
## group: Kab Solok
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 5.17 0.66 4.86 5.17 0.29 4.65 6.12 1.47 0.49 -1.9 0.27
## ------------------------------------------------------------
## group: Kab Solok Selatan
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 4.58 1.24 4.88 4.58 1.27 2.57 5.84 3.27 -0.5 -1.53 0.5
## ------------------------------------------------------------
## group: Kab Tanah Datar
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 4.65 0.96 4.71 4.65 0.99 3.2 5.91 2.71 -0.18 -1.56 0.39
## ------------------------------------------------------------
## group: Kota Bukittinggi
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 6.16 1.09 6.14 6.16 1.67 4.9 7.51 2.61 0.03 -1.93 0.45
## ------------------------------------------------------------
## group: Kota Padang
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 11.27 2.03 11.27 11.27 3.02 8.74 13.64 4.9 -0.02 -1.96 0.83
## ------------------------------------------------------------
## group: Kota Padang Panjang
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 5.36 0.99 5.12 5.36 0.48 4.38 7.22 2.84 0.89 -0.77 0.4
## ------------------------------------------------------------
## group: Kota Pariaman
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 5.66 0.31 5.7 5.66 0.25 5.19 6.09 0.9 -0.19 -1.38 0.13
## ------------------------------------------------------------
## group: Kota Payakumbuh
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 5.2 1.15 5 5.2 1.42 3.95 6.68 2.73 0.21 -1.95 0.47
## ------------------------------------------------------------
## group: Kota Sawahlunto
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 6.22 1.22 6.15 6.22 1.36 4.98 8.2 3.22 0.39 -1.49 0.5
## ------------------------------------------------------------
## group: Kota Solok
## vars n mean sd median trimmed mad min max range skew kurtosis se
## X1 1 6 5.7 1.81 5.59 5.7 2.34 3.72 8.35 4.63 0.2 -1.79 0.74
#GrafikK Pergerakan Y
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
plot_ly(Data_Projek_ADP, x = Data_Projek_ADP$Tahun, y = Data_Projek_ADP$Y,
type = 'scatter', mode = 'lines+markers',
color = Data_Projek_ADP$`Kabupaten/Kota`)
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
##Penduga Parameter ##Model Gabungan
library(plm)
common<-plm(Y~X1+X2+X3, data = Data_Projek_ADP, model = "pooling")
summary(common)
## Pooling Model
##
## Call:
## plm(formula = Y ~ X1 + X2 + X3, data = Data_Projek_ADP, model = "pooling")
##
## Balanced Panel: n = 19, T = 6, N = 114
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -2.524560 -0.983069 -0.053537 0.756945 3.201944
##
## Coefficients:
## Estimate Std. Error t-value Pr(>|t|)
## (Intercept) -8.9745e+00 1.8934e+00 -4.7400 6.440e-06 ***
## X1 1.3145e-01 2.6311e-02 4.9961 2.219e-06 ***
## X2 7.2389e-05 9.1886e-06 7.8782 2.561e-12 ***
## X3 1.3282e+01 4.0064e+00 3.3151 0.001241 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 446.16
## Residual Sum of Squares: 178.65
## R-Squared: 0.59958
## Adj. R-Squared: 0.58866
## F-statistic: 54.9047 on 3 and 110 DF, p-value: < 2.22e-16
residuals(common)
## 1 2 3 4 5 6
## -0.319820830 -0.579192026 -1.193164937 -0.752317104 -1.491576124 -1.131371184
## 7 8 9 10 11 12
## -0.528416712 0.191692032 0.320291617 0.086439657 0.886260052 0.653228515
## 13 14 15 16 17 18
## -1.011344356 -0.958456379 0.617528582 -1.259724085 -1.646244902 -2.211730118
## 19 20 21 22 23 24
## -2.198099084 -2.175773435 -1.378368043 -2.524560319 -0.780990898 -0.542266168
## 25 26 27 28 29 30
## 1.430229936 0.292118627 2.823254952 2.890439556 1.029997691 0.637956233
## 31 32 33 34 35 36
## 2.256267039 0.490563313 0.263267625 0.916137785 1.461718475 0.832897479
## 37 38 39 40 41 42
## -1.437970172 -0.125309397 -0.107264748 0.098110355 0.947239267 0.940274971
## 43 44 45 46 47 48
## 1.550650652 1.499049138 2.131875155 1.169443005 -0.312524829 -0.516273725
## 49 50 51 52 53 54
## -1.207749100 -0.833214436 0.791517274 -0.998746198 0.469744605 -0.157692528
## 55 56 57 58 59 60
## 1.136682672 -0.154425692 -0.297052117 0.070492878 1.110445226 0.135891215
## 61 62 63 64 65 66
## 1.335217243 0.500711605 0.824477204 0.400036457 -0.521555899 -2.060723595
## 67 68 69 70 71 72
## -1.089788230 -1.948236480 -0.532749658 -0.445467741 0.619000697 -0.253915737
## 73 74 75 76 77 78
## 0.628201704 0.389505880 1.734919770 -0.007337763 -1.789536456 -0.991272682
## 79 80 81 82 83 84
## -1.279048438 -1.816258167 3.030092799 2.120836102 -0.321171258 -1.118338751
## 85 86 87 88 89 90
## 0.080223671 -1.426838609 0.400482410 -0.775449902 -0.834057646 0.030268323
## 91 92 93 94 95 96
## 0.238984377 0.025436884 -0.099736515 0.338298633 -0.299205046 -0.134195038
## 97 98 99 100 101 102
## -1.813988120 -1.433295390 0.451310517 0.302767831 -1.069901866 -1.567140650
## 103 104 105 106 107 108
## 1.103140517 2.194049856 3.201944443 1.384277660 -0.400069915 -0.463924739
## 109 110 111 112 113 114
## 0.564595378 1.839078653 2.926370961 -0.185089154 -1.728157290 -1.557844770
shapiro.test(residuals(common))
##
## Shapiro-Wilk normality test
##
## data: residuals(common)
## W = 0.98238, p-value = 0.1394
#Model Pengaruh Tetap
fixed<-plm(Y~X1+X2+X3, data = Data_Projek_ADP, model = "within")
summary(fixed)
## Oneway (individual) effect Within Model
##
## Call:
## plm(formula = Y ~ X1 + X2 + X3, data = Data_Projek_ADP, model = "within")
##
## Balanced Panel: n = 19, T = 6, N = 114
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -2.344018 -0.552214 -0.023319 0.640261 2.622831
##
## Coefficients:
## Estimate Std. Error t-value Pr(>|t|)
## X1 1.0191e-01 1.0196e-01 0.9996 0.3201
## X2 -1.8214e-06 5.3197e-05 -0.0342 0.9728
## X3 7.8326e+00 5.1035e+00 1.5348 0.1283
##
## Total Sum of Squares: 106.56
## Residual Sum of Squares: 103.72
## R-Squared: 0.026609
## Adj. R-Squared: -0.19558
## F-statistic: 0.838303 on 3 and 92 DF, p-value: 0.47628
fixef(fixed)
## Kab Agam Kab Dharmasraya Kab Kepulauan Mentawai
## -4.63572 -4.22899 -6.24544
## Kab Lima Puluh Kota Kab Padang Pariaman Kab Pasaman
## -5.99480 -2.29709 -3.74264
## Kab Pasaman Barat Kab Pesisir Selatan Kab Sijunjung
## -4.17570 -3.45499 -5.02069
## Kab Solok Kab Solok Selatan Kab Tanah Datar
## -4.04303 -4.81991 -4.92237
## Kota Bukittinggi Kota Padang Kota Padang Panjang
## -4.33236 0.32768 -5.09059
## Kota Pariaman Kota Payakumbuh Kota Sawahlunto
## -4.63073 -5.26502 -3.67745
## Kota Solok
## -4.49668
#Model Pengaruh Acak
random<-plm(Y~X1+X2+X3, data = Data_Projek_ADP, model = "random")
summary(random)
## Oneway (individual) effect Random Effect Model
## (Swamy-Arora's transformation)
##
## Call:
## plm(formula = Y ~ X1 + X2 + X3, data = Data_Projek_ADP, model = "random")
##
## Balanced Panel: n = 19, T = 6, N = 114
##
## Effects:
## var std.dev share
## idiosyncratic 1.1274 1.0618 0.656
## individual 0.5924 0.7697 0.344
## theta: 0.5093
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -2.135111 -0.702342 -0.079934 0.715820 3.097818
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) -8.1864e+00 3.0258e+00 -2.7055 0.006820 **
## X1 1.2864e-01 3.9244e-02 3.2779 0.001046 **
## X2 6.7972e-05 1.5136e-05 4.4908 7.096e-06 ***
## X3 1.1429e+01 3.9997e+00 2.8574 0.004271 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 188.34
## Residual Sum of Squares: 124.38
## R-Squared: 0.33959
## Adj. R-Squared: 0.32158
## Chisq: 56.5627 on 3 DF, p-value: 3.186e-12
ranef(random)
## Kab Agam Kab Dharmasraya Kab Kepulauan Mentawai
## -0.682807400 0.188174318 -0.860075984
## Kab Lima Puluh Kota Kab Padang Pariaman Kab Pasaman
## -1.280834604 1.158203817 0.747429043
## Kab Pasaman Barat Kab Pesisir Selatan Kab Sijunjung
## 0.022821656 0.659511832 -0.277373081
## Kab Solok Kab Solok Selatan Kab Tanah Datar
## 0.226362546 0.033772460 -0.481307923
## Kota Bukittinggi Kota Padang Kota Padang Panjang
## 0.006005824 0.344263304 -0.296691583
## Kota Pariaman Kota Payakumbuh Kota Sawahlunto
## 0.014637350 -0.620781804 0.886715917
## Kota Solok
## 0.211974311
residuals(random, effects="individu")
## 1 2 3 4 5 6
## 0.112481204 -0.149958187 -0.712556202 -0.277871397 -0.956191176 -0.664071555
## 7 8 9 10 11 12
## -0.711509797 0.039271329 0.173300940 -0.079525845 0.763532278 0.544737302
## 13 14 15 16 17 18
## -0.467266326 -0.354223210 1.111863213 -0.674837295 -1.219334465 -1.731879163
## 19 20 21 22 23 24
## -1.343993429 -1.398768350 -0.628139042 -1.730153119 -0.043970290 0.177497032
## 25 26 27 28 29 30
## 0.699919634 -0.430253883 2.018329252 2.110380430 0.224099526 -0.130553094
## 31 32 33 34 35 36
## 1.680835412 0.038717153 -0.220039046 0.320381656 0.838648903 0.240248700
## 37 38 39 40 41 42
## -1.449956981 -0.144544164 -0.167589085 0.047110888 0.936765745 0.866724009
## 43 44 45 46 47 48
## 1.045388304 0.983404839 1.652059539 0.673311885 -0.812205944 -0.984139719
## 49 50 51 52 53 54
## -1.028135506 -0.661714838 0.926096822 -0.860072192 0.565625283 -0.017549960
## 55 56 57 58 59 60
## 1.006922619 -0.312088372 -0.465702762 -0.152504173 0.891194096 -0.089907821
## 61 62 63 64 65 66
## 1.312482902 0.455008583 0.805734082 0.327343801 -0.634476408 -2.135111479
## 67 68 69 70 71 72
## -0.767159850 -1.637708027 -0.226521635 -0.178974818 0.895885751 0.047797128
## 73 74 75 76 77 78
## 0.721120177 0.357455159 1.698780075 -0.002501497 -1.720060003 -1.031501212
## 79 80 81 82 83 84
## -1.175416837 -1.748994581 3.097817842 2.259457837 -0.126619672 -0.971070384
## 85 86 87 88 89 90
## 0.259959121 -1.184629012 0.777279493 -0.560639743 -0.633711655 0.191067459
## 91 92 93 94 95 96
## 0.261379805 0.021150700 -0.080342777 0.342666187 -0.344149330 -0.143935791
## 97 98 99 100 101 102
## -1.379030009 -1.041428495 0.934271141 0.771661768 -0.604790074 -1.088294561
## 103 104 105 106 107 108
## 0.511296922 1.566403465 2.599018599 0.774019837 -0.970332752 -1.041409791
## 109 110 111 112 113 114
## 0.418228950 1.649188841 2.764326049 -0.362540858 -1.880532987 -1.766559042
#Uji Spesifikasi Model #Uji Cow
pFtest(fixed, common)
##
## F test for individual effects
##
## data: Y ~ X1 + X2 + X3
## F = 3.6923, df1 = 18, df2 = 92, p-value = 1.768e-05
## alternative hypothesis: significant effects
#Uji Hausman
phtest(fixed, random)
##
## Hausman Test
##
## data: Y ~ X1 + X2 + X3
## chisq = 3.3331, df = 3, p-value = 0.3431
## alternative hypothesis: one model is inconsistent
#Uji Lagrange Multipliers
plmtest(random, effect="individual", type="bp")
##
## Lagrange Multiplier Test - (Breusch-Pagan)
##
## data: Y ~ X1 + X2 + X3
## chisq = 21.82, df = 1, p-value = 2.995e-06
## alternative hypothesis: significant effects
##Ujia Asumsi Model Terpilih
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:psych':
##
## logit
library(lmtest)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
#Uji Asumsi Normalitas
residuals <- random$residuals
shapiro.test(residuals)
##
## Shapiro-Wilk normality test
##
## data: residuals
## W = 0.98112, p-value = 0.108
plot(residuals)
#Uji Multikolinearitas
vif(random)
## X1 X2 X3
## 1.139489 1.140026 1.001328
#Uji Heteroskedastisitas
lmtest::bptest(random)
##
## studentized Breusch-Pagan test
##
## data: random
## BP = 2.6607, df = 3, p-value = 0.4469
#Uji Autokorelasi
lmtest::bgtest(random)
##
## Breusch-Godfrey test for serial correlation of order up to 1
##
## data: random
## LM test = 31.893, df = 1, p-value = 1.629e-08
#Uji Signifikansi Parameter
summary(random)
## Oneway (individual) effect Random Effect Model
## (Swamy-Arora's transformation)
##
## Call:
## plm(formula = Y ~ X1 + X2 + X3, data = Data_Projek_ADP, model = "random")
##
## Balanced Panel: n = 19, T = 6, N = 114
##
## Effects:
## var std.dev share
## idiosyncratic 1.1274 1.0618 0.656
## individual 0.5924 0.7697 0.344
## theta: 0.5093
##
## Residuals:
## Min. 1st Qu. Median 3rd Qu. Max.
## -2.135111 -0.702342 -0.079934 0.715820 3.097818
##
## Coefficients:
## Estimate Std. Error z-value Pr(>|z|)
## (Intercept) -8.1864e+00 3.0258e+00 -2.7055 0.006820 **
## X1 1.2864e-01 3.9244e-02 3.2779 0.001046 **
## X2 6.7972e-05 1.5136e-05 4.4908 7.096e-06 ***
## X3 1.1429e+01 3.9997e+00 2.8574 0.004271 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Total Sum of Squares: 188.34
## Residual Sum of Squares: 124.38
## R-Squared: 0.33959
## Adj. R-Squared: 0.32158
## Chisq: 56.5627 on 3 DF, p-value: 3.186e-12