Stata program for Probit/Logit Models


STATA Program for Ordered Probit Models


Download 230.5 Kb.
bet6/9
Sana23.03.2023
Hajmi230.5 Kb.
#1287378
1   2   3   4   5   6   7   8   9
Bog'liq
STATA Programs

STATA Program for Ordered Probit Models
sr_health_status.do

* this data for this example are adults, 18-64;


* who answered the cancer control supplement to;
* the 1994 national health interview survey;
* the key outcome is self reported health status;
* coded 1-5, poor, fair, good, very good, excellent;
* a ke covariate is current smoking status and whether;
* one smoked 5 years ago;

# delimit;


set memory 20m;
set matsize 200;
set more off;
log using c:\bill\jpsm\sr_health_status.log,replace;

* load up sas data set;


use c:\bill\jpsm\sr_health_status;

* get contents of data file;


desc;

* get summary statistics;


sum;

* get tabulation of sr_health;


tab sr_health;
* run OLS models, just to look at the raw correlations in data;
reg sr_health male age educ famincl black othrace smoke smoke5;

* do ordered probit, self reported health status;


oprobit sr_health male age educ famincl black othrace smoke smoke5;

* get marginal effects, evaluated at y=5 (excellent);


mfx compute, predict(outcome(5));

* get marginal effects, evaluated at y=3 (good);


mfx compute, predict(outcome(3));

* use prchange, evaluate marginal effects for;


* 40 year old white female with a college degree;
* never smoked with average log income;
prchange, x(age=40 black=0 othrace=0 smoke=0 smoke5=0 educ=16);
log close;
STATA Results for Ordered Probit Models
sr_health_status.log

------------------------------------------------------------------------------


log: c:\bill\iadb\sr_health_status.log
log type: text
opened on: 1 Nov 2004, 12:06:56

. * load up sas data set;


. use sr_health_status;

. * get contents of data file;


. desc;

Contains data from sr_health_status.dta


obs: 12,900
vars: 9 1 Nov 2004 11:51
size: 322,500 (98.5% of memory free)
------------------------------------------------------------------------------
> -
storage display value
variable name type format label variable label
------------------------------------------------------------------------------
> -
male byte %9.0g =1 if male
age byte %9.0g age in years
educ byte %9.0g years of education
smoke byte %9.0g current smoker
smoke5 byte %9.0g smoked in past 5 years
black float %9.0g =1 if respondent is black
othrace float %9.0g =1 if other race (white is ref)
sr_health float %9.0g 1-5 self reported health,
5=excel, 1=poor
famincl float %9.0g log family income
------------------------------------------------------------------------------
> -
Sorted by:

. * get summary statistics;


. sum;

Variable | Obs Mean Std. Dev. Min Max


-------------+--------------------------------------------------------
male | 12900 .438062 .4961681 0 1
age | 12900 39.84124 11.60603 21 64
educ | 12900 13.24016 2.73325 0 18
smoke | 12900 .2891473 .453384 0 1
smoke5 | 12900 .0813953 .2734519 0 1
-------------+--------------------------------------------------------
black | 12900 .1242636 .3298948 0 1
othrace | 12900 .0412403 .1988532 0 1
sr_health | 12900 3.888992 1.063713 1 5
famincl | 12900 10.21313 .95086 6.214608 11.22524

. * get tabulation of sr_health;


. tab sr_health;

1-5 self |


reported |
health, |
5=excel, |
1=poor | Freq. Percent Cum.
------------+-----------------------------------
1 | 342 2.65 2.65
2 | 991 7.68 10.33
3 | 3,068 23.78 34.12
4 | 3,855 29.88 64.00
5 | 4,644 36.00 100.00
------------+-----------------------------------
Total | 12,900 100.00

. * run OLS models, just to look at the raw correlations in data;


. reg sr_health male age educ famincl black othrace smoke smoke5;

Source | SS df MS Number of obs = 12900


-------------+------------------------------ F( 8, 12891) = 350.85
Model | 2609.62058 8 326.202572 Prob > F = 0.0000
Residual | 11985.4163 12891 .929750704 R-squared = 0.1788
-------------+------------------------------ Adj R-squared = 0.1783
Total | 14595.0369 12899 1.13148592 Root MSE = .96424

------------------------------------------------------------------------------


sr_health | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
male | .1033877 .0172399 6.00 0.000 .0695949 .1371804
age | -.0189687 .0007472 -25.39 0.000 -.0204333 -.0175041
educ | .074539 .0033897 21.99 0.000 .0678946 .0811833
famincl | .2299388 .0099542 23.10 0.000 .2104271 .2494504
black | -.2127016 .0265726 -8.00 0.000 -.2647878 -.1606153
othrace | -.2120907 .0429632 -4.94 0.000 -.2963049 -.1278765
smoke | -.1800193 .0196221 -9.17 0.000 -.2184815 -.1415572
smoke5 | -.1356116 .0317119 -4.28 0.000 -.1977716 -.0734515
_cons | 1.362405 .1005616 13.55 0.000 1.165289 1.55952
------------------------------------------------------------------------------

. * do ordered probit, self reported health status;


. oprobit sr_health male age educ famincl black othrace smoke smoke5;

Iteration 0: log likelihood = -17591.791


Iteration 1: log likelihood = -16403.785
Iteration 2: log likelihood = -16401.987
Iteration 3: log likelihood = -16401.987

Ordered probit estimates Number of obs = 12900


LR chi2(8) = 2379.61
Prob > chi2 = 0.0000
Log likelihood = -16401.987 Pseudo R2 = 0.0676

------------------------------------------------------------------------------


sr_health | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
male | .1281241 .0195747 6.55 0.000 .0897583 .1664899
age | -.0202308 .0008499 -23.80 0.000 -.0218966 -.018565
educ | .0827086 .0038547 21.46 0.000 .0751535 .0902637
famincl | .2398957 .0112206 21.38 0.000 .2179037 .2618878
black | -.221508 .029528 -7.50 0.000 -.2793818 -.1636341
othrace | -.2425083 .0480047 -5.05 0.000 -.3365958 -.1484208
smoke | -.2086096 .0219779 -9.49 0.000 -.2516855 -.1655337
smoke5 | -.1529619 .0357995 -4.27 0.000 -.2231277 -.0827961
-------------+----------------------------------------------------------------
_cut1 | .4858634 .113179 (Ancillary parameters)
_cut2 | 1.269036 .11282
_cut3 | 2.247251 .1138171
_cut4 | 3.094606 .1145781
------------------------------------------------------------------------------

. * get marginal effects, evaluated at y=5 (excellent);


. mfx compute, predict(outcome(5));

Marginal effects after oprobit


y = Pr(sr_health==5) (predict, outcome(5))
= .34103717
------------------------------------------------------------------------------
variable | dy/dx Std. Err. z P>|z| [ 95% C.I. ] X
---------+--------------------------------------------------------------------
male*| .0471251 .00722 6.53 0.000 .03298 .06127 .438062
age | -.0074214 .00031 -23.77 0.000 -.008033 -.00681 39.8412
educ | .0303405 .00142 21.42 0.000 .027565 .033116 13.2402
famincl | .0880025 .00412 21.37 0.000 .07993 .096075 10.2131
black*| -.0781411 .00996 -7.84 0.000 -.097665 -.058617 .124264
othrace*| -.0843227 .01567 -5.38 0.000 -.115043 -.053602 .04124
smoke*| -.0749785 .00773 -9.71 0.000 -.09012 -.059837 .289147
smoke5*| -.0545062 .01235 -4.41 0.000 -.078719 -.030294 .081395
------------------------------------------------------------------------------
(*) dy/dx is for discrete change of dummy variable from 0 to 1

. * get marginal effects, evaluated at y=3 (good);


. mfx compute, predict(outcome(3));

Marginal effects after oprobit


