Tutorials › Multiple Imputation by Chained Equations (MICE) › Changing Membership In Longitudinal Clusters

Nested and Multilevel Data · Tutorial 378 of 497

Changing Membership In Longitudinal Clusters

You will learn to represent each person’s cluster membership at the time of each record and use that changing structure in longitudinal imputations.

Advanced 10 min read

What You'll Learn

  • Distinguish a person’s stable cluster from the cluster associated with each time-specific record.
  • Decide when longitudinal records have stable, changing, or multiple cluster membership.
  • Formulate an imputation model that represents both repeated measurements and current cluster membership.
  • Derive how membership changes affect covariance between records.
  • Work through a numerical MICE imputation draw using time-specific membership.
  • Identify common coding errors and practical checks for changing membership.

Why membership must be indexed over time

A longitudinal data set may record a person repeatedly while the group surrounding that person changes. A patient may attend different clinics, a student may change schools, or an employee may move between teams. In each case, the person remains the same observational unit, but the cluster associated with a record may not. An imputation model that assigns one permanent cluster to that person can then represent the wrong dependence among records.

The key question is not simply “Which cluster does this person belong to?” It is “Which cluster is relevant to this record, at this time, and under the data-generating structure?” Some cluster membership is stable throughout follow-up; some changes at recorded times; and some records may reflect simultaneous membership in more than one group. These situations require different representations in the imputation model.

Definition: Let \(i\) index people and \(t\) index their observed time points. A stable membership variable \(g_i\) identifies the same cluster for every record from person \(i\). A time-varying membership variable \(g_{it}\) identifies the cluster associated with person \(i\)'s record at time \(t\). Membership is time-varying when \(g_{it}\) can differ across observed times for the same person.

Membership is a property of the record’s grouping structure, not an outcome to be filled in merely because an outcome value is missing. If membership is known, retain it as design information in the long data: each record must carry the cluster identifier that applies at that time. If membership itself is unknown, its uncertainty needs explicit treatment rather than an automatic assignment to the person’s first, last, or most frequent cluster.

Representing the membership structure

For a continuous outcome \(Y_{it}\), a basic model that separates person-level repetition from current cluster membership is

$$ Y_{it} = \boldsymbol{x}_{it}^{\mathsf T}\boldsymbol{\beta} + a_i + b_{g_{it}} + \epsilon_{it}. $$

Here \(\boldsymbol{x}_{it}\) contains predictors for that record, \(\boldsymbol{\beta}\) is a vector of regression coefficients, \(a_i\) is a person-specific random intercept, \(b_{g_{it}}\) is the random intercept for the cluster attached to that record, and \(\epsilon_{it}\) is the record-level residual. This is one useful structure, not a universal model. For example, the cluster effect may be unnecessary if the design and substantive assumptions do not support clustering, and other outcome types require a suitable conditional model rather than a Gaussian one.

For this formulation to describe the data, the identifiers and record-to-cluster links must be correct. A standard random-effects version assumes mean-zero random effects, independent across distinct people or clusters, and independent of the predictors conditional on the model. It also assumes residuals with the specified distribution and dependence structure. For a simple Gaussian illustration, take \(a_i\), \(b_g\), and \(\epsilon_{it}\) to be mutually independent, with variances \(\sigma_a^2\), \(\sigma_b^2\), and \(\sigma_\epsilon^2\), respectively. The model should also include relevant observed information associated with the outcome’s missingness so that the imputation is appropriate under the assumed missing-at-random mechanism. These are modeling assumptions, not consequences of using MICE.

In chained equations, the conditional model for a variable with missing values should use the membership applicable to each record, alongside the person-level repeated-measure structure and relevant predictors. If a person moves from cluster A to cluster B, their record in A should not be silently relabeled B, nor should the person-level identifier be mistaken for a stable cluster identifier. The model must also respect the actual time structure: a move between observed occasions does not create a record at every unobserved time.

Worked Example: Classifying stable and changing membership

