In order to bootstrap nonlinear regression, the following code works.
library(nlme)
data(Soybean)
fm1.nls <- nls(weight ~ SSlogis(Time, a, b, c), data=Soybean)
summary(fm1.nls)
bstat <- function(A, indices) {
mboot <- nls(weight ~ SSlogis(Time, a, b, c), data=Soybean[indices, ])
return(coef(mboot))
}
require(boot)
boot1 <- boot(Soybean, bstat, 2000)
boot1
For nonlinear mixed effects models it doesn't work.> stat.nlme <- function(A, indices) {
+ boot.nlme <- nlme(Gdiff/0.5 ~ SSlogis(tmmean,a,b,c),
+ fixed=list(a+b+c~1),
+ random = list(a+b+c~1), data = Soybean[indices,])
+ return(fixef(boot.nlme))
+ }>
> require(boot)
> bb <- boot(Soybean, stat.nlme, 2000)
Error in parse(text = paste("~", paste(nVal, collapse =
"/"))) :
unexpected end of input in "~ "
Could someone help me with fixing the code, thanks in advance for the help.
JN
[[alternative HTML version deleted]]