# Multilevel modeling for repeated measures

One application of multilevel modeling (MLM) is the analysis of repeated measures data. Multilevel modeling for repeated measures data is most often discussed in the context of modeling change over time (i.e. growth curve modeling for longitudinal designs); however, it may also be used for repeated measures data in which time is not a factor.
In multilevel modeling, an overall change function (e.g. linear, quadratic, cubic etc.) is fitted to the whole sample and, just as in multilevel modeling for clustered data, the slope and intercept may be allowed to vary. For example, in a study looking at income growth with age, individuals might be assumed to show linear improvement over time. However, the exact intercept and slope could be allowed to vary across individuals (i.e. defined as random coefficients).
Multilevel modeling with repeated measures employs the same statistical techniques as MLM with clustered data. In multilevel modeling for repeated measures data, the measurement occasions are nested within cases (e.g. individual or subject). Thus, level-1 units consist of the repeated measures for each subject, and the level-2 unit is the individual or subject. In addition to estimating overall parameter estimates, MLM allows regression equations at the level of the individual. Thus, as a growth curve modeling technique, it allows the estimation of inter-individual differences in intra-individual change over time by modeling the variances and covariances. In other words, it allows the testing of individual differences in patterns of responses over time (i.e. growth curves). This characteristic of multilevel modeling makes it preferable to other repeated measures statistical techniques such as repeated measures-analysis of variance (RM-ANOVA) for certain research questions.

## Assumptions

The assumptions of MLM that hold for clustered data also apply to repeated measures:
    (1) Random components are assumed to have a normal distribution with a mean of zero
    (2) The dependent variable is assumed to be normally distributed. However, binary and discrete dependent variables may be examined in MLM using specialized procedures (i.e. employ different link functions).
One of the assumptions of using MLM for growth curve modeling is that all subjects show the same relationship over time (e.g. linear, quadratic etc.). Another assumption of MLM for growth curve modeling is that the observed changes are related to the passage of time.

## Statistics & Interpretation

Mathematically, multilevel analysis with repeated measures is very similar to the analysis of data in which subjects are clustered in groups. However, one point to note is that time-related predictors must be explicitly entered into the model to evaluate trend analyses and to obtain an overall test of the repeated measure. Furthermore, interpretation of these analyses is dependent on the scale of the time variable (i.e. how it is coded).
* Fixed Effects: Fixed regression coefficients may be obtained for an overall equation that represents how, averaging across subjects, the subjects change over time.
* Random Effects: Random effects are the variance components that arise from measuring the relationship of the predictors to Y for each subject separately. These variance components include: (1) differences in the intercepts of these equations at the level of the subject; (2) differences across subjects in the slopes of these equations; and (3) covariance between subject slopes and intercepts across all subjects. When random coefficients are specified, each subject has its own regression equation, making it possible to evaluate whether subjects differ in their means and/or response patterns over time.
* Estimation Procedures & Comparing Models: These procedures are identical to those used in multilevel analysis where subjects are clustered in groups.

### Extensions

* Modeling Non-Linear Trends (Polynomial Models):
   * Non-linear trends (quadratic, cubic, etc.) may be evaluated in MLM by adding the products of Time (TimeXTime, TimeXTimeXTime etc.) as either random or fixed effects to the model.
* Adding Predictors to the Model: It is possible that some of the random variance (i.e. variance associated with individual differences) may be attributed to fixed predictors other than time. Unlike RM-ANOVA, multilevel analysis allows the use of continuous predictors (rather than only categorical), and these predictors may or may not account for individual differences in the intercepts as well as for differences in slopes. Furthermore, multilevel modeling also allows time-varying covariates.
* Alternative Specifications:
   * Covariance Structure: Multilevel software provides several different covariance or error structures to choose from for the analysis of multilevel data (e.g. autoregressive). These may be applied to the growth model as appropriate.
   * Dependent Variable: Dichotomous dependent variables may be analyzed with multilevel analysis by using more specialized analysis (i.e. using the logit or probit link functions).

## Multilevel modeling versus other statistical techniques for repeated measures
### Multilevel Modeling versus RM-ANOVA

