flowchart LR A[infra] --> C(invest) B[tik] --> C C --> D(human) D --> E(labor) A --> D B --> D A --> E B --> E
Analisis 3SLS pada Data Panel
Diagram Konsep
Input Data dari file CSV
datasri <- read.csv("~/Documents/datasri.csv")Ubah format data dari data.frame menjadi Data Panel
library(plm)
pdata <- pdata.frame(datasri, index=c('propinsi', 'tahun'), drop.index=TRUE, row.names=TRUE)Pooled
Regresi Data Tahap 1
stage1 <- plm(invest ~ infra + tik , data= pdata, model = "pooling")
invest_hat <-predict(stage1)
summary(stage1)Pooling Model
Call:
plm(formula = invest ~ infra + tik, data = pdata, model = "pooling")
Balanced Panel: n = 33, T = 11, N = 363
Residuals:
Min. 1st Qu. Median Mean 3rd Qu. Max.
-3.18e+08 -9.20e+07 -3.13e+07 0.00e+00 4.88e+07 6.77e+08
Coefficients:
Estimate Std. Error t-value Pr(>|t|)
(Intercept) -376571461 61881538 -6.0854 2.976e-09 ***
infra 84547206 15987305 5.2884 2.146e-07 ***
tik 10245552 9240927 1.1087 0.2683
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 1.2633e+19
Residual Sum of Squares: 8.904e+18
R-Squared: 0.29516
Adj. R-Squared: 0.29125
F-statistic: 75.3787 on 2 and 360 DF, p-value: < 2.22e-16
Tahap 2
stage2 <- plm(human ~ infra + tik +invest_hat , data=pdata, model = "pooling")
human_hat <-predict(stage2)
summary(stage2)Pooling Model
Call:
plm(formula = human ~ infra + tik + invest_hat, data = pdata,
model = "pooling")
Balanced Panel: n = 33, T = 11, N = 363
Residuals:
Min. 1st Qu. Median 3rd Qu. Max.
-5.166907 -1.215628 0.039474 1.549295 4.736175
Coefficients: (1 dropped because of singularities)
Estimate Std. Error t-value Pr(>|t|)
(Intercept) 57.86030 0.74280 77.8946 < 2.2e-16 ***
infra 2.36587 0.19191 12.3283 < 2.2e-16 ***
tik -0.39858 0.11092 -3.5933 0.000372 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 2496.3
Residual Sum of Squares: 1282.9
R-Squared: 0.48607
Adj. R-Squared: 0.48321
F-statistic: 170.24 on 2 and 360 DF, p-value: < 2.22e-16
Tahap 3
stage3 <- plm(labor ~ infra + tik + human_hat, data= pdata, model = "pooling")
summary(stage3)Pooling Model
Call:
plm(formula = labor ~ infra + tik + human_hat, data = pdata,
model = "pooling")
Balanced Panel: n = 33, T = 11, N = 363
Residuals:
Min. 1st Qu. Median Mean 3rd Qu. Max.
-3968612 -2558036 -1648570 0 -77265 18148610
Coefficients: (1 dropped because of singularities)
Estimate Std. Error t-value Pr(>|t|)
(Intercept) -328299 2006021 -0.1637 0.8701
infra 649203 518262 1.2527 0.2111
tik 111746 299564 0.3730 0.7093
Total Sum of Squares: 9.6075e+15
Residual Sum of Squares: 9.3569e+15
R-Squared: 0.026081
Adj. R-Squared: 0.020671
F-statistic: 4.82035 on 2 and 360 DF, p-value: 0.0085919
Analisis Data Panel Fixed Effect
Tahap 1
one_sls <- plm(invest ~ tik + infra , data=pdata, effect = "individual", model = "within")
summary(one_sls)Oneway (individual) effect Within Model
Call:
plm(formula = invest ~ tik + infra, data = pdata, effect = "individual",
model = "within")
Balanced Panel: n = 33, T = 11, N = 363
Residuals:
Min. 1st Qu. Median Mean 3rd Qu. Max.
-2.66e+08 -9.42e+06 9.06e+05 0.00e+00 1.07e+07 1.85e+08
Coefficients:
Estimate Std. Error t-value Pr(>|t|)
tik 13699324 3541784 3.8679 0.0001324 ***
infra -1686075 10618763 -0.1588 0.8739378
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 6.6722e+17
Residual Sum of Squares: 5.5528e+17
R-Squared: 0.16777
Adj. R-Squared: 0.0815
F-statistic: 33.0605 on 2 and 328 DF, p-value: 8.3191e-14
Tahap 2
two_sls <- plm(human ~ invest | + tik + infra , data=pdata, effect = "individual", model = "within")
summary(two_sls)Oneway (individual) effect Within Model
Instrumental variable estimation
Call:
plm(formula = human ~ invest | +tik + infra, data = pdata, effect = "individual",
model = "within")
Balanced Panel: n = 33, T = 11, N = 363
Residuals:
Min. 1st Qu. Median 3rd Qu. Max.
-3.541186 -0.260648 -0.044327 0.305850 4.762756
Coefficients:
Estimate Std. Error z-value Pr(>|z|)
invest 2.2093e-08 2.5495e-09 8.6658 < 2.2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 101.84
Residual Sum of Squares: 239.38
R-Squared: 0.26682
Adj. R-Squared: 0.19328
Chisq: 75.0962 on 1 DF, p-value: < 2.22e-16
Tahap 3
three_sls <- plm(labor ~ human+tik+infra |.- human + invest +tik + infra |. -invest + tik + infra , data=pdata, effect = "individual", model = "within")
summary(three_sls)Oneway (individual) effect Within Model
Instrumental variable estimation
Call:
plm(formula = labor ~ human + tik + infra | . - human + invest +
tik + infra | . - invest + tik + infra, data = pdata, effect = "individual",
model = "within")
Balanced Panel: n = 33, T = 11, N = 363
Residuals:
Min. 1st Qu. Median Mean 3rd Qu. Max.
-1567253 -289756 30421 0 231122 4235163
Coefficients:
Estimate Std. Error z-value Pr(>|z|)
human 1476398 241743 6.1073 1.013e-09 ***
tik -231282 70498 -3.2807 0.001036 **
infra -172404 165200 -1.0436 0.296667
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 4.7408e+13
Residual Sum of Squares: 1.0963e+14
R-Squared: 0.12668
Adj. R-Squared: 0.033206
Chisq: 83.1531 on 3 DF, p-value: < 2.22e-16
Uji pFTest
pFtest(three_sls,stage3)
F test for individual effects
data: labor ~ human + tik + infra | . - human + invest + tik + infra | ...
F = 835.81, df1 = 33, df2 = 327, p-value < 2.2e-16
alternative hypothesis: significant effects
Terlihat bahwa p-value <5%, sehingga hipotesis null ditolaj, dan terpilih model Fixed Effect
Model Efek Random
Tahap 1
rone_sls <- plm(invest ~ tik + infra , data=pdata, effect = "individual", model = "random")
summary(rone_sls)Oneway (individual) effect Random Effect Model
(Swamy-Arora's transformation)
Call:
plm(formula = invest ~ tik + infra, data = pdata, effect = "individual",
model = "random")
Balanced Panel: n = 33, T = 11, N = 363
Effects:
var std.dev share
idiosyncratic 1.693e+15 4.115e+07 0.085
individual 1.817e+16 1.348e+08 0.915
theta: 0.9084
Residuals:
Min. 1st Qu. Median Mean 3rd Qu. Max.
-2.04e+08 -1.58e+07 -4.69e+06 0.00e+00 6.09e+06 2.50e+08
Coefficients:
Estimate Std. Error z-value Pr(>|z|)
(Intercept) 45888005 52858340 0.8681 0.385322
tik 11608418 3570867 3.2509 0.001151 **
infra 7201399 10554312 0.6823 0.495038
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 7.6772e+17
Residual Sum of Squares: 6.4447e+17
R-Squared: 0.16054
Adj. R-Squared: 0.15588
Chisq: 68.8484 on 2 DF, p-value: 1.1214e-15
Tahap 2
rtwo_sls <- plm(human ~ invest | + tik + infra , data=pdata, effect = "individual", model = "random")
summary(rtwo_sls)Oneway (individual) effect Random Effect Model
(Swamy-Arora's transformation)
Instrumental variable estimation
(Balestra-Varadharajan-Krishnakumar's transformation)
Call:
plm(formula = human ~ invest | +tik + infra, data = pdata, effect = "individual",
model = "random")
Balanced Panel: n = 33, T = 11, N = 363
Effects:
var std.dev share
idiosyncratic 0.7276 0.8530 0.113
individual 5.6967 2.3868 0.887
theta: 0.8929
Residuals:
Min. 1st Qu. Median 3rd Qu. Max.
-4.96016 -0.30653 0.11655 0.48069 3.30174
Coefficients:
Estimate Std. Error z-value Pr(>|z|)
(Intercept) 6.6616e+01 5.4565e-01 122.0854 < 2.2e-16 ***
invest 2.1991e-08 2.5071e-09 8.7716 < 2.2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 129.32
Residual Sum of Squares: 290.6
R-Squared: 0.25785
Adj. R-Squared: 0.2558
Chisq: 76.9402 on 1 DF, p-value: < 2.22e-16
Tahap 3
rthree_sls <- plm(labor ~ human+tik+infra |.- human + invest +tik + infra |. -invest + tik + infra , data=pdata, model = "random")
summary(rthree_sls)Oneway (individual) effect Random Effect Model
(Swamy-Arora's transformation)
Instrumental variable estimation
(Balestra-Varadharajan-Krishnakumar's transformation)
Call:
plm(formula = labor ~ human + tik + infra | . - human + invest +
tik + infra | . - invest + tik + infra, data = pdata, model = "random")
Balanced Panel: n = 33, T = 11, N = 363
Effects:
var std.dev share
idiosyncratic 3.353e+11 5.790e+05 0.002
individual 1.757e+14 1.326e+07 0.998
theta: 0.9868
Residuals:
Min. 1st Qu. Median Mean 3rd Qu. Max.
-1407503 -309308 10628 0 228261 4250600
Coefficients:
Estimate Std. Error z-value Pr(>|z|)
(Intercept) -97872045 15796336 -6.1959 5.796e-10 ***
human 1488962 233002 6.3903 1.655e-10 ***
tik -232795 67911 -3.4279 0.0006082 ***
infra -180109 159937 -1.1261 0.2601136
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Total Sum of Squares: 4.9066e+13
Residual Sum of Squares: 1.1262e+14
R-Squared: 0.12499
Adj. R-Squared: 0.11768
Chisq: 89.933 on 3 DF, p-value: < 2.22e-16
Uji Hausman
Terlihat bahwa intercept bernilai signifikan, sehingga dilanjutkan degan menguji Hausman
phtest(three_sls, rthree_sls)
Hausman Test
data: labor ~ human + tik + infra | . - human + invest + tik + infra | ...
chisq = 0.053147, df = 3, p-value = 0.9968
alternative hypothesis: one model is inconsistent
Karena p-value lebih besar dari 5%, maka hipotesis null diterima, artinya model random effect yang diterima.