0% found this document useful (0 votes)
45 views36 pages

Lab Session I: Simultaneous Equations, Instrumental Variables and Two-Stage Least Squares (2SLS)

Uploaded by

Ibrahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views36 pages

Lab Session I: Simultaneous Equations, Instrumental Variables and Two-Stage Least Squares (2SLS)

Uploaded by

Ibrahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Econometrics II

Lab Session I:
Simultaneous Equations, Instrumental
Variables and Two-Stage Least Squares (2SLS)
Dr. Rabia Ikram
Assistant Professor, Lahore School Of Economics
Lahore School of Economics

Winter 2024
Limited Dependent Variables
Let’s Start…
To start a log file:
File>Log>Begin

Log files are used to keep record of everything you carry out in Stata. It
saves everything that appears in result window.

3
Dataset

Stata> File>Open> Pass.dta

4
Start a Do File
To start a do file:
Window>Do-file editor>New Do-file Editor

It allows you to save all your commands in a text file that you can use
later to reproduce all you results

5
Why do some students pass a
college-level economics course
and others do not?

Where;

6
1. Linear Probability Model
(LPM)
reg pass atten female hsgpa study Interpretation:
The regression
Binary Dependent Variable coefficient is the
Independent Variables change in the
Model Sum of Squares probability that Y=1
tells you how much of the Source SS df MS Number of obs = 856 associated with a unit
variation in the dependent F(4, 851) = 91.07 change
This in , ceteris
is the p-value of the
variable does your model Model 64.1458944 4 16.0364736 Prob > F = 0.0000 model. Itparibus.
tests whether R2 is
Residual 149.849433 851 .17608629 R-squared = 0.2998
explain. The closer to TSS different from 0. usually we
Adj R-squared = 0.2965
the better fit. Total 213.995327 855 .250286932 Root MSE = .41963
need a p-value lower than 0.05
to show a statistically
Residual Sum of Squares significant relationship between
tells you how much of the pass Coef. Std. Err. t P>|t| [95% Conf. Interval] X and Y.
dependent variable’s Root Mean Squared Error: is the sd
atten .0076484 .0022506 3.40 0.001 .003231 .0120657
variation your model did female .2846302 .033969 8.38 0.000 .2179575 .351303
of the regression. It shows the
not explain. hsgpa .4408387 .0407172 10.83 0.000 .3609207 .5207566 average distance of the estimator
study .0033232 .0017898 1.86 0.064 -.0001897 .0068362 from the mean. The closer to zero
Total Sum of Squares tells _cons -1.367275 .1343157 -10.18 0.000 -1.630904 -1.103647 better the fit.
you how much variation
there is in the dependent
variable. The t-values and the two-tail p-values test the hypothesis that each coefficient is different from
0. To reject this, the p-value has to be lower than 0.05 or a t-value greater than 1.96 . 7
Exporting Regression Output

ssc install outreg2

If you want to export the output into word:


outreg2 using LabSession1.doc, replace ctitle(LPM)

If you want to export the output into excel:


outreg2 using LabSession1.xls, replace ctitle(LPM)

8
1. Linear Probability Model
(LPM)
To estimate predicted probabilities, type:
predict prob A
PROBABILIT
sum prob Y CANNOT
BE LESS
THAN 0 OR
Variable Obs Mean Std. Dev. Min Max GREATER
THAN 1!

prob 856 .5023364 .2739059 -.7232935 1.10786

Shortcoming of the LPM:


Predicted probabilities can exceed 1 and
fall below 0.
9
1. Linear Probability Model
(LPM)- Interpretation

How does the attendance affect the probability of passing the


course?

How does gender affect the probability of passing the course?

10
1. Linear Probability Model
(LPM)- Interpretation

How does the attendance affect the probability of passing the


course?
Attending one more class increases the probability of passing
by 0.0076 ( or by 0.76%), ceteris paribus.

How does gender affect the probability of passing the course?


Females have 28.5% higher probability than males of passing
the course, ceteris paribus.

11
2. Logit Model

12
2. Logit Model

13
2. Logit Model

