Tugas Ekonometrika 2 Model LDV - Binary Response Okto Riyo Ananda 19060051

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

TUGAS EKONOMETRIKA 2

MODEL LIMITED DEPENDENT

VARIABLE

BINARY RESPONSE MODEL

Nama : Okto Riyo Ananda

Nim : 19060051

Prodi : Ekonomi Pembangunan

Saudara diminta untuk melakukan analisis dan estimasi seperti pada tahapan yang
ada di modul “Model Limited Dependent Variable (aplikasi STATA1)” dengan model
analisis sebagai berikut:

P(infl =1) = α + β1kidsge6 + β2kidslt6 + β3age + β4educ + β5hauswage + β6exper +


β7fatheduc + ε

Dimana,

inlf =1 if in lab force in 1975,

kidsge6 = number of kids aged 6-18

kidslt6 = number of kids aged < 6

years age = woman's age in years

educ = years of schooling

hauswage = gaji suami

exper = actual labor market

experience Fatheduc = Pendidikan

ayah

Untuk mengetahui jenis data, variabel name, value label, format serta varabel label
kita dapat melakukannya sebagai berikut:
describe
. describe

Contains data from http://www.stata.com/data/jwooldridge/eacsap/mroz.dta


obs: 753
vars: 22 2 Sep 1996 16:04
size: 36,897

storage display value


variable name type format label variable label

inlf byte %9.0g =1 if in lab frce, 1975


hours int %9.0g hours worked, 1975
kidslt6 byte %9.0g # kids < 6 years
kidsge6 byte %9.0g # kids 6-18
age byte %9.0g woman's age in yrs
educ byte %9.0g years of schooling
wage float %9.0g est. wage from earn, hrs
repwage float %9.0g rep. wage at interview in 1976
hushrs int %9.0g hours worked by husband, 1975
husage byte %9.0g husband's age
huseduc byte %9.0g husband's years of schooling
huswage float %9.0g husband's hourly wage, 1975
faminc float %9.0g family income, 1975
mtr float %9.0g fed. marg. tax rte facing woman
motheduc byte %9.0g mother's years of schooling
fatheduc byte %9.0g father's years of schooling
Unem float %9.0g unem. rate in county of resid.
City byte %9.0g =1 if live in SMSA
Exper byte %9.0g actual labor mkt exper
Nwifeinc float %9.0g (faminc - wage*hours)/1000
Lwage float %9.0g log(wage)
Expersq int %9.0g exper^2

Sorted by:

Untuk mengetahui berapa jumlah observasi, mean, std.deviasi, nilai max dan nilaiminimum
kita dapat melakukannya sebagai berikut:

Sum
. sum

Variable Obs Mean Std. Dev. Min Max

inlf 753 .5683931 .4956295 0 1


hours 753 740.5764 871.3142 0 4950
kidslt6 753 .2377158 .523959 0 3
kidsge6 753 1.353254 1.319874 0 8
age 753 42.53785 8.072574 30 60

educ 753 12.28685 2.280246 5 17


wage 753 2.374565 3.241829 0 25
repwage 753 1.849734 2.419887 0 9.98
hushrs 753 2267.271 595.5666 175 5010
husage 753 45.12085 8.058793 30 60

huseduc 753 12.49137 3.020804 3 17


huswage 753 7.482179 4.230559 .4121 40.509
faminc 753 23080.59 12190.2 1500 96000
mtr 753 .6788632 .0834955 .4415 .9415
motheduc 753 9.250996 3.367468 0 17

fatheduc 753 8.808765 3.57229 0 17


unem 753 8.623506 3.114934 3 14
city 753 .6427623 .4795042 0 1
exper 753 10.63081 8.06913 0 45
nwifeinc 753 20.12896 11.6348 -.0290575 96

lwage 428 1.190173 .7231978 -2.054164 3.218876


expersq 753 178.0385 249.6308 0 2025

Untuk mengetahui suatu komposisi nilai dari suatu nilai dummy, kita dapat melakukannya
sebagai berikut: (misal variabel yang kita ingin tahu adalah inlf)

inspect inlf
. inspect inlf

inlf: =1 if in lab frce, 1975 Number of Observations