Suppose a hypothetical data set has the following three records for each of four people. The letters identify clinics, and each row is one person-time record.

PersonTime 1 clinicTime 2 clinicTime 3 clinic
ANorthNorthNorth
BNorthEastEast
CWestWestSouth
DEastEastEast

For A and D, clinic membership is stable over the recorded times: their clinic identifier can be represented by \(g_i\). For B and C, it changes, so the appropriate record-level identifiers are \(g_{it}\). B contributes one record to North and two to East; C contributes two to West and one to South.

There are two membership transitions across the four people: B changes between Times 1 and 2, and C changes between Times 2 and 3. The correct long representation therefore has 12 records and assigns the clinic separately on every row. A person-level field such as “clinic at baseline” could still be retained as a baseline descriptor, but it cannot replace the current clinic identifier in a model intended to account for the clinic associated with each outcome.

This classification follows directly from comparing each person’s identifiers across time. It does not assume that a move caused any outcome change; it only establishes which cluster is linked to each record.

Why changing membership changes dependence

The distinction can be justified through the covariance implied by the model. Consider two different records \(Y_{it}\) and \(Y_{is}\) from the same person, with independent record-level residuals. Both records contain the same person effect \(a_i\). They share the cluster effect only if their cluster identifiers match. Thus

$$ \operatorname{Cov}(Y_{it},Y_{is}) = \sigma_a^2 + \sigma_b^2 I(g_{it}=g_{is}), \qquad t\ne s, $$

where \(I(g_{it}=g_{is})\) is 1 if the two records have the same cluster and 0 otherwise. The equation follows by expanding the covariance: independent random effects and residuals contribute zero cross-covariance, while the shared person effect contributes \(\operatorname{Var}(a_i)=\sigma_a^2\). A shared cluster effect contributes \(\operatorname{Var}(b_g)=\sigma_b^2\); if the cluster identifiers differ, the two independent cluster effects have covariance zero.

Consequently, two records from one person can remain correlated after a move because they share \(a_i\), but they need not share the current-clinic component. Conversely, records from different people in the same clinic may share a clinic effect. A model that treats a person’s baseline clinic as their permanent clinic can impose shared-clinic dependence where none is appropriate and omit it where the person later joins another cluster.

Worked Example: Comparing covariance under a move

Assume the model above has \(\sigma_a^2=4\), \(\sigma_b^2=9\), and \(\sigma_\epsilon^2=1\). These values are hypothetical variances, in squared outcome units. Person B has one record in North and a later record in East.

The two records share the person effect but have different clinic effects, so

$$ \operatorname{Cov}(Y_{B,1},Y_{B,2}) =4+9I(\text{North}=\text{East}) =4+9(0) =4. $$

Each record has variance \(4+9+1=14\), so their correlation under these assumptions is

$$ \operatorname{Corr}(Y_{B,1},Y_{B,2}) = \frac{4}{\sqrt{14\cdot 14}} = \frac{4}{14} \approx 0.286. $$

If the same person had two records in North instead, the covariance would be \(4+9=13\), and the correlation would be \(13/14\approx0.929\). Assigning B permanently to North would therefore imply a covariance of 13 for the North-to-East pair, rather than the model-implied covariance of 4. These calculations isolate the grouping consequence; they do not establish that this particular variance structure is appropriate for any real data set.

Using the structure in an imputation draw

A MICE iteration draws missing values from conditional models. When cluster membership changes, a draw for a missing record should condition on the cluster attached to that record, not on a single cluster assigned to the person for convenience. For multilevel conditional models, uncertainty in the regression coefficients and random effects matters: an imputed value should represent a draw from the predictive distribution, rather than only the fitted conditional mean.

The following calculation illustrates one draw for a continuous outcome under a specified Gaussian model. The example assumes the membership identifier is observed, the conditional mean structure is adequate, and the random-effect values shown are draws from their relevant conditional distributions. In practice, those draws depend on the fitted model and observed data.

