Why Work Through a Logistic Random-Slope Model?
In a logistic random-slope model, clusters can differ both in their baseline odds and in how their odds change with a covariate. The fixed slope describes the common part of that change; each cluster’s random slope adjusts it. Consequently, interpreting the fixed slope alone does not describe the covariate effect in every cluster. A useful interpretation works through the linear predictor, converts it to odds or probability, and states which cluster and covariate value are being discussed.
This tutorial uses a hypothetical binary outcome: whether a participant experiences an event by a specified follow-up time. The covariate \(x\) is dose, measured in units of 10 mg. All parameters and random-effect values below are hypothetical and are treated as given for calculation; they are not estimates from a real study.
Model and Conditional Interpretations
Let \(Y_{ij}\) indicate whether the event occurred for observation \(i\) in cluster \(j\), and let \(x_{ij}\) denote that observation’s dose. Write \(b_{0j}\) and \(b_{1j}\) for cluster \(j\)’s random intercept and random slope. The logistic random-slope model is
Here \(p_{ij}=P(Y_{ij}=1\mid x_{ij},b_{0j},b_{1j})\) is the conditional event probability. The cluster-specific intercept is \(\beta_0+b_{0j}\), and the cluster-specific slope is \(\beta_1+b_{1j}\). Because one unit of \(x\) represents a 10-mg dose increase, that slope is a change in conditional log odds per 10 mg.
For probability calculations, first find the cluster-specific linear predictor \(\eta_j(x)=\beta_0+b_{0j}+(\beta_1+b_{1j})x\), then apply the inverse-logit function:
A cluster comparison at a fixed covariate value is different from a one-unit increase within a cluster. For clusters \(B\) and \(A\), the conditional log-odds difference at \(x\) is \((b_{0B}-b_{0A})+(b_{1B}-b_{1A})x\). Exponentiating it gives the conditional odds ratio for \(B\) versus \(A\). This contrast can change with \(x\) whenever their random slopes differ.
A Short Derivation of the Odds-Ratio Formula
For a fixed cluster \(j\), compare the conditional log odds at \(x+\Delta\) with those at \(x\). Subtracting the two linear predictors cancels the intercept:
Since a difference in log odds is the log of the corresponding odds ratio, exponentiating this difference yields \(\exp\{(\beta_1+b_{1j})\Delta\}\). The derivation also shows why the cluster intercept affects the probability at a given \(x\), but not the within-cluster odds ratio for a change in \(x\).
Worked Example: The Dose Effect Within Each Cluster
Suppose the fixed effects are \(\beta_0=-1\) and \(\beta_1=0.8\). For hypothetical clusters \(A\) and \(B\), let \((b_{0A},b_{1A})=(0.2,-0.4)\) and \((b_{0B},b_{1B})=(-0.1,0.1)\). Calculate each cluster’s conditional odds ratio for a 10-mg increase.
For cluster \(A\), its slope is \(\beta_1+b_{1A}=0.8-0.4=0.4\) log-odds units per 10 mg. Therefore, \(\exp(0.4)=1.4918\). At any specified starting dose, a 10-mg increase multiplies the cluster’s conditional event odds by about 1.49.
For cluster \(B\), its slope is \(\beta_1+b_{1B}=0.8+0.1=0.9\). Its conditional odds ratio is \(\exp(0.9)=2.4596\). Thus, a 10-mg increase multiplies cluster \(B\)’s conditional event odds by about 2.46.
These are odds multipliers, not changes of 49.18 or 145.96 percentage points in probability. The probability change depends on the starting probability, so it must be calculated at the relevant dose.
Calculate Probabilities at Several Covariate Values
For the same parameters, the linear predictors simplify to \(\eta_A(x)=-0.8+0.4x\) and \(\eta_B(x)=-1.1+0.9x\). Compute probabilities by substituting each \(x\) into the appropriate predictor and applying the inverse logit. For instance, in cluster \(A\) at \(x=1\), \(\eta_A(1)=-0.8+0.4=-0.4\), so \(p_A(1)=1/(1+\exp(0.4))=0.4013\).
Worked Example: Conditional Probabilities at Three Doses
Calculate the conditional event probabilities in clusters \(A\) and \(B\) at \(x=0,1,2\), corresponding to doses of 0, 10, and 20 mg.
For cluster \(A\), the linear predictors at those values are \(-0.8\), \(-0.4\), and \(0\). The corresponding substitutions are \(1/(1+\exp(0.8))=0.3100\), \(1/(1+\exp(0.4))=0.4013\), and \(1/(1+\exp(0))=0.5000\).
For cluster \(B\), the linear predictors are \(-1.1\), \(-0.2\), and \(0.7\). Thus the probabilities are \(1/(1+\exp(1.1))=0.2497\), \(1/(1+\exp(0.2))=0.4502\), and \(1/(1+\exp(-0.7))=0.6682\).
| Dose \(x\) | Cluster A: \(\eta_A(x)\) | Cluster A: \(p_A(x)\) | Cluster B: \(\eta_B(x)\) | Cluster B: \(p_B(x)\) |
|---|---|---|---|---|
| 0 (0 mg) | -0.8 | 0.3100 | -1.1 | 0.2497 |
| 1 (10 mg) | -0.4 | 0.4013 | -0.2 | 0.4502 |
| 2 (20 mg) | 0 | 0.5000 | 0.7 | 0.6682 |
The table gives probabilities conditional on the stated random effects. For example, at 20 mg, the model assigns cluster \(B\) a conditional event probability of 0.6682, or about 66.82%. That statement is about the model prediction for that cluster at that dose, not a claim that dose causes the event.
Compare Clusters at the Same Dose
Worked Example: A Cluster Contrast That Changes With Dose
Using the same model, compare cluster \(B\) with cluster \(A\) at 0, 10, and 20 mg. At \(x=1\), the log-odds difference is \((-0.1-0.2)+(0.1-(-0.4))(1)=-0.3+0.5=0.2\). The odds ratio is therefore \(\exp(0.2)=1.2214\). Equivalently, the conditional odds are \(\exp(-0.2)=0.8187\) in \(B\) and \(\exp(-0.4)=0.6703\) in \(A\); their ratio is \(0.8187/0.6703=1.2214\).
The probability difference at this dose is \(p_B(1)-p_A(1)=0.4501660-0.4013123=0.0488537\), which rounds to 0.0489. Thus, at 10 mg, cluster \(B\)’s conditional odds are about 1.22 times cluster \(A\)’s, and its conditional probability is about 0.0489 higher, or 4.89 percentage points higher.
At \(x=0\), the log-odds difference is \(-0.3\), giving an odds ratio of \(\exp(-0.3)=0.7408\). The probability difference is \(0.2497-0.3100=-0.0603\), so \(B\)’s conditional probability is about 6.03 percentage points lower. At \(x=2\), the log-odds difference is \(-0.3+0.5(2)=0.7\), giving an odds ratio of \(\exp(0.7)=2.0138\). The probability difference is \(0.6682-0.5000=0.1682\), or about 16.82 percentage points higher in \(B\).
The contrast changes direction because the clusters have different slopes: \(B\) has a larger conditional slope than \(A\). The probability difference also changes in size because the inverse-logit transformation is nonlinear.
Assumptions, Diagnostics, and Interpretation Limits
These calculations rely on a model in which the conditional log odds are linear in \(x\), with the stated fixed and random effects. For a conventional random-intercept and random-slope specification, the random-effects vector \((b_{0j},b_{1j})\) is modeled as having mean zero and a specified joint distribution, commonly a bivariate normal distribution with an estimated covariance matrix. Observations are taken to be conditionally independent given their covariates and cluster random effects, and distinct clusters are assumed independent under the model. For the worked arithmetic, the values of \(b_{0j}\) and \(b_{1j}\) are simply supplied; the computations do not depend on how they were obtained.
A calculation can be arithmetically correct while the model is a poor description of the data. Check whether the log-odds relationship with \(x\) is plausible over the observed range, whether the fitted model converged, and whether estimated random-effect variation and covariance are supported by the data. Predictions far beyond the observed covariate range are especially fragile: the model continues a linear trend on the log-odds scale, which may not be credible there. Also check whether the chosen dose unit is clear; changing the unit changes the numerical slope and odds ratio, though not the underlying fitted relationship.
The examples report conditional predictions for particular random-effect values. In an actual analysis, estimated cluster effects are uncertain, and that uncertainty should be considered when making inferential claims. A conditional probability at specified random effects is not automatically a population-average probability. Averaging over the random-effects distribution generally requires averaging probabilities, not simply applying the inverse logit to the fixed-effects linear predictor; because the inverse-logit function is nonlinear, these operations need not agree.
Common Pitfalls and Alternatives
- Using only the fixed slope. \(\exp(\beta_1)\) is not the one-unit conditional odds ratio for every cluster when random slopes are present. For cluster \(j\), use \(\exp(\beta_1+b_{1j})\).
- Calling an odds ratio a probability increase. An odds ratio of 1.22 does not mean a 22-percentage-point increase. Calculate both conditional probabilities when a probability difference is needed.
- Comparing clusters without specifying \(x\). With different random slopes, the cluster odds ratio depends on the covariate value. State the dose at which the comparison is made.
- Confusing conditional and population-average results. A random-effects value-specific prediction describes a cluster conditional on its effects. A marginal prediction averages over the random-effects distribution and is a different quantity.
A random-intercept-only logistic model is a simpler alternative: it allows clusters to have different baselines but imposes a common covariate slope, so its within-cluster odds ratio for a one-unit increase is the same across clusters. A model with cluster indicators and cluster-specific slopes is another possible approach, but it does not impose the same random-effects distribution and partial-pooling structure. The appropriate choice depends on the scientific target and design; no one set of conditional calculations alone establishes that the model is adequate.
Check Your Understanding
Answer each question, then compare with the solutions below.
- If \(\beta_1=0.6\) and a cluster’s random slope is \(b_{1j}=-0.2\), what is its conditional odds ratio for a one-unit increase in \(x\)?
- For a cluster with linear predictor \(\eta=-0.5\) at a specified \(x\), calculate its conditional probability.
- Two clusters have a log-odds difference of \(0.3-0.2x\), where the difference is for cluster \(B\) minus cluster \(A\). Calculate the \(B\)-versus-\(A\) conditional odds ratio at \(x=0\) and \(x=2\).
- Why is \(\exp(\beta_1)\) generally not the conditional odds ratio for every cluster in a random-slope model?
Solutions. (1) The cluster slope is \(0.6-0.2=0.4\), so the odds ratio is \(\exp(0.4)=1.492\). (2) \(p=1/(1+\exp(0.5))=0.3775\). (3) At \(x=0\), the log-odds difference is \(0.3\), so the odds ratio is \(\exp(0.3)=1.350\). At \(x=2\), it is \(0.3-0.2(2)=-0.1\), so the odds ratio is \(\exp(-0.1)=0.9048\). (4) The cluster-specific slope is \(\beta_1+b_{1j}\), so its odds ratio is \(\exp(\beta_1+b_{1j})\); it varies with the random slope \(b_{1j}\).