14
2. Logit Model
logit pass atten female hsgpa study
Binary Dependent Variable Independent Variables Interpretation:
The regression
Maximum likelihood coefficient tells us
Iteration 0: log likelihood = -593.32464
(ML) is an iterative Iteration 1: log likelihood = -443.97309 how the log of the
estimation technique Iteration 2: log likelihood = -442.85965 odds ratio will
that chooses Iteration 3: log likelihood = -442.85927 change with a unit
Iteration 4: log likelihood = -442.85927
coefficient estimates change in , ceteris
that maximize the log Logistic regression Number of obs = 856 paribus.
of the probability of LR chi2(4) = 300.93
It tests whether
observing the Prob > chi2 = 0.0000
the combined
Log likelihood = -442.85927 Pseudo R2 = 0.2536
particular set of effect, of all the
values of the variables in the
dependent variable in pass Coef. Std. Err. z P>|z| [95% Conf. Interval]
model, is
the
Logitsample for a are
coefficients different from
atten .0441567 .0135047 3.27 0.001 .017688 .0706254
given set ofunits
in log-odds Xs. and female 1.400826 .1861903 7.52 0.000 1.0359 1.765752 zero. We need a
cannot be read as hsgpa 2.660571 .2749554 9.68 0.000 2.121668 3.199474 p-value lower
regular OLS study .0193234 .0105265 1.84 0.066 -.0013082 .039955
than 0.05 to show
_cons -11.09044 .9651513 -11.49 0.000 -12.9821 -9.198778
coefficients. To that the model
interpret you need to has some
estimate the The t-values and the two-tail p-values test the hypothesis that each coefficient is different
explanatory
predicted from 0. To reject this, the p-value has to be lower than 0.05 or a t-value greater than 1.96.
powerThe 15
probabilities of Y=1. higher the Z the higher the relevance of the variable
Exporting Regression Output
If you want to export the output into word:
outreg2 using LabSession1.doc, append ctitle(Logit)

If you want to export the output into excel:


outreg2 using LabSession1.xls, append ctitle(Logit)

16
mlogit pass atten female hsgpa study
. mlogit pass atten female hsgpa study

Iteration 0: log likelihood = -593.32464


Iteration 1: log likelihood = -443.97309
Iteration 2: log likelihood = -442.85965
Iteration 3: log likelihood = -442.85927
Iteration 4: log likelihood = -442.85927

Multinomial logistic regression Number of obs = 856


LR chi2(4) = 300.93
Prob > chi2 = 0.0000
Log likelihood = -442.85927 Pseudo R2 = 0.2536

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

0
atten -.0441567 .0135047 -3.27 0.001 -.0706254 -.017688
female -1.400826 .1861903 -7.52 0.000 -1.765752 -1.0359
hsgpa -2.660571 .2749554 -9.68 0.000 -3.199474 -2.121668
study -.0193234 .0105265 -1.84 0.066 -.039955 .0013082
_cons 11.09044 .9651513 11.49 0.000 9.198778 12.9821

1 (base outcome)

17
2. Logit Model

To estimate predicted probabilities, type:


predict ylogit

18
2. Logit Model

What is the difference in the predicted probability of passing


the course for a male and a female given that both attend 10
classes, have a hsgpa of 2.5 and study 5 hours during the
week?

19
2. Logit Model

What is the difference in the predicted probability of passing the


course for a male and a female given that both attend 10 classes,
have a hsgpa of 2.5 and study 5 hours during the week?
Females:

Males:

The difference between the two probabilities is 5.607%


20
Margins
• Logit model
logit pass atten female hsgpa study

• Logit - marginal effect at the mean


margins, dydx(*) atmeans

• * Logit - average marginal effect


margins, dydx(*)

21
. margins,dydx(*)

Average marginal effects Number of obs = 856


Model VCE : OIM

Expression : Pr(pass), predict()


dy/dx w.r.t. : atten female hsgpa study

Delta-method
dy/dx Std. Err. z P>|z| [95% Conf. Interval]

atten .007581 .002271 3.34 0.001 .0031299 .0120321


female .2405 .0279407 8.61 0.000 .1857372 .2952628
hsgpa .4567786 .0375848 12.15 0.000 .3831137 .5304435
study .0033175 .0017956 1.85 0.065 -.0002018 .0068369

22
3. Probit Model

23
3. Probit Model

24
3. Probit Model

