langkah 1 menginstal packages

library(plm)
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric

langkah 2 membaca data

library(readxl)
Data_Panel_Rahmat <- read_excel("C:/Users/ASUS/OneDrive/Documents/Data Panel Rahmat.xlsx")
View(Data_Panel_Rahmat)

Langkah 3: Membuat Deskripsi Data yang digunakan

str(Data_Panel_Rahmat)
## tibble [30 x 5] (S3: tbl_df/tbl/data.frame)
##  $ Kabupaten: chr [1:30] "Halmahera Barat" "Halmahera Barat" "Halmahera Barat" "Halmahera Tengah" ...
##  $ Tahun    : num [1:30] 2017 2018 2019 2017 2018 ...
##  $ TPT      : num [1:30] 2.19 3.26 3.39 3.95 4.59 4.1 5.86 5.34 4.93 4.68 ...
##  $ IPM      : num [1:30] 64.2 64.2 65.3 63.9 64.7 ...
##  $ Miskin   : num [1:30] 8.74 8.74 8.59 14.15 13.94 ...
summary(Data_Panel_Rahmat)
##   Kabupaten             Tahun           TPT             IPM       
##  Length:30          Min.   :2017   Min.   :2.190   Min.   :59.03  
##  Class :character   1st Qu.:2017   1st Qu.:4.390   1st Qu.:62.72  
##  Mode  :character   Median :2018   Median :4.920   Median :64.42  
##                     Mean   :2018   Mean   :4.947   Mean   :65.92  
##                     3rd Qu.:2019   3rd Qu.:5.883   3rd Qu.:67.11  
##                     Max.   :2019   Max.   :7.710   Max.   :80.03  
##      Miskin      
##  Min.   : 2.730  
##  1st Qu.: 4.857  
##  Median : 7.220  
##  Mean   : 7.918  
##  3rd Qu.: 8.852  
##  Max.   :15.390
names(Data_Panel_Rahmat)
## [1] "Kabupaten" "Tahun"     "TPT"       "IPM"       "Miskin"

Langkah 4: membuat Estimasi Model regresi data panel dari ketiga dari ketiga model yang ada 1. 1. Pooled Least Square (Common Effect)

CEM=plm(Miskin~TPT+IPM, data = Data_Panel_Rahmat, model = "pooling")
summary(CEM)
## Pooling Model
## 
## Call:
## plm(formula = Miskin ~ TPT + IPM, data = Data_Panel_Rahmat, model = "pooling")
## 
## Balanced Panel: n = 10, T = 3, N = 30
## 
## Residuals:
##     Min.  1st Qu.   Median  3rd Qu.     Max. 
## -4.83653 -1.70830 -0.77685  1.06056  6.83186 
## 
## Coefficients:
##             Estimate Std. Error t-value Pr(>|t|)   
## (Intercept) 26.67746    7.76817  3.4342 0.001934 **
## TPT         -1.47390    0.58260 -2.5299 0.017555 * 
## IPM         -0.17396    0.12282 -1.4164 0.168094   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    437.14
## Residual Sum of Squares: 306.04
## R-Squared:      0.29991
## Adj. R-Squared: 0.24805
## F-statistic: 5.78323 on 2 and 27 DF, p-value: 0.0081204
  1. model fixed effect
FE=plm(Miskin~TPT+IPM,data=Data_Panel_Rahmat,model="within","effect"="time",index=c("Kabupaten","Tahun"))
summary(FE)
## Oneway (time) effect Within Model
## 
## Call:
## plm(formula = Miskin ~ TPT + IPM, data = Data_Panel_Rahmat, effect = "time", 
##     model = "within", index = c("Kabupaten", "Tahun"))
## 
## Balanced Panel: n = 10, T = 3, N = 30
## 
## Residuals:
##     Min.  1st Qu.   Median  3rd Qu.     Max. 
## -4.93550 -1.75251 -0.69127  1.14713  6.79670 
## 
## Coefficients:
##     Estimate Std. Error t-value Pr(>|t|)  
## TPT -1.49461    0.62154 -2.4047  0.02392 *
## IPM -0.17172    0.12942 -1.3268  0.19657  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    436.61
## Residual Sum of Squares: 305.49
## R-Squared:      0.30033
## Adj. R-Squared: 0.18838
## F-statistic: 5.3656 on 2 and 25 DF, p-value: 0.011512
  1. Model Random effect