Worked Example: Drawing a value in the current cluster

Suppose the conditional model is \(Y_{it}=10+2x_{it}+a_i+b_{g_{it}}+\epsilon_{it}\). A missing outcome belongs to person P’s record in clinic East, with \(x_{it}=3\). For one hypothetical MICE draw, suppose the sampled person effect is \(a_i=-1.2\), the sampled East clinic effect is \(b_{\text{East}}=0.8\), and the sampled residual is \(\epsilon_{it}=0.5\).

Substitute those draws and the observed predictor value:

$$ Y_{it}^{\mathrm{imp}} =10+2(3)+(-1.2)+0.8+0.5 =10+6-1.2+0.8+0.5 =16.1. $$

Thus this iteration contributes an imputed value of 16.1 outcome units. It is one predictive draw, not a claim that the conditional mean is exactly 16.1. If P previously belonged to West, the missing East record still uses the East effect for this draw. Using a West effect solely because it was P’s earlier clinic would encode the wrong record-to-cluster link.

Practical choices, diagnostics, and limitations

When the cluster identifier is unchanged across a person’s records, a stable-membership multilevel structure may be suitable. When it changes, the model must represent the time-specific link. If a record genuinely belongs to several clusters simultaneously, a single \(g_{it}\) is not enough; a multiple-membership formulation can represent weighted contributions from those clusters. The weights should reflect the design or exposure definition, rather than being chosen simply to make the model easier to fit.

Several simpler alternatives may be reasonable in particular settings, but they answer different modeling needs. Imputing without cluster information can be inadequate when outcomes within clusters are dependent. Treating every cluster as a fixed indicator can be difficult with many clusters or sparse membership, and does not by itself create a person-level repeated-measure structure. Assigning each person one permanent cluster is appropriate only when membership is in fact stable for the model’s purpose. Aggregating a person’s records to one value may discard time-specific information and is not a substitute for modeling changing membership when the estimand concerns records over time.

Before fitting, inspect the membership structure itself. A transition table can reveal moves, unexpected identifier changes, and records with missing or inconsistent cluster IDs. Tabulate the number of people and records per cluster at each time, since a cluster with very few observed members may provide little information for estimating a cluster-level variance. Confirm that each person-time record has exactly the membership intended by the study design. After fitting, check whether imputed distributions and within-cluster patterns are plausible across times and whether the model encounters sparse or unsupported groups. These checks do not prove that the model is correct, but they can expose coding and specification failures.

A common mistake is to say, “Each person belongs to one clinic, so I will assign their baseline clinic to every row.” That reasoning confuses a person identifier with a record’s current cluster membership. If a person moves, the baseline label does not describe later records. The correction is to preserve the time-specific membership variable and use it in the relevant conditional model, while retaining the person identifier to represent repeated observations.

Key takeaway: Keep the person identifier and the cluster identifier conceptually separate. Use a stable \(g_i\) only when membership is stable for the analysis; otherwise attach \(g_{it}\) to each record and make the imputation structure reflect that changing relationship.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. A person contributes records to Team R at Times 1 and 2 and Team S at Time 3. Is team membership stable or time-varying, and which identifier belongs on each record?
  2. Under the stated random-intercept model, two records from the same person belong to different clusters. Which random effect contributes to their covariance?
  3. Why is the baseline cluster not automatically the appropriate cluster effect for a later record after a move?
  4. What additional modeling idea may be needed if one record simultaneously belongs to two clinics?

Solutions. (1) Membership is time-varying. The records should carry \(g_{i1}=\text{R}\), \(g_{i2}=\text{R}\), and \(g_{i3}=\text{S}\). (2) The shared person effect contributes \(\sigma_a^2\); distinct independent cluster effects have zero covariance under the model. (3) The later record is linked to its current cluster, so using the baseline cluster would assign the wrong cluster-level dependence. (4) A multiple-membership formulation can represent both clinics, with weights defined from the study’s membership or exposure structure.

Clinical Biostats