# Presentation: 211964

## An Introduction to Hierarchical Modeling

- Ken Pietz
- February 5, 2003

## Outline

- Introduction
- Linear models with fixed effects
- Random effects
- Computation
- Example
- Inference
- Uses of hierarchical models
- More complicated models

## Recommended References

- McCulloch and Searle, *Generalized, Linear, and Mixed Models*, Wiley, 2001
- Goldstein, *Multilevel Statistical Models*, Arnold, 1995
- Littell, Milliken, Stroup and Wolfinger, *SAS System for Mixed Models*, SAS Institute, 1996
- Verbeke and Molenberghs, *Linear Models for Longitudinal Data, Springer*, 2000
*SAS Proc Mixed Manual*

## Introduction

- Linear models are used to describe how a variable of interest (outcome) depends on other variables (effects)
- Effects can be fixed or random

## Notation and Terminology

- Fixed effects are denoted by Greek letters while random effects are denoted by Roman letters
- Determining values of fixed effects from the data is known as “estimation” while determining values of random effects is called “prediction”
- The basic unit of analysis (patient) is called a level 1 unit; the next highest (provider) is level 2
- The notation “yij” will mean the outcome of patient i of provider j

## Fixed and random effects

- A variable enters the equation as a fixed effect if the values that occur in the data are all values about which inference is to be made
- Case-mix adjustment variables (including age and sex) are normally considered a fixed effect because all patients (even future patients) are in one of the categories
- A variable enters the equation as a random effect if it is considered a random selection from a larger population
- Level 2 units such as doctors, hospitals

## Fixed and Random Effects (continued)

- Level 2 effects are a source of clustering in the outcomes
- If there are more than a few level 2 units units (e.g., 21 VA networks), it may be appropriate to consider them random even though they are not part of a larger population
- They behave like realizations of a random variable
- The characteristics of the network change over time

## Fixed and Random Effects (continued)

- If there is a small number of level 2 units  (< 8) , a stratified fixed effects analysis may be more appropriate
- To be modeled as a random effect, the level 2 units must be considered observations from the same distribution
- If they are very different, this may not be valid

## Linear Models with Fixed Effects

- The basis of linear modeling with fixed effects is the Gauss-Markov theorem:
- If data are characterized by the relationship
- 	yij = Σkxijkβk + eij  with eij independent and identically distributed (iid) and with      E(eij) = 0, then the best linear unbiased estimator (BLUE) of the βk is the least squares estimate

## Linear Models with Fixed Effects (continued) 

- Matrix notation:  **y** = **Xβ** + **ε, **E**(y|X) = xβ**
**y** ~ (**X****β, V), **where** V **is the covariance matrix, which in this case is diagonal.
** **
- To obtain the least-squares solution (BLUE), solve** β = (X****T****X)****-1****X****T****y.  **This is called ordinary least squares (OLS) regression.** **

## Linear Models with Fixed Effects (continued) 

- Normality is not a required hypothesis for the G-M theorem
- However, normality is important for meaningful inference
- Moreover, if the data have a skewed distribution, the BLUE may not be an appropriate statistic

## Linear models with Fixed Effects (continued)

- If the fixed effects are discrete categories, then the estimates of βk are the mean values of y in category k
- The fixed effects may be powers of the same quantity (e.g., 1, age, age2) and may contain interactions

## Random Effects

- The need for random effects arises when the assumptions of the G-M theorem are not satisfied, i.e., the errors are not iid
- The errors may correlated due to clustering
- Patient outcomes are correlated because they are treated by the same doctor or at the same hospital
- Measurements on the same patient over time are correlated
- Farm animals with the same parent are correlated

## Random Effects (continued)

- Clustering can be represented by adding a random effect to the model equation:
- 	yij = Σkxijkβk + uj + eij 	E(uj) = 0, uj iid
- The uj are the effect of the clustering unit (e.g., hospital)
- Models with both fixed and random effects are called “mixed models”
- This equation represents a random intercept model

## Random Effects (continued)

- The term “hierarchical” model is also used for models with random effects
- Patients are nested within providers
- Models with more that two levels are often used
- Patients can be nested within physicians and physicians nested within hospitals
- Interactions between fixed and random effects are also frequently included

## Mixed Model

- The general mixed model is written in matrix notation as
- 	E**(y|x) = X****β + Zu**, where **X** and **Z** are known model matrices and **u** ~ (**0**,**D**) meaning that E(**u) = 0 **and var(u) = **D**
- 	To complete the model specification, we define var(**y**|**u**) = **R** so that
- 	**y** ~ N(**X****β, ZDZ****T**** + R)**

## Mixed Model (continued)

- Fixed effects enter the model equation only through the mean
- Random effects enter the model equation only through the variance
- The mixed model equation can be regarded as a method  of dealing with a complicated set of variances and covariances which we know affect the data

## Covariance Matrix

- Compound symmetric structure
- Two levels of variation, σu (provider level variation) and σe (remaining variation)
- If there were two providers each with two patients, the covariance matrix V would be

- B = σu2

- A = σu2 + σe2

## Conceptual Computation Sequence

