Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Use of margins command to get individual level predictions but where one factor is treated as balanced
From 
 
Sam Brilleman <[email protected]> 
To 
 
[email protected] 
Subject 
 
st: Use of margins command to get individual level predictions but where one factor is treated as balanced 
Date 
 
Thu, 04 Aug 2011 14:00:44 +0100 
Hi STATAlisters,
I am hoping someone can help me with getting the correct -margins- syntax. 
I have found several people with similar questions, but no clear answers.
I have a GLM (log link) model fit using the following command:
glm totalcost_modelfit i.practiceid i.age_gender i.imd_decile 
i.QOF_MMscore_trunc6, link(log) family(gamma) eform	
There are 174 levels for the i.practiceid factor variable. I wish to 
calculate the marginal mean for the outcome variable (totalcost_modelfit) 
within each practice, whilst treating the practice effect as balanced (i.e. 
using the average practice effect for the full sample). I've tried:
margins, over(practiceid) at((asbalanced) practiceid)
but this obviously treats practiceid as balanced within each practice 
rather than across the whole sample, so I may aswell have just used 
-predict- and calculated the mean predictions by practice manually. And if 
I try:
margins practiceid, at((asbalanced) practiceid)
then individuals from the full sample are contributing to the estimated 
marginal mean for each practice aren't that? I don't really want that since 
the age-gender distribution may differ across practices.
Ideally I would want to -predict- individual level prediction but where I 
am allowed to treat the practice effect as balanced (i.e. use the average 
practice fixed effect) and then I would just calculate the mean prediction 
within each practice manually (NB this would give me more flexibility as I 
would have the individual level predictions available too). Possibly using 
the -adjust- command? However it says that margins has superseded this.
Thanks for any help,
Sam.
------------------------------
Sam Brilleman
School of Social and Community Medicine
University of Bristol
Canynge Hall
39 Whatley Road
Bristol BS8 2PS
Tel: (0117) 928 7319
Email: [email protected]
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/