I am hoping to get some advice from this excellent community on how I might try to proceed with an analysis of patient outcomes for a large conglomerate of hospitals. Essentially the dataset that I have shows one record/row per hospital visit (from admission to discharge) for many different patients at several different hospitals. Patients can appear in the dataset multiple times (once for each hospital visit), but there are no patients that go between hospitals. At each visit, which occur at irregular intervals for each patient (essentially patients come into the hospital as needed), a number of measurements are made that may be covary with X and Y and should be controlled for. I realize that I am facing a correlated/cluster data problem and cannot just proceed with a traditional regression model without taking into account the correlations and hierarchical clustered nature of the data with repeated measurements.

At first, I thought I would simply make hospital and patient each random effects to account for the clustered nature of the data. However, one of the things I'd like to study with a regression model is how moving from hospital A to hospital B impacts (i.e. increases or decreases) the expected outcome Y. Given that I would think that I'd need to make hospital a fixed effect, but if I do that, how do I account for the correlation within hospital?

One thought I had to handle the above is just to fit separate models for each hospital. Is there a benefit or drawback from fitting separate models for each hospital?

Is there any other way to do this?

Thanks in advance for your help!

Added in response to Bill's questions/comments:

Thanks Bill. I appreciate the response. So, I somewhat oversimplified the actual situation in order to encourage more responses. Essentially, I'm trying to take into account the clustered or longitudinal aspects of my data into account. I have a few levels of clusters going on here:

1. Hospitals. Each hospital has different policies that might conceivably result in more positive or negative outcomes or there may be hospitals in areas where patients might just be generally in more poor health (e.g. they may server older populations).

2. Doctors within a hospital may be adhere to hospital policies so there may be correlations among patients from the same doctor. Skilled doctors would have patients with better outcomes, I would expect.

3. Patient observations would obviously be correlated as the same patient will likely have more highly correlated responses than the responses between patients.

Essentially, a consequence of the clustering is that measurement on units within any given cluster (hospitals/doctors/patients) are more similar than measurements on units in different clusters. From what I've been reading it seems like the way to go about this is by making hospitals, doctors, and patients random effects to account for the clustering. If this is the right approach, then it seems I can't make comparisons of the mean responses between hospitals (or any cluster) if I treat them as random effects right?

  • 1
    $\begingroup$ What do you mean by "correlation within hospital?" Where does the correlation come from? Maybe it comes from the fact that some hospitals are good and some hospitals are bad. In that case, the hospital fixed effect controls for correlation within hospital. If it comes from something else, then, to correct for it, you have to say something about the process (the process in the world, not the statistical process) from which it comes. $\endgroup$
    – Bill
    Jan 23, 2015 at 18:58
  • 1
    $\begingroup$ By the way, this correlation is not usually the issue people worry about when running regressions like yours. Usually they are worried about selection. Some hospitals get "harder" or "sicker" patients than others, and the patient level covariates are not enough to adjust for it. So, hospital A looks like a bad hospital when it is really just a hospital which receives sicker patients. $\endgroup$
    – Bill
    Jan 23, 2015 at 19:00
  • $\begingroup$ Bill, see my edits/additions above. Thanks again for your assistance and any guidance. $\endgroup$ Jan 24, 2015 at 1:28
  • $\begingroup$ How are you assessing patient 'outcome'? Is it like 'recovered', 'recovered partially', 'died' etc? Also, one important factor that affects outcome is baseline severity of disease of patients taken up by doctors/hospitals. Severely diseased patients have a worse outcome even when doctors are more skilled and hospitals are better equipped. You need to take this into account in some clear manner. $\endgroup$
    – rnso
    Jan 24, 2015 at 2:09
  • $\begingroup$ There are three measures of interest really. One is length of stay which is measured in days (integers) only and is only of discharged patients. I do plan to also do a survival analysis with this too. The other measures are binary outcomes of 30-day readmission and then in-hospital mortality. I'm adjusting in the models for disease severity based on a APR-DRG coding, mortality risk (some standard measures used by the hospitals) and major disease category. I'm also adjusting for a few other baseline values. My concern is around clustering and adjusting standard errors accordingly. Thanks. $\endgroup$ Jan 24, 2015 at 4:05

2 Answers 2


A perspective from Gelman & Hill's Data Analysis Using Regression and Multilevel/Hierarchical Models may point in a helpful direction. G&H entirely eschew the terms 'fixed' and 'random', arguing that these are misleading (see pp. 245-6). Instead, they emphasize describing the model itself, in terms of the assumptions it embodies, as they relate to our understanding of real-world phenomena.

Turning attention to that latter principle, I would offer the following direct response to the question about separate models. If your 7 hospitals were: (1) a maternity hospital with a neonatal intensive care unit, (2) an academic childrens' hospital, (3) a small-animal veterinary hospital, (4) a veterinary unit of an aquarium, (5) a specialty cancer care hospital, (6) a rural community hospital and (7) an academic medical center, then clearly separate models are indicated! However, to the extent that you think your analytical aims (exploratory? testing theory-based hypotheses?) will be served by sharing information between the separate hospitals, then unifying them in a hierarchical model makes sense. So, if your 7 hospitals seem similar enough with respect to the mental picture underlying your approach to your scientific questions, then you may well want to share information between your 7 models. Hierarchical modeling can be understood as a way to connect the 7 hospital models to achieve that information sharing.

It should be noted that a ready analogy presents itself here to the question about whether to discretize a continuous variable. If you use an infant/child/adult categorical variable in a model, you lose the opportunity to share information about 17 year-old patients with information about 22 year-old patients, which you might accomplish with splines on a continuous age variable. But of course, in an analysis of the patients (mothers, neonates) at a maternity hospital, there are limited opportunities to share information in this way between two clearly distinct categories of patient.


One quick point about fixed vs random effects: Both are ways to deal with lack of independence in the errors. If you include hospital as a fixed effect (dummy coding) then the errors are assumed to be independent conditional on hospital - which is totally legitimate. However, when you have many higher level units (k), modelling their means as a random effect (i.e. as a probability distribution summarized by few paramters) is more efficient because you estimate fewer parameters than for a fixed effect (which would include k-1 dummy variables - a separate mean for each hospital).

Given this point, a really important question is how many hospitals are there, and how many hospital level variables are important to you? The same questions should be asking re: doctors, patients, and their characteristics.

  • $\begingroup$ Thank you so much, D L Dahly. This is exactly what I was looking for! Yes, I think the fixed effects route is the way to go, since I only have 7 hospitals. Since I have many doctor's and patients, I'll use random effects for them. Thanks again for all your help! $\endgroup$ Jan 28, 2015 at 14:57
  • $\begingroup$ I guess one follow-up questions I would have is why not just fit separate regression models for each hospital than include fixed effects for hospital? $\endgroup$ Jan 29, 2015 at 8:02
  • 1
    $\begingroup$ Well, one thing is that by splitting your sample up, you lose power. Your estimates become more volatile and you might see chance differences. So if you assume that the other parameters you are estimating don't vary across hopsitals (though they might), it's much better to keep your sample together. Like many things with modelling, you have many "researcher degrees of freedom" availible to you, which is why it's really important to have some clear, justified hypotheses in place before you start modelling. $\endgroup$
    – D L Dahly
    Jan 29, 2015 at 9:37
  • $\begingroup$ Thanks again D L Dahly. It's much appreciated for all your fantastic advice. $\endgroup$ Jan 29, 2015 at 19:57
  • $\begingroup$ @ D L Dahly, can't hopsitals be treated as random effect even they are only 7? $\endgroup$
    – Alph
    Jan 30, 2015 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.