[R-sig-ME] simulate.lme for correlation in repeated measure

Ben Bolker bbolker at gmail.com
Fri Nov 29 19:04:53 CET 2013


On 13-11-29 01:11 AM, bbonit at tin.it wrote:
> Dear list, good morning I would like to ask You (and in particular to
> professor Ben Bolker and Professor Bates) how i can silmulate dataset
> fittet with lme where there is specied correlation argument in lme
> function .  simulate.leme function give error and doesn' t allow this
> kind of operation Can someome prototipe an example how i can i do for
> solve this problem? Thank You so much in advance list ..sorry for
> noise Bonitta Gianluca

  I don't know of a canned solution.  You can simulate correlated
multivariate normal deviates using mvrnorm() from the MASS package, or
slightly more efficiently by using the machinery from the nlme package
to construct the Cholesky factors

library(nlme)
cs1 <- corAR1(form = ~1 | Subject, value=0.6)
cs1 <- Initialize(cs1, data = Orthodont)
## get Cholesky factor rather than correlation matrix
cm <- corMatrix(cs1,corr=FALSE)
library(Matrix)
mm <- bdiag(cm)
image(mm)

  That might get you started, but if you need a more canned solution I
hope someone else comes forward with one ...



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