Skip to content
Prev 11134 / 20628 Next

nlme repeated measures

On 13-11-25 09:32 PM, Elizabeth Webb wrote:
Your main problem is that you also need 'Rd' in the model as a fixed
effect -- the random effects are defined to have mean zero.  (Note that
these data are sufficiently noisy that the block variance = residual
variance/100 (i.e. ratio of 10 in the standard deviations) and that the
other two variance terms are essentially zero ...)

ww.light_grouped<-groupedData(gC~par|block/fence/plot,data=ww.light)

nls0 <- nls(gC~alpha*par*Fmax/(alpha*par+Fmax)+Rd,
            start=c(alpha=-0.0001795,Fmax=-0.0092121,Rd=0),
            data=ww.light)
pframe <- data.frame(par=1:700)
pframe$gC <- predict(nls0,newdata=pframe)

ww.light <- transform(ww.light,
                      bfp=interaction(block,fence,plot))
library(ggplot2)
ggplot(ww.light,aes(x=par,y=gC)) +geom_point(aes(colour=bfp))+
    geom_line(aes(group=bfp,
                  colour=bfp))+
    geom_line(data=pframe,lwd=2,alpha=0.4)

library(mgcv)
ggplot(ww.light,aes(x=par,y=gC)) +geom_point(aes(colour=bfp))+
    geom_smooth(aes(group=interaction(block,fence,plot),
                  colour=interaction(block,fence,plot)),
                se=FALSE,method="gam")+
    geom_line(data=pframe,lwd=2,alpha=0.4)

ggplot(ww.light,aes(x=par,y=gC)) +geom_point(aes(colour=bfp))+
    geom_smooth(aes(group=bfp,
                  colour=bfp),se=FALSE)+
    coord_cartesian(ylim=c(-0.03,0.04))

mixedWW<-nlme(model=gC~(alpha*par*Fmax)/(alpha*par+Fmax)+Rd,

fixed=alpha+Fmax+Rd~1,start=c(alpha=-0.0001795,Fmax=-0.0092121,
                                 Rd=0.0139),
              data=ww.light,random=Rd~1|bfp)

mixedWW2<-nlme(model=gC~(alpha*par*Fmax)/(alpha*par+Fmax)+Rd,

fixed=alpha+Fmax+Rd~1,start=c(alpha=-0.0001795,Fmax=-0.0092121,
                                 Rd=0.0139),
              data=ww.light,random=Rd~1|block/fence/plot)