25
3. Probit Model
The cumulative distribution function of the probit model
is:

26
3. Probit Model
probit pass atten female
Binary Dependent Variable hsgpaIndependent
studyVariables Interpretation:
The regression
Iteration 0: log likelihood = -593.32464 coefficient tells us
Maximum likelihood (ML) Iteration 1: log likelihood = -444.70906 how the z-score
is an iterative estimation Iteration 2: log likelihood = -443.40141 will change with a
Iteration 3: log likelihood = -443.4012
technique that chooses unit change in ,
Iteration 4: log likelihood = -443.4012
coefficient estimates that ceteris paribus.
maximize the log of the Probit regression Number of obs = 856
probability of observing LR chi2(4) = 299.85

the particular set of values Prob > chi2 = 0.0000 It tests whether the
Log likelihood = -443.4012 Pseudo R2 = 0.2527
of the dependent variable combined effect, of
in the sample for a given all the variables in the
set of Xs. pass Coef. Std. Err. z P>|z| [95% Conf. Interval] model, is different
from zero. We need a
atten .0250008 .0077702 3.22 0.001 .0097715 .0402302
Probit coefficients cannot p-value lower than
female .845968 .1107282 7.64 0.000 .6289447 1.062991
be read as regular OLS hsgpa 1.559471 .1547111 10.08 0.000 1.256243 1.8627 0.05 to show that the
coefficients. To interpret study .0110622 .0061418 1.80 0.072 -.0009756 .0231 model has some
you need to estimate the _cons -6.482623 .5325056 -12.17 0.000 -7.526315 -5.438931 explanatory power
predicted probabilities of
Y=1. The t-values and the two-tail p-values test the hypothesis that each coefficient is different from 0. To reject this, the p-
value has to be lower than 0.05 or a t-value greater than 1.96. The higher the Z the higher the relevance of the variable 27
Exporting Regression Output
If you want to export the output into word:
outreg2 using LabSession1.doc, append
ctitle(Probit)

If you want to export the output into excel:


outreg2 using LabSession1.xls, append
ctitle(Probit)

28
3. Probit Model

To estimate predicted probabilities, type:


predict yprobit

29
Standard Normal Cumulative Probability Table

30
3. Probit Model

What is the difference in the predicted probability of passing


the course for a male and a female given that both attend 10
classes, have a hsgpa of 2.5 and study 5 hours during the
week?

31
3. Probit Model

What is the difference in the predicted probability of passing the


course for a male and a female given that both attend 10 classes,
have a hsgpa of 2.5 and study 5 hours during the week?
Females:

Males:

The difference between the two probabilities is 6.51%


32
Standard Normal Cumulative Probability Table

33
Regression Results
Dependent Variable: Pass=1; (1) (2) (3)
0 otherwise
LPM Logit Probit

atten 0.00765*** 0.0442*** 0.0250***


(0.00225) (0.0135) (0.00777)
female 0.285*** 1.401*** 0.846***
(0.0340) (0.186) (0.111)
hsgpa 0.441*** 2.661*** 1.559***
(0.0407) (0.275) (0.155)
study 0.00332* 0.0193* 0.0111*
(0.00179) (0.0105) (0.00614)
Constant -1.367*** -11.09*** -6.483***
(0.134) (0.965) (0.533)

Observations 856 856 856


R-squared 0.300
Standard errors in parentheses 34
*** p<0.01, ** p<0.05, * p<0.1
Graphical Representation of the
LPM, Logit and Probit Models
reg pass hsgpa
predict yhat
logit pass hsgpa
predict yhat_l
probit pass hsgpa
predict yhat_p
twoway (scatter pass hsgpa) (line yhat hsgpa, lcolor(red))
(connected yhat_l hsgpa, sort mcolor(orange)
msize(medsmall) msymbol(none) lcolor(orange)
lwidth(medthick) lpattern(solid) connect(direct)) (connected
yhat_p hsgpa, sort mcolor(forest_green) msize(small)
msymbol(none) lcolor(forest_green) lwidth(medium)
connect(direct)) 35
Graphical Representation of the
LPM, Logit and Probit Models

1
.5
0
-.5

1 2 3 4 5
high school GPA

=1 if the student passed the course Fitted values


Pr(pass) Pr(pass)

36

You might also like