|
|
|
||||
|
|
|||||
use http://www.ats.ucla.edu/stat/stata/notes/hsb2, clear gen hiwrite = (write>60) xi: logit hiwrite i.female*math read mat c=e(b) /*storing the regresison coefficients*/ sum read preserve clear set obs 3 gen read = r(mean) in 1 replace read = r(mean) + r(sd) in 2 replace read = r(mean) - r(sd) in 3 gen group = _n expand 2 /*for two values of gender*/ sort read by read: gen female = _n -1 sort read female expand 20 /*for 20 values of math going from 32 all the way to 70*/ sort read female by read female: gen math = 2*_n + 30 gen fmath = female*math /*interaction term*/ gen one = 1 mkmat female math fmath read one, mat(X) mat pred = X*c' /*linear prediction*/ svmat pred gen p = exp(pred)/(1+exp(pred)) /*probability*/ twoway (line p math if female==1 & group==1) (line p math if female==0 & group==1) restore
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services