Skip to content

Instantly share code, notes, and snippets.

@Aaronmoralesshildrick
Created November 24, 2019 20:11
Show Gist options
  • Save Aaronmoralesshildrick/a5f34b80e824ee91d3e4a062491dfd8a to your computer and use it in GitHub Desktop.
Save Aaronmoralesshildrick/a5f34b80e824ee91d3e4a062491dfd8a to your computer and use it in GitHub Desktop.
* get data from 17.2 from http://pages.stern.nyu.edu/~wgreene/Text/Edition7/tablelist8new.htm
label var yrb "Constructed measure of time spent in extramarital affairs"
label var v1 "Rating of the marriage"
label var v2 "Age in years aggregated"
label var v3 "Number of years married"
label var v4 "Number of childen"
label var v5 "Religiosity"
label var v6 "Education"
label var v7 "Occupation"
label var v8 "Husband's occupation"
gen A = 0
replace A = 1 if yrb > 0
rename v1 rating
rename v2 age
rename v3 myears
rename v4 children
rename v5 religiosity
rename v6 educ
probit A i.rating age myears children i.religiosity educ
outreg2 using probit_logit, replace tex dec(3)
logit A i.rating age myears children i.religiosity educ
outreg2 using probit_logit, append tex dec(3)
quietly probit A i.rating age myears children i.religiosity educ
margins, dydx(*) post
outreg2 using mfx, replace tex dec(3)
quietly logit A i.rating age myears children i.religiosity educ
margins, dydx(*) post
outreg2 using mfx, append tex dec(3)
estat classification /* run for both models as an additional method of comparison*/
*part b
oprobit rating age myears children i.religiosity educ
outreg2 using oprobit1, replace tex dec(3)
*specified variables margins calculations
margins, dydx(children) post
outreg2 using mfx3, replace tex dec(4)
margins, dydx(educ) post
outreg2 using mfx3, append tex dec(4)
*Q2
rename handdum handy
rename hhninc income
rename hhkids children
rename public insured
label var married "married"
label var female "female"
label var age "age"
label var hsat "health satisfaction"
label var handy "handycapped"
label var income "income"
label var educ "education"
label var children "children"
label var working "employed"
label var insured "public insurance"
label var addon "additional insurance"
global xlist female age hsat handy income educ children working insured addon married
tabulate hospvis
poisson hospvis $xlist /* Interpret as percenntage increase*/
outreg2 using pssn, replace tex dec(4)
margins, dydx(*) post/* Interpret as full visit increase*/
outreg2 using pols, replace tex dec(4)
regress hospvis $xlist
outreg2 using pols, append tex dec(4)
nbreg hospvis $xlist
outreg2 using nb, replace tex dec(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment