[R] start values for random effects in nlme

Jos Lommerse jos.lommerse at certara.com
Wed Jan 3 14:09:52 CET 2018


Hi Lindsey,

Yeah, I do realize that this answer gets to you 12 years too late, however, it may be helpful to others in future.
I have been struggling with the same issue. When analysing the source code (https://svn.r-project.org/R-packages/trunk/nlme/R/nlme.R)
I found out that the E matrix needs rownames referring to the random effect of each group in the dataset, something like:
rownames(E) <- c("subjectname1","subjectname2","subjectname3",.....).
Then your code should run perfectly OK.

Example:
----------
library(nlme)

data <- data.frame(a=c(1,2,3,4,5,1,2,3,4,5,1,2,3,4,5),
                   b=c(2,3,4,5,7,3,4,5,7,8,3,5,6,8,9),
                   ID=c(rep('X',5),rep('Y',5),rep('Z',5)))

# Random effect matrix E:
E <- as.matrix(c(-0.1,0.2,0.3))
rownames(E) <- c('X','Y','Z')
fm1 <- nlme(b ~ par1*a + par2*exp(IIV),
            data = data,
            fixed = list(par1 ~ 1, par2 ~ 1),
            random = IIV ~ 1 | ID,
            start = list(fixed = c(1,1), random= E))
summary(fm1)
---------

Kind regards,
Jos Lommerse, Certara


NOTICE: The information contained in this electronic mail message is intended only for the personal and confidential 
use of the designated recipient(s) named above. This message may be an attorney-client communication, may be protected 
by the work product doctrine, and may be subject to a protective order. As such, this message is privileged and 
confidential. If the reader of this message is not the intended recipient or an agent responsible for delivering it to 
the intended recipient, you are hereby notified that you have received this message in error and that any review, 
dissemination, distribution, or copying of this message is strictly prohibited. If you have received this 
communication in error, please notify us immediately by telephone and e-mail and destroy any and all copies of this 
message in your possession (whether hard copies or electronically stored copies). Thank you.

buSp9xeMeKEbrUze

	[[alternative HTML version deleted]]



More information about the R-help mailing list