trt | id | visit | score |
---|---|---|---|
1 | 1 | 1 | 20 |
1 | 1 | 2 | 15 |
1 | 1 | 3 | 14 |
1 | 1 | 4 | 13 |
1 | 1 | 5 | 13 |
1 | 2 | 1 | 14 |
1 | 2 | 2 | 12 |
1 | 2 | 3 | 12 |
ASR020. Random coefficient LMM for longitudinal data (random intercept and slope) - Treatment of Alzheimer’s disease
The complete script for this example can be downloaded here:
Dataset
The model that we will fit here is based on the D016 dataset, and the first few rows are presented below:
Model
In this example we will fit a LMM to analyze the effect of lecithin in the treatment of Alzheimer’s disease. The specification of the model is: \[ y = \mu + trt + visit + id + id:visit + e\ \]
where,\(y\) is the patient’s score,
\(\mu\) is the overall mean,
\(trt\) is the fixed effect of treatment,
\(visit\) is the fixed covariate (slope) of visit,
\(id\) is the random id intercept, with \(id \sim \mathcal{N}(0,\,\sigma^{2}_{ii})\),
\(id:visit\) is the random id slope, with \(id:visit \sim \mathcal{N}(0,\,\sigma^{2}_{is})\),
\(e\) is the random residual effect, with \(e \sim \mathcal{N}(0,\,\sigma^{2}_{e})\).Now, let’s take a look at how to write the model with ASReml-R. Note that before fitting the model, id
, and trt
need to be set as factors.
<- asreml(
asr020 fixed = score ~ trt + visit,
random = ~str(~id + id:visit, ~corgh(2):id(id)),
residual = ~units,
data = d016
)
The str()
model function is used to help define a covariance between model terms. It will fit a regression for each patient (id
) and estimate a random intercept deviation and a random slope deviation. This function requires a model formula (e.g., id + id:visit
) and a variance formula (e.g., corgh(2):id(id)
). Notice that the corgh()
function takes \(2\) as the argument value referring to a \(2 \times 2\) covariance matrix for the variance of the intercepts and slopes deviations.
Exploring output
The statistical significance of fixed effects can be tested as:
wald(asr020, denDF = 'numeric')$Wald
Df denDF F.inc Pr
(Intercept) 1 45 267.500 0.00000000
trt 1 45 9.435 0.00360478
visit 1 46 4.734 0.03473848
The fixed effects (BLUEs) are:
summary(asr020, coef = TRUE)$coef.fixed
solution std error z.ratio
(Intercept) 6.612252 1.1159019 5.925478
trt_1 0.000000 NA NA
trt_2 3.728371 1.2217984 3.051544
visit 0.493617 0.2268586 2.175880
The variance components estimated from this model are:
summary(asr020)$varcomp
component std.error z.ratio bound %ch
id+id:visit!corgh(2)!2:!corgh(2)!1.cor -0.7602775 0.07649541 -9.938865 U 0.1
id+id:visit!corgh(2)_1 39.8669098 10.18650554 3.913698 P 0.3
id+id:visit!corgh(2)_2 2.1085215 0.50571481 4.169389 P 0.0
units!R 3.1035732 0.36963180 8.396391 P 0.0
Note here that the correlation between slope and intercept was estimated (V1), as well as their variances (V2 and V3, respectively).
The random effects (BLUPs) are:
- An intercept deviation of each patient (
id
):
<- summary(asr020, coef = TRUE)$coef.random
BLUP head(BLUP)
solution std.error z.ratio
id_1 12.2434251 2.034937 6.0166116
id_2 7.3449500 2.034937 3.6094239
id_3 -0.3590487 2.034937 -0.1764422
id_4 1.2025444 2.034937 0.5909492
id_5 3.1734835 2.034937 1.5594997
id_6 2.3764461 2.034937 1.1678230
- A slope deviation of each patient (
id:visit
):
tail(BLUP)
solution std.error z.ratio
id_42:visit 1.3828391 0.5561379 2.4865040
id_43:visit 0.5472550 0.5561379 0.9840276
id_44:visit 2.0875126 0.5561379 3.7535881
id_45:visit 0.8185144 0.5561379 1.4717833
id_46:visit 2.4375519 0.5561379 4.3829992
id_47:visit 1.9958675 0.5561379 3.5887997