Mixed effects models EN - pdmoerland/wiki-biostatistiek-bilingual GitHub Wiki

Mixed effects models

Deze pagina lezen in het Nederlands.

This page was translated from the Dutch-language original using AI and has not been fully reviewed. Where the two differ, the Dutch version takes precedence.

Contents

Advanced models for clustered data

When there is clustering in the data, or the assumption of independent observations is not met in some other way (see also the page Repeated measures), simple regression techniques (generalized linear models) are not sufficient. Fortunately, several alternatives exist.

How do I specify a model that accounts for the clustered nature of the data?

When determining a suitable model, it is useful to make a distinction between

  1. studies in which all patients are repeatedly measured at (more or less) the same time points (or under the same conditions), and
  2. studies in which the number of repeated measurements per patient and/or the time points and conditions differ between patients.

Situation 1: repeated measurements at the same time points

If all patients are measured at the same time points (under the same conditions), the standard linear model can be extended with this extra 'dimension'. In formula form, the extension of the standard model looks as follows:

$Y_{i,t} = a + b \times X_{i,t} + \epsilon_{i,t}$

where $Y_{i,t}$ is the measurement of the $i^{th}$ patient at the $t^{th}$ time point (condition); $X_{i,t}$ is the measurement of the covariate at that moment and $\epsilon_{i,t}$ is the distance (or: residual) of the data points to the regression line. In a standard linear regression all these residuals are independent of each other, but with repeated measurements that is not necessarily the case. Namely, if the first data point of a patient lies (far) above (or below) the line, it is easy to imagine that subsequent data points from the same person will also lie above (or below) the regression line. In other words: data points from the same person resemble each other more than they resemble data points from other people. In a mixed model, the correlations between the residuals of measurements from the same patient are taken into account. This can be done in various ways and must be specified by the user. Common correlation structures are:

  • compound symmetry, in which it is assumed that the correlations between all residuals of the same person are equal. The first and second measurement of a person are thus just as strongly related to each other as the first and the last measurement of that person;
  • unstructured, in which no assumption at all is made about the correlations. Each correlation between two time points is determined independently of the others;

There are various other options and the best choice depends on the type of study and the number of repeated measurements. There are statistical measures that help you make this choice. The Akaike Information Criterion (AIC) is often used for this. This is a measure of how well the chosen model fits the data. The lower the AIC, the better the model fits.

This first type of extension of the standard linear model is also called a 'Generalized Least Squares Model'.

Situation 2: repeated measurements at different time points

If the number of repeated measurements per patient and/or the time points (conditions) at which measurements are taken differ between patients, it makes sense to extend the linear model in a different way. In situation 1, the correlation between measurement points at different time points was modeled directly. If measurements are not taken at fixed time points, this is not logical. The dependency of measurements within the same patient can also be modeled using so-called random effects. With random effects, an estimate is made of the deviation that measurements from the same patient have relative to the regression line. Here it does not matter how often and at which time points a patient was measured; all their measurements are assumed to have a fixed deviation from the 'average' regression line. In formula form this looks as follows:

$Y_{i,t} = (a+ \alpha_i) + (b+\beta_i) \times X_{i,t} + \epsilon_{i,t}$

where the newly added $\alpha_i$ and $\beta_i$ represent the specific deviations of patient $i$ relative to the regression line. The $\alpha_i$ is the deviation of the intercept of patient $i$ relative to the average intercept $a$. The $\beta_i$ is the deviation of the slope of patient $i$ relative to the average slope $b$ of the regression line. The $\alpha's$ and $\beta's$ are not estimated directly; instead they are assumed to be normally distributed with mean 0. The standard deviations of these distributions are estimated. The specifications of the random effects can be further extended, and the fit of the model is quantified with, for example, the AIC. Here too: the model with the lowest AIC fits the data best.

This second type of model is often referred to as 'Random Effect Models' or 'Mixed (Effects) Models'.

What is a GEE model?

A GEE, also called a marginal model, is yet another extension of generalized linear models with which (just like with mixed models and generalized least-squares models) clustered data can be analyzed (Liang and Zeger, 1986). The GEE model ignores the correlations between the repeated measurements or between the measurements within the same family or cluster, but corrects the standard errors of the regression coefficients by calculating robust standard errors. No assumption is made about the distribution of the measurements between families (the distribution of the 'random effect' in a mixed model), which can be an advantage of GEE compared with a mixed model.

How do I analyze an effect over time with a mixed model?

I am studying a group of patients who have undergone surgery. We are interested in the pain score (VAS) at various time points after surgery. The expectation is (of course) that pain immediately after surgery is more severe than, for example, 3 months later (this also turns out to be true when you put the data in a bar chart). Initially I used repeated measures ANOVA to analyze whether pain changes significantly over time. But, because I have some missing data, I also tried a mixed models analysis (here is my syntax). My questions about this:

1. Did I use the correct covariance structure? (i.e. AR1)