Total Integers Nonintegers


## Negative - - -
## Zero 325 325 -
## Positive 428 428 -
##
##
Total 753 753 -
Missing -

0 1 753
(2 unique values)
histogram inlf

. histogram inlf
(bin=27, start=0, width=.03703704)
15
10
Density

5
0

0 .2 .4 .6 .8 1
=1 if in lab frce, 1975

MODEL YANG DIGUNAKAN

1. LPM

reg inlf kidsge6 kidslt6 age educ huswage exper fatheduc

. reg inlf kidsge6 kidslt6 age educ huswage exper fatheduc

Source SS df MS Number of obs = 753


F(7, 745) = 35.91
Model 46.5999801 7 6.65714001 Prob > F = 0.0000
Residual 138.127776 745 .18540641 R-squared = 0.2523
Adj R-squared = 0.2452
Total 184.727756 752 .245648611 Root MSE = .43059

inlf Coef. Std. Err. t P>|t| [95% Conf. Interval]

kidsge6 .0107176 .0133202 0.80 0.421 -.0154321 .0368672


kidslt6 -.2739981 .0336064 -8.15 0.000 -.3399727 -.2080235
age -.0182664 .0024369 -7.50 0.000 -.0230504 -.0134825
educ .0384488 .0080438 4.78 0.000 .0226576 .05424
huswage -.0074 .0039429 -1.88 0.061 -.0151406 .0003405
exper .0231027 .0021573 10.71 0.000 .0188676 .0273377
fatheduc .0002931 .0049815 0.06 0.953 -.0094863 .0100726
_cons .7308092 .1509548 4.84 0.000 .4344618 1.027157
Karena kita melakukan data menggunakan LPM dimana berdasarkan OLS, maka dari hasil
diatas kita dapat membuat model menjadi seperti berikut: (yaitu dengan memasukan koefisient
ke model awal)
P(infl=1)= 0.7308 + 0.0107kidsge6 – 0.2739kidslt6 – 0.0182age + 0.0384educ –
0.0074huswage + 0.0231exper + 0.0002fatheduc

Melihat nilai prediksi dan error dari estimasi menggunakan

LPM reg inlf kidsge6 kidslt6 age educ huswage exper fatheduc

(omitted)

predict lpminlfhat => (untuk mendapatkan nilai inlf estimasi)

predict erlpm, resid => (untuk mendapatkan nilai error dari inlf

estimasi (lpminlfhat))

list inlf lpminlfhat erlpm in 26/35

. list inlf lpminlfhat erlpm in 26/35

inlf lpminl~t erlpm

26. 1 1.004737 -.0047374


27. 1 .784344 .215656
28. 1 .7868974 .2131026
29. 1 .6629737 .3370263
30. 1 .5516995 .4483005

31. 1 .961174 .038826


1 .4869401 .5130599
32.
1 .923646 .076354
33.
1 .5432175 .4567825
34.
1 1.12761 -.1276104
35.

list inlf kidsge6 kidslt6 age educ huswage exper fatheduc lpminlfhat erlpm in 26
. list inlf kidsge6 kidslt6 age educ huswage exper fatheduc lpminlfhat erlpm in 26

inlf kidsge6 kidslt6 age educ huswage exper fatheduc lpminl~t erlpm

26. 1 2 0 43 17 14.181 21 14 1.004737 -.0047374

Dimana dari nilai variabel tersebut kita masukkan kedalam model LPM yang telah kitadapatkan
koefisiennya dari hasil estimasi di atas. Terlihat bahwa estimasi yang kita peroleh bisa lebih
dari 1, padahal data sebenarnya data kita hanya antara 0 dan 1. Oleh karena itu, permasalahan
tersebut merupakan salah satu kelemahan dari LPM.

Grafik scatterplot

Untuk memperjelas hasil dari estimasi menggunakan LPM (lpminlfhat) maka nilainyadapat
kita gambarkan menggunakan scatter plot, dengan cara seperti berikut:

Membuat Scatter Plot berdasarkan Fitted Values

scatter inlf lpminlfhat || lfit inlf lpminlfhat


1
.5