Repeated measures analysis of variance (RM-ANOVA) has been traditionally used for analysis of repeated measures designs. However, violation of the assumptions of RM-ANOVA can be problematic. Multilevel modeling (MLM) is commonly used for repeated measures designs because it presents an alternative approach to analyzing this type of data with three main advantages over RM-ANOVA:
       1. MLM has Less Stringent Assumptions: MLM can be used if the assumptions of constant variances (homogeneity of variance, or homoscedasticity), constant covariances (compound symmetry), or constant variances of differences scores (sphericity) are violated for RM-ANOVA. MLM allows modeling of the variance-covariance matrix from the data; thus, unlike in RM-ANOVA, these assumptions are not necessary.
       2. MLM Allows Hierarchical Structure: MLM can be used for higher-order sampling procedures, whereas RM-ANOVA is limited to examining two-level sampling procedures. In other words, MLM can look at repeated measures within subjects, within a third level of analysis etc., whereas RM-ANOVA is limited to repeated measures within subjects.
       3. MLM can Handle Missing Data: Missing data is permitted in MLM without causing additional complications. With RM-ANOVA, subject’s data must be excluded if they are missing a single data point. Missing data and attempts to resolve missing data (i.e. using the subject’s mean for non-missing data) can raise additional problems in RM-ANOVA.
       4. MLM can also handle data in which there is variation in the exact timing of data collection (i.e. variable timing versus fixed timing). For example, data for a longitudinal study may attempt to collect measurements at age 6 months, 9 months, 12 months, and 15 months. However, participant availability, bank holidays, and other scheduling issues may result in variation regarding when data is collected. This variation may be addressed in MLM by adding “age” into the regression equation. There is also no need for equal intervals between measurement points in MLM.
       5. MLM is relatively easily extended to discrete data.
       Note: Although missing data is permitted in MLM, it is assumed to be missing at random. Thus, systematically missing data can present problems.

### Multilevel Modeling versus Structural Equation Modeling (SEM; Latent Growth Model)

An alternative method of growth curve analysis is latent growth curve modeling using structural equation modeling (SEM). This approach will provide the same estimates as the multilevel modeling approach, provided that the model is specified identically in SEM. However, there are circumstances in which either MLM or SEM are preferable:
    Multilevel modeling approach:
      * For designs with a large number of unequal intervals between time points (SEM cannot manage data with a lot of variation in time points)
      * When there are many data points per subject
      * When the growth model is nested in additional levels of analysis (i.e. hierarchical structure)
      * Multilevel modeling programs have for more options in terms of handling non-continuous dependent variables (link functions) and allowing different error structures
    Structural equation modeling approach:
      * Better suited for extended models in which the model is embedded into a larger path model, or the intercept and slope are used as predictors for other variables. In this way, SEM allows greater flexibility.
The distinction between multilevel modeling and latent growth curve analysis has become less defined. Some statistical programs incorporate multilevel features within their structural equation modeling software, and some multilevel modeling software is beginning to add latent growth curve features.

## Data Structure

Multilevel modeling with repeated measures data is computationally complex. Computer software capable of performing these analyses may require data to be represented in “long form” as opposed to “wide form” prior to analysis. In long form, each subject’s data is represented in several rows – one for every “time” point (observation of the dependent variable). This is opposed to wide form in which there is one row per subject, and the repeated measures are represented in separate columns. Also note that, in long form, time invariant variables are repeated across rows for each subject. See below for an example of wide form data transposed into long form:
Wide form:
| Subject | Group | Time0 | Time1 | Time2 |
| 1 | 1 | 12 | 8 | 4 |
| 2 | 1 | 11 | 7 | 6 |
| 3 | 2 | 15 | 12 | 10 |
| 4 | 2 | 11 | 10 | 9 |
Long form:
| Subject | Group | Time | DepVar |
| 1 | 1 | 0 | 12 |
| 1 | 1 | 1 | 8 |
| 1 | 1 | 2 | 4 |
| 4 | 2 | 0 | 11 |
| 4 | 2 | 1 | 10 |
| 4 | 2 | 2 | 9 |