[R-sig-ME] Random intercept/slopes on two correlated outcomes

Thierry Onkelinx thierry.onkelinx at inbo.be
Wed Feb 1 09:49:58 CET 2017


Dear Theodore,

You can do this is you convert the dataset into long format.

untested

library(lme4)
library(tidyr)
long <- gather(dat, key = "trait", value = "Y", Y1, Y2)
lmer(Y ~ 0 + trait + trait * (age + X) + (0 + trait | id), data = long)

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2017-02-01 9:37 GMT+01:00 Theodore Lytras <thlytras op gmail.com>:

> Hi all,
>
> I have repeated measures on individuals, and I'm fitting two LMMs with
> random
> intercepts and slopes per participant, on two outcomes (Y1, Y2) as follows:
>
> library(lme4)
> m1 <- lmer(Y1 ~ age + X + (age | id), data=dat)
> m2 <- lmer(Y2 ~ age + X + (age | id), data=dat)
>
> Fixed covariates for the two outcomes are the same, and id = participant
> ID.
>
> However, my two continuous outcomes Y1 and Y2 are correlated (highly),
> thus I
> would like to jointly model them (including estimating their correlation).
>
> What is the appropriate way to do so in this case? Can lme4 do it, or do I
> have to resort to MCMCglmm or JAGS? Could someone point me in the right
> direction (for either lme4, MCMCglmm or JAGS), including any helpful
> papers,
> guides, etc ??
>
> Thank you,
>
> Theodore Lytras
>
> Epidemiologist, PhD student
> Hellenic Centre for Disease Control and Prevention
>
> _______________________________________________
> R-sig-mixed-models op r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list