version 12.1
* Problem 1B
clear all
matrix input means = (79\14\15)
matrix input sds = (9.4\2.7\5.6)
matrix input corr = (1,.35,-.22\.35,1,-.90\-.22,-.90,1)
corr2data opinion educ tv, n(200) means(means) sds(sds) corr(corr)
sum
corr
corr, cov
reg opinion educ tv, beta
reg opinion tv, beta
reg opinion educ, beta
*Problem 2
use http://www3.nd.edu/~rwilliam/xsoc63993/statafiles/gender.dta, clear
*** Wald Test
reg income educ jobexp
test educ = jobexp
vce
*** Incremental F test
* Unconstrained model
reg income educ jobexp
est store unconstrained
* Constrained model
gen jobed = educ + jobexp
reg income jobed
est store constrained
* Use Buis's -ftest- command
ftest constrained unconstrained
*** Likelihood Ratio Test
lrtest constrained unconstrained, stats
* Part 3
use http://www3.nd.edu/~rwilliam/xsoc63993/statafiles/gender.dta, clear
* (a) Compositional differences
ttest educ, by(female)
ttest jobexp, by(female)
ttest income, by(female)
* (b) Differences in effects
* Constrained model: No Gender differences
reg income educ jobexp
est store both
* Unconstrained - Effects differ by gender
reg income educ jobexp if female == 0
est store male
reg income educ jobexp if female == 1
est store female
*** Likelihood ratio
lrtest (male female) both
*** Wald test using suest
quietly reg income educ jobexp if female == 0
est store male
quietly reg income educ jobexp if female == 1
est store female
suest male female
test [male_mean = female_mean], constant coef
* (d) What if
tabstat income educ jobexp, by(female) columns(variables)
* Margins
quietly reg income educ jobexp if female == 1
margins, at (educ = 11.2222 jobexp = 14.11111)
* Predict
quietly reg income educ jobexp if female == 1
adjust educ jobexp if female == 0
* Adjust
quietly reg income educ jobexp if female == 1
adjust educ jobexp if female == 0
* Margins using atmeans
quietly reg income educ jobexp if female == 1
margins if female == 0, atmeans noesample
* Margins using precise values
sum educ if female == 0, meanonly
scalar malemeaneduc = r(mean)
sum jobexp if female == 0, meanonly
scalar malemeanjobexp = r(mean)
scalar list
quietly reg income educ jobexp if female == 1
margins, at (educ = `=malemeaneduc' jobexp = `=malemeanjobexp')