regression - Stata: Mlogit macro with dummy variables -
i new stata , macros. trying loop on several variables generate estimates mlogit, , save them in datasets. portion working well. problem have categorical variable need split dummy variables.
global mypath "/volumes/no name/dissertation/data/aim 2" use "$mypath/aim 2 data" global ses "sesq2 sesq3 sesq4 sesq5" /*regression*/ foreach xvar in age_median female marital ethnicity literacy $ses poor_health physical_median mental_median facility_fee time_clinic { mlogit trauma_main `xvar', b(5) vce(cluster ea_id) rrr parmest, saving("$mypath/multi_`xvar'.dta", replace) } i thought setting ses global variable, loop treat 1 set of variables, mistaken. code loops on every variable in $ses end each dummy variable regressed onto trauma_main separately, not want. there way "tell" stata treat dummy variables 1 block? additionally, know i.ses, , using work fine, reference group used not 1 want. have googled how set reference group i.var, coming nothing useful, because using wrong search terms.
thanks in advance advice,
maggie
you not need split categorical variable dummies. can use factor variables notation (i.) instead. documented in help fvvarlist. factor variables, change of reference category straightforward.
here example. site variable has 3 categories. default site = 1 reference category categorical variable:
webuse sysdsn1, clear
foreach v in age male i.site {
mlogit insure `v'
}
with ib can set reference category desired level. if want site = 2 reference, can following:
foreach v in age male ib2.site {
mlogit insure `v'
}
Comments
Post a Comment