- Recall**  y** ~ N(**X****β, ZDZ****T**** + R).  **
- Let** V= **var**(Y) = ZDZ****T**** + R.**
- 1.  Solve** β = (X****T****V****–1****X)****-1****X****T****V****-1****y **to get BLUEs of fixed effects.  This is the same as the formula used in OLS regression except that V enters the equation.  In the OLS equation the V drops out because it is diagonal.** **

## Computation (continued)

- 2. Calculate level 2 residuals

**	****	****	**

- 3. Calculate predicted provider effects

## Computation (continued)

- The formula in step 3 is called the best linear unbiased predictor (BLUP) of the random effects
- Unlike the G-M theorem, BLUPs are not robust to departures from normality

## Shrinkage

**	****	****	**

- The quantity

- is called the “shrinkage factor.”
- Providers with small panels have their
- predicted effects shrunken toward the
- group mean.  This allows providers with
- small panels to be included in the model.

## Example 

- 334 primary care providers (PCPs) treating 24,477 patients in one VAMC
- Adjusted Clinical Groups (ACGs) are used for case-mix adjustment
- Patients are divided into 53 groups based on age, sex, and illness burden
- Outcome is log of number of medical encounters per year
- With log transform, the data are close to normal
- Not all encounters are with PCP

## Random Intercept Model

## Variance Components

- σu2 is the amount of variation due to the difference among providers
- σe2 is the remaining patient variation
- σu2 + σe2 is the total variation among patients not accounted for by case-mix adjustment
- ρ = σu2/(σu2 + σe2) is the proportion of total variation due to differences among providers (intraclass correlation)

## SAS Proc Mixed Code

-   **title2 'hierarchical model with random pcp';**** ods output SolutionR = encout;****  proc mixed data=temp3 noclprint covtest;****  class pcpssn acggrp;****  model lenc = acggrp;****   random pcpssn/solution;****  run;****  title2 'univariate of predicted effect';**** proc univariate normal plot;****  var estimate;**** run;**

## Proc Mixed Output

**Covariance Parameter Estimates**
**                                          ****Standard         Z**
**    ****Cov Parm     Estimate       Error     Value        Pr Z**
**    ****pcpssn          0.06525      0.007843         8.32      <.0001**
**    ****Residual       0.3970         0.003614    109.86      <.0001                                           **
**                  ****Fit Statistics**
**      ****-2 Res Log Likelihood        47493.3**
**      ****AIC (smaller is better)       47497.3**
**      ****AICC (smaller is better)     47497.3**
**      ****BIC (smaller is better)       47504.9**

## Proc Mixed Output (continued)

**               ****Solution for Random Effects             **
**                                                                          ****Std Err**
**       ****Effect     Provider                  Estimate        Pred   **
**       ****pcpssn    XXXXXXXXX       -0.1060       0.2217   **
**       ****pcpssn    XXXXXXXXX      -0.08971     0.09620    **
**      **
**                ****Type 3 Tests of Fixed Effects**
**                     ****Num     Den**
**       ****Effect         DF      DF    F Value    Pr > F**
**       ****acggrp         51    24E3     539.27    <.0001**

## Variance Components

- σe2 = 0.397
- σu2 = 0.06525
- ρ = 0.141
- About 14% of the total variation is due to variation between providers.

## Predicted Random Effects

## Inference

- To test for the need for random effects, run proc Mixed twice, with and without random effects
- Subtract the values of –2 log likelihood and compare to a chi-squared table with DOF = number of variance components – 1 (1 in this case)
- The p-values on the estimated variance components cannot be used to test for the need for random effects

## Interpretation of Results

- Estimated fixed effects are interpreted as in a fixed effects model
- Predicted random effects are a measure of the provider’s performance if he/she treated a large number of average patients
- A value of 0 means that the provider’s performance equals the group mean
- A value of 1 means that the provider’s patients have 2.7 times the mean number of encounters (we are in log space)

## Ranking

- Under certain conditions including normality, the probability that ranking based on the predicted random effects equals the unknown true ranking is maximized (over all possible rankings)
- Ranking based on O/E ratios, for example, has been shown to be inaccurate

## Uses of Hierarchical Models

- Profiling providers (physicians or hospitals)
- Ranking providers
- Estimating how much variation is due to clustering at various levels
- Longitudinal analysis
- Multicenter trials
- Split-plot experiments

## Advantages and Disadvantages of Hierarchical Models

- Advantages
- Correct modeling of variation
- If ordinary least squares model is used when there is hierarchical structure, estimated standard errors will be too small
- BLUPs are valid even when providers have a small number of patients
- Disadvantages
- Difficult to explain results to non-statisticians

## More complicated models(logistic regression)

- When the outcome is a dichotomous variable (e. g. death or catastrophic cost), we are interested in the unknown probability of occurrence pi
- Since a probability must lie in the interval [0,1], we instead use
- 	logit(pi) = log(pi/(1-pi) as dependent variable in the mixed model

## More Complicated Models(random coefficients model)

- Random intercept model example assumes that the case-mix adjustment affects all providers’ performance in the same way, except for a constant shift
- In a random coefficients model, the individual β have a fixed and random component
- Leads to a larger number of parameters to estimate