-.5 0 .5 1
Fitted values
=1 if in lab frce, 1975Fitted values

2. Logit

logit inlf kidsge6 kidslt6 age educ huswage exper fatheduc


. logit inlf kidsge6 kidslt6 age educ huswage exper fatheduc

Iteration 0: log likelihood = -514.8732


Iteration 1: log likelihood = -408.2327
Iteration 2: log likelihood = -407.4094
Iteration 3: log likelihood = -407.4082
Iteration 4: log likelihood = -407.4082

Logistic regression Number of obs = 753


LR chi2(7) = 214.93
Prob > chi2 = 0.0000
Log likelihood = -407.4082 Pseudo R2 = 0.2087

inlf Coef. Std. Err. z P>|z| [95% Conf. Interval]

kidsge6 .0461418 .0729743 0.63 0.527 -.0968853 .1891689


kidslt6 -1.431655 .2003829 -7.14 0.000 -1.824398 -1.038911
age -.0943063 .0142614 -6.61 0.000 -.1222582 -.0663544
educ .2130828 .0456843 4.66 0.000 .1235432 .3026224
huswage -.04014 .0212205 -1.89 0.059 -.0817313 .0014513
exper .1228271 .0135672 9.05 0.000 .0962359 .1494183
fatheduc .0025618 .0273787 0.09 0.925 -.0510994 .056223
_cons .9996058 .8378678 1.19 0.233 -.6425849 2.641796

Dari hasil regress kita menggunakan logit maka kita mendapatkan koefisient untuk
dimasukan kedalam rumus logistik, yakni

𝟏 𝒆𝒛
𝑷𝒊 = =
𝟏 + 𝒆−𝒛 𝟏 + 𝒆𝒛
Menjadi seperti berikut :
Pr(inlf=1)
e 0.999 + 0.046kidsge6 – 1.432kidslt6 – 0.094age + 0.213educ – 0.040huswage + 0.123exper + 0.002fatheduc
e 0.999 + 0.046kidsge6 – 1.432kidslt6 – 0.094age + 0.213educ – 0.040huswage + 0.123exper + 0.002fatheduc + 1

Contoh, misalkan kita ingin melihat data kita pada baris satu dari stata dan melihat berapa nilai
probabilitas prediksi dengan logit, maka dapat dilakukan dengan seperti berikut:
logit inlf kidsge6 kidslt6 age educ huswage exper fatheduc

predict lgtinlfhat

list inlf kidsge6 kidslt6 age educ huswage exper fatheduc lgtinlfhat in 1
. list inlf kidsge6 kidslt6 age educ huswage exper fatheduc lgtinlfhat in 1

inlf kidsge6 kidslt6 age educ huswage exper fatheduc lgtinl~t

1. 1 0 1 32 12 4.0288 14 7 .6643942

Dengan memasukan rumus yang telah memiliki keofisien kita akan mendapatkan nilai inlf
estimasi (lgtinlfhat), atau nilai Probabilitas prediksi dengan rumus seperti ini:

0.999 + 0.046k(0) – 1.432(1) – 0.094(32) + 0.213(12) – 0.040(4.02) + 0.123(14) + 0.002(7)


e

0.999 + 0.046k(0) – 1.432(1) – 0.094(32) + 0.213(12) – 0.040(4.02) + 0.123(14) + 0.002(7) + 1


e

= 0.6643942

Menggunakan odds ratio

logit inlf kidsge6 kidslt6 age educ huswage exper fatheduc, or

. logit inlf kidsge6 kidslt6 age educ huswage exper fatheduc, or

Iteration 0: log likelihood = -514.8732


Iteration 1: log likelihood = -408.2327
Iteration 2: log likelihood = -407.4094
Iteration 3: log likelihood = -407.4082
Iteration 4: log likelihood = -407.4082

Logistic regression Number of obs = 753


LR chi2(7) = 214.93
Prob > chi2 = 0.0000
Log likelihood = -407.4082 Pseudo R2 = 0.2087

inlf Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]

kidsge6 1.047223 .0764204 0.63 0.527 .9076601 1.208245