y = Pr(sr_health==3) (predict, outcome(3))
= .25239744
------------------------------------------------------------------------------
variable | dy/dx Std. Err. z P>|z| [ 95% C.I. ] X
---------+--------------------------------------------------------------------
male*| -.0276959 .00425 -6.51 0.000 -.036029 -.019363 .438062
age | .0043717 .0002 21.81 0.000 .003979 .004765 39.8412
educ | -.0178727 .00089 -20.02 0.000 -.019623 -.016123 13.2402
famincl | -.0518395 .00261 -19.85 0.000 -.056959 -.04672 10.2131
black*| .0464219 .00599 7.75 0.000 .034675 .058169 .124264
othrace*| .0501493 .00934 5.37 0.000 .031834 .068464 .04124
smoke*| .0443735 .00464 9.56 0.000 .035272 .053476 .289147
smoke5*| .0323707 .00739 4.38 0.000 .017882 .04686 .081395
------------------------------------------------------------------------------
(*) dy/dx is for discrete change of dummy variable from 0 to 1

. * use prchange, evaluate marginal effects for;


. * 40 year old white female with a college degree;
. * never smoked with average log income;
. prchange, x(age=40 black=0 othrace=0 smoke=0 smoke5=0 educ=16);

oprobit: Changes in Predicted Probabilities for sr_health


male
Avg|Chg| 1 2 3 4


0->1 .0203868 -.0020257 -.00886671 -.02677558 -.01329902

5
0->1 .05096698


age
Avg|Chg| 1 2 3 4


Min->Max .13358317 .0184785 .06797072 .17686112 .07064757
-+1/2 .00321942 .00032518 .00141642 .00424452 .00206241
-+sd/2 .03728014 .00382077 .01648743 .04910323 .0237889
MargEfct .00321947 .00032515 .00141639 .00424462 .00206252

5
Min->Max -.33395794


-+1/2 -.00804856
-+sd/2 -.09320036
MargEfct -.00804868

educ
Avg|Chg| 1 2 3 4


Min->Max .21397413 -.10945692 -.19725057 -.22822781 .07974288
-+1/2 .01315829 -.00133136 -.00579271 -.01734608 -.00842556
-+sd/2 .03589903 -.0036753 -.01587057 -.04728749 -.02291423
MargEfct .01316202 -.0013293 -.00579057 -.01735309 -.00843208

5
Min->Max .45519245


-+1/2 .03289571
-+sd/2 .08974758
MargEfct .03290504

famincl
Avg|Chg| 1 2 3 4


Min->Max .16759798 -.05486112 -.13623201 -.22790183 .00276569
-+1/2 .03808549 -.00390581 -.01684746 -.05016185 -.02429861
-+sd/2 .03622223 -.0037093 -.01601486 -.04771243 -.02311897
MargEfct .03817633 -.00385563 -.0167955 -.05033251 -.02445719

5
Min->Max .41622926


-+1/2 .09521371
-+sd/2 .09055558
MargEfct .09544083

black
Avg|Chg| 1 2 3 4


0->1 .03467907 .00473166 .01835598 .04779626 .01581377

5
0->1 -.08669767


othrace
Avg|Chg| 1 2 3 4


0->1 .03787661 .00532324 .02040636 .05239134 .0165706

5
0->1 -.09469151


smoke
Avg|Chg| 1 2 3 4


0->1 .03270518 .00438228 .01712416 .04497364 .01528287

5
0->1 -.08176297


smoke5
Avg|Chg| 1 2 3 4


0->1 .02411037 .00299019 .012047 .03281575 .01242298

5
0->1 -.06027591


1 2 3 4 5


Pr(y|x) .00563112 .03431748 .17979275 .30986777 .47039089

male age educ famincl black othrace smoke


x= .438062 40 16 10.2131 0 0 0
sd(x)= .496168 11.606 2.73325 .95086 .329895 .198853 .453384

smoke5
x= 0


sd(x)= .273452

. log close;


log: c:\bill\iadb\sr_health_status.log
log type: text
closed on: 1 Nov 2004, 12:07:40
------------------------------------------------------------------------------

Download 230.5 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling