Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
186 views
in Technique[技术] by (71.8m points)

Modeling longitudinal correlation correctly with nlme when there are missing outcomes (R)

I have longitudinal data in long format which look, for the first two subjects, like this:

  id X  M     Y
1  1 0 M1  2.53
2  1 0 M2  1.45
3  1 0 M3  1.17
4  1 0 M5  0.78
5  1 0 M7 -0.95
6  1 0 M9 -0.07
7  2 1 M1 -0.81
8  2 1 M2 -1.66
9  2 1 M3 -0.01
10 2 1 M5  0.39

M1 to M9 denote nine different fixed measurement occasions. As typical with longitudinal data, some outcomes Y are missing. Subject id 1 misses outcomes for M4, M6, M8, and id 2 misses M4 and M6 to M9. Other subjects in the data miss data at different points.

A random intercept model fit with lme with occasions and the covariate X as fixed effects is

lme(fixed = Y ~ M + X, random = ~ 1 | id , data  = dat)

It is well known that this yields implicitly a compound symmetry correlation structure and the estimates are consistent as long as the missing outcomes are MAR. If compound symmetry is not plausible, it is an option to add random slopes or to specify a different correlation structure, such as unstructured.

lme(fixed = Y ~ M + X, random = ~ 1 | id , data  = dat, correlation = corSymm())

Then in the output I get a within group correlation matrix of M1 to M9. However, how does lme know which time points M are adjacent, i.e. what the ordering is and where two outcomes are not adjacent? For example, for id 1, it looks like lme will take its first 6 measurements as M1, M2, ..., M6, instead of, as it should be, M1, M2, M3, M5, M7, and M9. So I am concerned the unstructured correlation matrix is incorrectly estimated. Is there a way to pass the information to lme which time points are concerned for each Y?

question from:https://stackoverflow.com/questions/65935686/modeling-longitudinal-correlation-correctly-with-nlme-when-there-are-missing-out

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If M1 to M9 are fixed measurement occasions, they can be identified as time and treated as a continuous variable.

library(nlme)
# arbitrary time selected from the measurement occasion labels
dat$T <- as.numeric(sub("M", "", dat$M))
lme(fixed = Y ~ T + X, random = ~ 1 | id , data  = dat) 

Alternatively, the corSymm structure can contain information on a time covariate and define the order of the measurements.

corSymm(form = ~ T)

Note that T must contain a sequence of consecutive integers to be successfully used as a time covariate in the correlation structure.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...