Hi,
First-time Statalist poster (and novice Stata user) here. Please be kind.
My question is about how to properly fit a mixed effect model for clustered data in Stata.
I am studying hospital performance (Y) in relationship to hospital-level characteristics (H) and county-level characteristics (D), as well as some interactions between certain hospital-level characteristics and certain county-level characteristics (X).
My data are cross-sectional and consist of 2,540 unique hospitals, each nested within one of 1,305 unique counties and either one of 333 unique multi-hospital systems or no system at all.
Hospitals that operate within the same county or the same system may be similar and, in turn, their performance may be correlated. Accordingly, I'd like random effects (intercepts) due to county and system.
Systems and counties are not purely nested within one another (a system can operate in multiple counties; multiple systems can operate within the same county).
Thus, I think I need to fit a mixed effects model with crossed effects. Specifically, having reviewed the Stata manual and some related posts on this site, I think my code should look something like:
or, equivalently:
Does this look basically correct? Or, is it also necessary for me to also include "|| hospital:" after "|| county:", as follows:
The last of these (i.e. the version that includes || hospital: ) seems incorrect but as I'm just getting started in Stata, I would like to be sure before proceeding.
Thanks,
Brian
First-time Statalist poster (and novice Stata user) here. Please be kind.
My question is about how to properly fit a mixed effect model for clustered data in Stata.
I am studying hospital performance (Y) in relationship to hospital-level characteristics (H) and county-level characteristics (D), as well as some interactions between certain hospital-level characteristics and certain county-level characteristics (X).
My data are cross-sectional and consist of 2,540 unique hospitals, each nested within one of 1,305 unique counties and either one of 333 unique multi-hospital systems or no system at all.
Hospitals that operate within the same county or the same system may be similar and, in turn, their performance may be correlated. Accordingly, I'd like random effects (intercepts) due to county and system.
Systems and counties are not purely nested within one another (a system can operate in multiple counties; multiple systems can operate within the same county).
Thus, I think I need to fit a mixed effects model with crossed effects. Specifically, having reviewed the Stata manual and some related posts on this site, I think my code should look something like:
Code:
mixed Y H C X || _all: R.system || _all: R.county
Code:
mixed Y H C X || _all: R.system || county:
Code:
mixed Y H C X || _all: R.system || county: || hospital:
Thanks,
Brian