[R] Using corStruct in nlme

grieve at u.washington.edu grieve at u.washington.edu
Tue Jul 18 20:28:41 CEST 2006


I am having trouble fitting correlation structures within nlme. I would like to 
fit corCAR1, corGaus and corExp correlation structures to my data.  I either 
get the error "step halving reduced below minimum in pnls step" or 
alternatively R crashes.

My dataset is similar to the CO2 example in the nlme package. The one major 
difference is that in my case the 'conc' steps are not the same for each 'Plant'. I have replicated the problem using the CO2 data in nlme (based off of the Ch08.R script).

This works (when 'conc' is the same for each 'Plant':

(fm1CO2.lis <- nlsList(SSasympOff, CO2))
(fm1CO2.nlme <- nlme(fm1CO2.lis, control = list(tolerance = 1e-2)))
(fm2CO2.nlme <- update(fm1CO2.nlme, random = Asym + lrc ~ 1))
CO2.nlme.var <- update(fm2CO2.nlme,
 fixed = list(Asym ~ Type * Treatment, lrc + c0 ~ 1),
 start = c(32.412, 0, 0, 0, -4.5603, 49.344), 
 weights=varConstPower(fixed=list(const=0.1, power=1)), verbose=T)

CO2.nlme.CAR<-update(CO2.nlme.var, corr=corCAR1())

CO2.nlme.gauss<-update(CO2.nlme.var, 
correlation=corGaus(form=~as.numeric(conc)|Plant,nugget=F), data=CO2)

CO2.nlme.exp<-update(CO2.nlme.var, 
correlation=corExp(form=~as.numeric(conc)|Plant,nugget=F), data=CO2)  

But, if i change each of the 'conc' numbers slightly so that they are no longer identical between subjects i can only get the corCAR1 correlation to work while R crashes for both corExp and corGaus:

for(i in 1:length(CO2$conc)){
    CO2$conc[i]<-(CO2$conc[i]+rnorm(1))
}

(fm1CO2.lis <- nlsList(SSasympOff, CO2))
(fm1CO2.nlme <- nlme(fm1CO2.lis, control = list(tolerance = 1e-2)))
(fm2CO2.nlme <- update(fm1CO2.nlme, random = Asym + lrc ~ 1))
CO2.nlme.var <- update(fm2CO2.nlme,
 fixed = list(Asym ~ Type * Treatment, lrc + c0 ~ 1),
 start = c(32.412, 0, 0, 0, -4.5603, 49.344), 
 weights=varConstPower(fixed=list(const=0.1, power=1)), verbose=T)

CO2.nlme.CAR<-update(CO2.nlme.var, corr=corCAR1())

CO2.nlme.gauss<-update(CO2.nlme.var, 
correlation=corGaus(form=~as.numeric(conc)|Plant,nugget=F), data=CO2)

CO2.nlme.exp<-update(CO2.nlme.var, 
correlation=corExp(form=~as.numeric(conc)|Plant,nugget=F), data=CO2) 

I have read Pinheiro & Bates (2000) and i think that it should be possible to fit these correlation structures to my data, but maybe i am mistaken.

I am running R 2.3.1 and have recently updated all packages.

Thanks,
Katie Grieve

Quantitative Ecology & Resource Management
University of Washington



More information about the R-help mailing list