2. I took 'time' as a fixed effect because the decrease in VAS occurred at specific time points, is that correct?

3. How do you present the results of this mixed analysis?

  1. Whether AR(1) is the best cannot really be said in general; that depends on the correlation between the time points in your data. You could, for example, run all possible structures and then choose the one with the smallest AIC (smaller is better, as the output also notes).

  2. Time is indeed a fixed variable here, because you want to test the hypothesis of whether there is a change over time.

  3. In the output, under "fixed effects" you will find a B that indicates what the effect is per time point (relative to the starting point) and an associated p-value. This is the test you probably want to report. Under the heading "mean estimates" you will find the model's estimate for the mean VAS value at each time point. These mean estimates are easier for a reader to interpret than the B's.

How is a linear mixed model usually reported in an article?

I notice that there is not much to be found about this on Pubmed, and where there is something, it varies a great deal. For example, I found an article in which they only give the Beta coefficient with the associated p-value. But I would still like to also present the mean (±SD). Is it customary to do that per cluster? Or, for example, still a mean (±SD) per group?

You could present the raw data (mean ±SD) for each group. Here, however, the (cluster) correction of the mixed model has not yet been taken into account. Alternatively, you could report the estimated marginal means (+ confidence interval) from the model per group; these are 'corrected' for the clusters/correlations. You can also request these in SPSS.

What is the minimum number of observations needed when using a mixed model?

How many data points (clusters and/or patients) do I need if I want to use a mixed model?

This paper provides some guidance for binary outcomes. And this paper for continuous outcomes. And this paper for ordinal outcomes.

What is the difference between a mixed model and a GEE model?

I used a mixed model because I want to correct for the family relationships between my patients. However, in a paper with a similar analysis I see that a GEE model was used. Which one should I use and what is the difference?

Both models, a mixed model and a GEE model, can correct for family relationships (or other repeated-measurement structures). A GEE (generalized estimating equations), also called a marginal model, ignores the correlations between the repeated measurements within the same family, but corrects the standard errors of the regression coefficients by calculating robust standard errors. A mixed model, also called a conditional model or random-effects model, models the correlations between the repeated measurements within the same family by including a random effect for (the variation between) families in the model. The repeated measurements within a family share that random-effects parameter, and that is what makes those measurements correlate.

If you want to be able to say something about the size of the random effects (how much variation is explained by family differences), you therefore want to use a mixed model. However, you then need to be able to assume that the families are a 'random sample' from a normal distribution. If you are not particularly interested in the random effect itself, or if you cannot assume that the random effect for 'family' has a normal distribution, then the GEE model is probably a more suitable choice. The following page from The analysis factor gives a clear overview of the similarities and differences between the various models you can use for repeated measures.

Where do I find mixed models in SPSS?

You will find the linear mixed models under Analyze -> Mixed models -> Linear. Procedures for other types of outcomes, such as dichotomous variables, can be found under Analyze -> Mixed Models -> Generalized.

Note: in order to run a mixed model in SPSS, the data must be structured with each measurement on its own row and multiple rows belonging to the same patient (long format). This SPSS manual describes step by step how to restructure data into the format required for mixed models. If there are three repeated measurements from three patients, the result looks like this, for example:

patientnumber measurementno measurement
1 1 10
1 2 9
1 3 11
2 1 8
2 2 11
2 3 12
3 1 5
3 2 8
3 3 9

The mixed model (the modeling discussed in 'situation 2') is specified under the 'Random...' button. Note: random intercept is turned off by default! Under 'covariance type' the correlation between the random effects can be specified.

Where do I find Generalized Least Squares models in SPSS?

The 'situation 1' described above (Generalized Least Squares Model) can also be found in SPSS under Analyze -> Mixed Models. However, in that case you choose 'Repeated' (and the corresponding repeated covariance type) in the first panel of the procedure.

It is therefore possible in SPSS to use both options at the same time ('Repeated' and 'Random'), but this will sometimes lead to redundant parameters. Often, using just one of the two options (either 'Repeated' or 'Random') is enough to capture the correlation in the data.

Where do I find Generalized Estimating Equations in SPSS?

You will find GEE in SPSS under Analyze -> Generalized Linear Models -> Generalized Estimating Equations.

What options for using mixed models are there in other packages?

In other packages such as R (package 'nlme' and package 'lme4'), Stata (GLAMM) and SAS, mixed models are available for various types of outcome measures.


Finished reading? You can go to the Overview of all topics, or to Choosing a test for help picking a suitable test or analysis. Want to learn more about biostatistics? Then follow the AMC e-learning Practical Biostatistics. Did you find something on these pages that isn't correct? Does a link not work? Or would you like to contribute to the wiki? Then get in touch with us.

This biostatistics wiki is an initiative of the former statistics helpdesk of Amsterdam UMC, location AMC. Amsterdam UMC staff can request statistical support via intranet.

⚠️ **GitHub.com Fallback** ⚠️