Stata program for Probit/Logit Models


STATA Program for Probit/Logit Models


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

STATA Program for Probit/Logit Models
workplace.do

* this data for this program are a random sample;


* of 10k observations from the data used in;
* evans, farrelly and montgomery, aer, 1999;
* the data are indoor workers in the 1991 and 1993;
* national health interview survey. the survey;
* identifies whether the worker smoked and whether;
* the worker faces a workplace smoking ban;

* set semi colon as the end of line;


# delimit;

* ask it NOT to pause;


set more off;
* open log file;
log using c:\bill\jpsm\workplace1.log,replace;

* use the workplace data set;


use c:\bill\jpsm\workplace1;

* print out variable labels;


desc;

* get summary statistics;


sum;
* run a linear probability model for comparison purposes;
* estimate white standard errors to control for heteroskedasticity;
reg smoker age incomel male black hispanic
hsgrad somecol college worka, robust;

* run probit model;


probit smoker age incomel male black hispanic
hsgrad somecol college worka;

*predict probability of smoking;


predict pred_prob_smoke;
* get detailed descriptive data about predicted prob;
sum pred_prob, detail;

* predict binary outcome with 50% cutoff;


gen pred_smoke1=pred_prob_smoke>=.5;
label variable pred_smoke1 "predicted smoking, 50% cutoff";

* compare actual values;


tab smoker pred_smoke1, row col cell;
* ask for marginal effects/treatment effects;
mfx compute;
* the same type of variables can be produced with;
* prchange. this command is however more flexible;
* in that you can change the reference individual;
prchange, help;

* get marginal effect/treatment effects for specific person;


* male, age 40, college educ, white, without workplace smoking ban;
* if a variable is not specified, its value is assumed to be;
* the sample mean. in this case, the only variable i am not;
* listing is mean log income;
prchange, x(age=40 black=0 hispanic=0 hsgrad=0 somecol=0 worka=0);
* using a wald test, test the null hypothesis that;
* all the education coefficients are zero;
test hsgrad somecol college;
* how to run the same tets with a -2 log like test;

* estimate the unresticted model and save the estimates ;


* in urmodel;
probit smoker age incomel male black hispanic
hsgrad somecol college worka;
estimates store urmodel;

* estimate the restricted model. save results in rmodel;


probit smoker age incomel male black hispanic
worka;
estimates store rmodel;

lrtest urmodel rmodel;


* run logit model;
logit smoker age incomel male black hispanic
hsgrad somecol college worka;

* ask for marginal effects/treatment effects;


* logit model;
mfx compute;
log close;

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