kidslt6 .2389133 .0478741 -7.14 0.000 .1613147 .3538397
age .910004 .012978 -6.61 0.000 .8849198 .9357991
educ 1.237487 .0565337 4.66 0.000 1.131499 1.353403
huswage .960655 .0203855 -1.89 0.059 .9215195 1.001452
exper 1.130689 .0153403 9.05 0.000 1.101019 1.161159
fatheduc 1.002565 .0274489 0.09 0.925 .9501842 1.057834
_cons 2.71721 2.276663 1.19 0.233 .5259312 14.0384

Nilai Odds Ratio mewakili kemungkinan untuk inlf = 1 (bekerja) ketika variabel tersebut
meningkat sebesar 1 unit. Nilai ini adalah exp (logit coeff).
Contoh interpretasi variable kidsge6 :
Setiap penambahan satu orang anak yang berusia di atas 6 tahun akan menyebabkan
kemungkinan seorang wanita yang telah menikah untuk bekerja mengalami peningkatan
dengan odds ratio sebesar 1.047
Contoh interpretasi variable kidslt6 :
Setiap penambahan satu orang anak yang berusia di bawah 6 tahun akan menyebabkan
kemungkinan seorang wanita yang telah menikah untuk bekerja mengalami penurunan dengan
odds ratio sebesar 0.23
Melihat Odds ratio pada different levels di setiap variable

logit inlf kidsge6 kidslt6 age educ huswage exper

fatheduc (omitted)

adjust, by (kidsge6) exp


. adjust, by (kidsge6) exp

Dependent variable: inlf Equation: inlf Command: logit


Variables left as is: kidslt6, age, educ, huswage, fatheduc, exper

# kids
6-18 exp(xb)

0 1.48136
1 1.37637
2 1.5271
3 1.29372
4 1.44427
5 1.07912
6 .109483
7 2.39664
8 7.72864

Key: exp(xb) = exp(xb)

Interpreatasi :

Ketika kids 6-18 years = 0 (perempuan tidak memiliki anak umur 6-18 tahun) maka
kemungkinan (the odds of) inlf = 1 (bekerja) akan meningkatkan odds ratio sebesar 1.481.
misalnya contoh lain, ketika kids 6-18 years = 8 (perempuan memiliki anak usia 6-18 tahun
sebanyak 8 orang) maka keungkinan (the odds of) inlf = 1 (bekerja) akan meningkat dengan
odds ratio sebesar 7.728
adjust, by (kidslt6) exp

. adjust, by (kidslt6) exp

Dependent variable: inlf Equation: inlf Command: logit


Variables left as is: kidsge6, age, educ, huswage, fatheduc, exper

# kids <
6 years exp(xb)

0 1.8473
1 .594501
2 .29323
3 .031088

Key: exp(xb) = exp(xb)

Interpretasi :

Ketika kids <6 years = 0 (perempuan tidak memiliki anak dibawah 6 tahun) maka kemungkinan
(the odds of) inlf = 1 (bekerja) akan meningkatkan odds ratio sebesar 1.4847. misalnya contoh
lain, ketika kids <6 years = 3 (perempuan memiliki anak usia dibawah 6 tahun sebanyak 3 orang)
maka keungkinan (the odds of) inlf = 1 (bekerja) akan menurun dengan odds ratio sebesar 0.031

Memprediksi probabilitas pada different levels di setiap variable di Model

Logit logit inlf kidsge6 kidslt6 age educ huswage exper fatheduc (omitted)

adjust, by (kidsge6) pr
. adjust, by (kidsge6) pr

Dependent variable: inlf Equation: inlf Command: logit


Variables left as is: kidslt6, age, educ, huswage, fatheduc, exper

# kids
6-18 pr

0 .596996
1 .57919
2 .60429
3 .564028
4 .590881
5 .519028
6 .098679
7 .705592
8 .885435

Key: pr = Probability

Penjelasannya : Ketika kids 6-18 years = 0 (perempuan tidak memiliki anak umur 6-18 tahun)
maka probabilita inlf = 1 (bekerja) adalah 0.596 atau 59.6 % . misalnya contoh lain, ketika kids
6-18 years = 8 (perempuan memiliki anak usia 6-18 tahun sebanyak 8 orang) maka probabilita
inlf = 1 (bekerja) adalah 0.885 atau 88.5 %.

adjust, by (kidslt6) pr

. adjust, by (kidslt6) pr

Dependent variable: inlf Equation: inlf Command: logit


Variables left as is: kidsge6, age, educ, huswage, fatheduc, exper

# kids <
6 years pr

0 .64879
1 .372845
2 .226743
3 .03015

Key: pr = Probability

Penjelasan : Ketika kids <6 years = 0 (perempuan tidak memiliki anak dibawah 6 tahun) maka
probabilita inlf = 1 (bekerja) adalah 0.648 atau 64.8%. misalnya contoh lain, ketika kids <6 years
= 2 (perempuan memiliki anak usia dibawah 6 tahun sebanyak 2 orang) maka probabilita inlf = 1
(bekerja) adalah 0.226 atau 22.6%.
Efek marginal rata-rata dari setiap variabel peubah (multiplier) ModelLogit

logit inlf kidsge6 kidslt6 age educ huswage exper fatheduc (omitted)

mfx
. mfx

Marginal effects after logit


y = Pr(inlf) (predict)
= .58812812

variable dy/dx Std. Err. z P>|z| [ 95% C.I. ] X

kidsge6 .0111771 .01768 0.63 0.527 -.023474 .045828 1.35325


kidslt6 -.3467946 .04873 -7.12 0.000 -.442295 -.251295 .237716
age -.0228441 .00346 -6.60 0.000 -.029623 -.016065 42.5378
educ .0516158 .01106 4.67 0.000 .029933 .073299 12.2869
huswage -.0097232 .00514 -1.89 0.058 -.019794 .000348 7.48218
exper .0297528 .00325 9.15 0.000 .023381 .036125 10.6308
fatheduc .0006206 .00663 0.09 0.925 -.012378 .013619 8.80876

Penjelasan untuk marginal tiap variable, missal untuk variable kidslt6, secara rata-rata ketika
nilai kidslt6 naik satu satuan maka kemungkinan perempuan untuk inlf = 1 (bekerja) akan turun
sebesar 0.346 point atau 34.6%, dan begitu juga untuk variable alinnya.

Pengujian Goodness of Fit


logit inlf kidsge6 kidslt6 age educ huswage exper fatheduc

fitstat
. fitstat

Measures of Fit for logit of inlf

Log-Lik Intercept Only: -514.873 Log-Lik Full Model: -407.408


D(745): 814.816 LR(7): 214.930
Prob > LR: 0.000
McFadden's R2: 0.209 McFadden's Adj R2: 0.193
Maximum Likelihood R2: 0.248 Cragg & Uhler's R2: 0.333
McKelvey and Zavoina's R2: 0.347 Efron's R2: 0.258
Variance of y*: 5.040 Variance of error: 3.290
Count R2: 0.740 Adj Count R2: 0.397
AIC: 1.103 AIC*n: 830.816
BIC: -4120.112 BIC': -168.562

Hasil diatas menyatakan bahwa McFadden's Adj R2 = 0.193, yang dapat diartikan sebagai
berikut garis regresi mampu menjelaskan variasi penyebaran dependen dengan menggunakan
kurva sigmoid sebesar 19.3%.

Pengujian Goodness of Fit Hosmer-Lemeshow


logit inlf kidsge6 kidslt6 age educ huswage exper fatheduc (omitted)

estat gof
. estat gof

Logistic model for inlf, goodness-of-fit test

number of observations = 753


number of covariate patterns = 753
Pearson chi2(745) = 754.65
Prob > chi2 = 0.3950

Pada hasil model kita, model fits hasilnya sangat baik. Dimana, nilai number of covariate
patterns saama dengan number of observations yaitu 753, sedangkan nilai dari (Prob>chi2) lebih
besar dari α atau terima H0. Dimana memilki hipotesis sepertiberikut:
H0 : 𝒚 = 𝒚̅ ∶ Tidak Tolak

Model H1 : 𝒚 ≠ 𝒚̅ ∶ Tolak

Model Grafik scatterplot

gen lnlgtinlfhat = ln(lgtinlfhat/(1-lgtinlfhat))


scatter lgtinlfhat inlf lnlgtinlfhat

. gen lnlgtinlfhat = ln(lgtinlfhat/(1-lgtinlfhat))

. scatter lgtinlfhat inlf lnlgtinlfhat


1
.8
.6
.4
.2
0

-4 -2 0 2 4
lnlgtinlfhat
Pr(inlf)=1 if in lab frce, 1975

3. Probit

probit inlf kidsge6 kidslt6 age educ huswage exper fatheduc

. probit inlf kidsge6 kidslt6 age educ huswage exper fatheduc

Iteration 0: log likelihood = -514.8732


Iteration 1: log likelihood = -408.37567
Iteration 2: log likelihood = -407.45643
Iteration 3: log likelihood = -407.45526
Iteration 4: log likelihood = -407.45526

Probit regression Number of obs = 753


LR chi2(7) = 214.84
Prob > chi2 = 0.0000
Log likelihood = -407.45526 Pseudo R2 = 0.2086

inlf Coef. Std. Err. z P>|z| [95% Conf. Interval]

kidsge6 .0276532 .0429978 0.64 0.520 -.0566209 .1119274


kidslt6 -.8720633 .1169919 -7.45 0.000 -1.101363 -.6427634
age -.0574763 .0083015 -6.92 0.000 -.073747 -.0412056
educ .1259319 .0266259 4.73 0.000 .073746 .1781177
huswage -.0230459 .0125729 -1.83 0.067 -.0476883 .0015966
exper .0719673 .0075121 9.58 0.000 .0572438 .0866907
fatheduc .0016439 .0162474 0.10 0.919 -.0302005 .0334883
_cons .6717027 .4960076 1.35 0.176 -.3004543 1.64386

Pr(inlf=1)
e 0.671 + 0.027kidsge6 – 0.872kidslt6 – 0.057age + 0.125educ – 0.023huswage + 0.071exper + 0.001fatheduc
e 0.671 + 0.027kidsge6 – 0.872kidslt6 – 0.057age + 0.125educ – 0.023huswage + 0.071exper + 0.001fatheduc + 1

Contoh, misalkan kita ingin melihat data kita pada baris satu dari stata dan melihat berapa nilai
probabilitas prediksi dengan probit, maka dapat dilakukan dengan seperti berikut:
probit inlf kidsge6 kidslt6 age educ huswage exper fatheduc

predict prinlfhat

list inlf kidsge6 kidslt6 age educ huswage exper fatheduc prinlfhat in 1

. predict prinlfhat
(option pr assumed; Pr(inlf))

. list inlf kidsge6 kidslt6 age educ huswage exper fatheduc prinlfhat in 1

inlf kidsge6 kidslt6 age educ huswage exper fatheduc prinlf~t

1. 1 0 1 32 12 4.0288 14 7 .6546048

Dengan memasukan rumus yang telah memiliki keofisien kita akan mendapatkan nilai inlf
estimasi prinlfhat atau nilai Probabilitas prediksi dengan rumus seperti ini:

0.671 + 0.027(0) – 0.872(1) – 0.057(32) + 0.125(12) – 0.023(4.028) + 0.071(14) + 0.001(7)


e

0.671 + 0.027(0) – 0.872(1) – 0.057(32) + 0.125(12) – 0.023(4.028) + 0.071(14) + 0.001(7) + 1


e

= 0.6546048
Grafik Scatterplot
Membandingkan scatter plot model Probit dan
Logit Membuat grafik Scatter Plot Transformasi
Probit
gen lnprinlfhat = ln(prinlfhat/(1-
prinlfhat)) scatter prinlfhat inlf lnprinlfhat

. gen lnprinlfhat = ln(prinlfhat/(1-prinlfhat))

. scatter prinlfhat inlf lnprinlfhat

.
1

1
.8

.8
.6

.6
.4

.4
.2

.2
0

0
-4 -2 0 2 4 -4 -2 0 2 4
lnprinlfhat lnlgtinlfhat
Pr(inlf)=1 if in lab frce, 1975 Pr(inlf)=1 if in lab frce, 1975

Scatter plot probit scatter plot logit

You might also like