RE=plm(Miskin~TPT+IPM,data=Data_Panel_Rahmat,model="random",index=c("Kabupaten","Tahun"))
summary(RE)
## Oneway (individual) effect Random Effect Model 
##    (Swamy-Arora's transformation)
## 
## Call:
## plm(formula = Miskin ~ TPT + IPM, data = Data_Panel_Rahmat, model = "random", 
##     index = c("Kabupaten", "Tahun"))
## 
## Balanced Panel: n = 10, T = 3, N = 30
## 
## Effects:
##                    var  std.dev share
## idiosyncratic  0.03242  0.18006 0.002
## individual    13.69203  3.70027 0.998
## theta: 0.9719
## 
## Residuals:
##      Min.   1st Qu.    Median   3rd Qu.      Max. 
## -0.490007 -0.098475  0.022816  0.080541  0.384218 
## 
## Coefficients:
##              Estimate Std. Error z-value Pr(>|z|)  
## (Intercept) -1.624186   4.570986 -0.3553  0.72235  
## TPT         -0.099330   0.074243 -1.3379  0.18093  
## IPM          0.152192   0.063989  2.3784  0.01739 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    1.4754
## Residual Sum of Squares: 0.99579
## R-Squared:      0.32507
## Adj. R-Squared: 0.27508
## Chisq: 13.0044 on 2 DF, p-value: 0.0015002

Langkah 5: Menentukan model terbaik yang akan digunakan

phtest(FE,RE)
## 
##  Hausman Test
## 
## data:  Miskin ~ TPT + IPM
## chisq = 22.376, df = 2, p-value = 1.384e-05
## alternative hypothesis: one model is inconsistent

Langkah 5: Melakukan Pengujian Breusch-Pangan

m=plm(Miskin~TPT+IPM, data = Data_Panel_Rahmat, model = "within", index = c("Kabupaten","Tahun"))
plmtest(m, effect = "twoways", type = "bp")#uji efek individu maupun waktu
## 
##  Lagrange Multiplier Test - two-ways effects (Breusch-Pagan) for
##  balanced panels
## 
## data:  Miskin ~ TPT + IPM
## chisq = 27.657, df = 2, p-value = 9.872e-07
## alternative hypothesis: significant effects
plmtest(m,effect = "individual") # uji efek individu 
## 
##  Lagrange Multiplier Test - (Honda) for balanced panels
## 
## data:  Miskin ~ TPT + IPM
## normal = 5.1037, p-value = 1.665e-07
## alternative hypothesis: significant effects
plmtest(m,effect = "time",type = "bp")#uji efek waktu
## 
##  Lagrange Multiplier Test - time effects (Breusch-Pagan) for balanced
##  panels
## 
## data:  Miskin ~ TPT + IPM
## chisq = 1.6085, df = 1, p-value = 0.2047
## alternative hypothesis: significant effects

Langkah 6: Pembuatan Model

model1=plm(Miskin~TPT+IPM, data = Data_Panel_Rahmat, model = "within", effect = "time", index = c("Kabupaten","Tahun"))
summary(model1)
## Oneway (time) effect Within Model
## 
## Call:
## plm(formula = Miskin ~ TPT + IPM, data = Data_Panel_Rahmat, effect = "time", 
##     model = "within", index = c("Kabupaten", "Tahun"))
## 
## Balanced Panel: n = 10, T = 3, N = 30
## 
## Residuals:
##     Min.  1st Qu.   Median  3rd Qu.     Max. 
## -4.93550 -1.75251 -0.69127  1.14713  6.79670 
## 
## Coefficients:
##     Estimate Std. Error t-value Pr(>|t|)  
## TPT -1.49461    0.62154 -2.4047  0.02392 *
## IPM -0.17172    0.12942 -1.3268  0.19657  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    436.61
## Residual Sum of Squares: 305.49
## R-Squared:      0.30033
## Adj. R-Squared: 0.18838
## F-statistic: 5.3656 on 2 and 25 DF, p-value: 0.011512
fixef(model1,type="level")
##   2017   2018   2019 
## 26.787 26.452 26.657

Langkah 7: Pengujian Diagnostik

pbgtest(FE)
## 
##  Breusch-Godfrey/Wooldridge test for serial correlation in panel models
## 
## data:  Miskin ~ TPT + IPM
## chisq = 11.997, df = 3, p-value = 0.007395
## alternative hypothesis: serial correlation in idiosyncratic errors

Uji hipotesis korelasi serial • Hipotesis H0 : tidak ada korelasi serial pada komponen galat H1 : ada korelasi serial pada komponen galat • Tingkat signifikansi α = 0,05 • Statistik uji P-value tercantum pada tabel dibawah. • Daerah kritik H0 ditolak jika P-value < α Berdasarkan perhitungan di atas p value di peroleh 0.007, di mana lebih kecil dari 0.05 terdapat korelasi serial

bptest(FE)
## 
##  studentized Breusch-Pagan test
## 
## data:  FE
## BP = 6.5851, df = 2, p-value = 0.03716

Uji Heteroskedasitas • Hipotesis H0 : heteroskedasitas H1 : heteroskedastisitas • Tingkat signifikansi α = 0,05 • Statistik uji P-value tercantum pada tabel dibawah. • Daerah kritik H0 ditolak jika P-value < α • Kesimpulan: diperoleh nilai BP sebesar 0.037 lebih besar dari 0.05 , hal ini berarti bahwa tidak terdapat heteroskedasitas