capture log close log using addobs-eg1, replace text // program: addobs-eg1.do // task: show how to add observations and make predictions with addobs // project: addobs // author: jsl \ 19May2009 // #0 // program setup version 10 clear all set linesize 80 matrix drop _all which addobs // #1 // load datga spex binlfp3, clear list in 1 local last = _N list in `last' sum /* lfp 753 .5683931 .4956295 0 1 k5 753 .2377158 .523959 0 3 k618 753 1.353254 1.319874 0 8 age 753 42.53785 8.072574 30 60 wc 753 .2815405 .4500494 0 1 hc 753 .3917663 .4884694 0 1 lwg 753 1.097115 .5875564 -2.054124 3.218876 inc 753 20.12897 11. */ // #2 // add without svy * add row and make prediction logit lfp k5 k618 age wc hc lwg inc, nolog addobs, x(age=10) mean(lfp k5 k618 wc hc lwg inc) addobs, x(age=20) mean(lfp k5 k618 wc hc lwg inc) predict p1 in 754/755 list age p1 in 754/755 prvalue, x(age=10) prvalue, x(age=20) addobs, x(age=10) mean(inc) addobs, row(753) x(age=10) addsd(inc) // #3 // with svy use svydata_ki, clear svyset, clear svyset [pweight=c7], strata(c2) /* id ID c7 c2 age Age agesq Age squared attrpart Is partner attractive? attrself Are you attractive? black Black (1=yes) college Have a college degree? (1=yes) income Income in thousands (midpoints) income2log Log of income in thousands ownsex How good is own sexuality-3cat(2nd Q) sexacts # Sexual acts w/ ptnr white White (1=yes) */ svy: logit attrself white age agesq sexacts, or addobs, mean(attrself white age agesq sexacts) /// lin(age) squ(agesq) predict p1 in 814/815 list attrself white age agesq sexacts p1 in 814/815, clean log close exit