Hi all, I am trying to use nonlinear regression (nls) to analyze some seed germination data, but am having problems with error codes.
The data that I have closely matches the germination dataset included in the drc package. Here is the head of the data temp species start end germinated TotSeeds TotGerminated Prop 1 10 wheat 0 1 0 20 0 0.0 2 10 wheat 1 2 0 20 0 0.0 3 10 wheat 2 3 0 20 0 0.0 4 10 wheat 3 4 0 20 0 0.0 5 10 wheat 4 5 0 20 0 0.0 6 10 wheat 5 6 4 20 4 0.2 temp is the temperature under which the seeds were germinated, species denotes the species (wheat, mungbean, or rice) Start and end denote the beginning and end of a period of time and germinated denotes how many seeds germinated during that period of time. Prop represents the proportion of seeds that have germinated. I have attempted to mimic Fox and Weisberg's appendix to Nonlinear Regression found here. https://socserv.socsci.mcmaster.ca/jfox/Books/Companion/appendix/Appendix-Nonlinear-Regression.pdf My first step is to look at a single species, wheat, and use nls on the individual temperatures. I have tried to use both the nlsList function and to attempt to estimate the parameters using lm(), but I receive error messages on both. Here is the code. library(drc) ### for germination dataset data(germination) wheat = germination[germination$species == "wheat",] ### subset by wheat scatterplot(Prop ~ end|temp,data=wheat,box=FALSE,reg=FALSE) ### view the data wheat$temp = as.factor(wheat$temp) ### convert to factor ### First, try to use nlsList wheat.list <- nlsList(Prop ~ SSlogis(end,phi1,phi2,phi3)| temp,pool=FALSE,data=wheat) ### ### next, try to use lm to estimate starting parameters. wheat.list = list() for (i in 1:length(levels(wheat$temp))){ tmpDat = wheat[wheat$temp == levels(wheat$temp)[i],] tmp.lm <- lm(Prop ~ end,data = tmpDat) tmp.nls <- nls(Prop ~ theta1 / (1 + exp(-(theta2 + theta3*end))), start = list(theta1 = .5,theta2=coef(tmp.lm)[1],theta3 = coef(tmp.lm)[2]), data = tmpDat,trace=TRUE) tmp2.nls <- nls(Prop ~ SSlogis(end,phi1,phi2,phi3),data=tmpDat) wheat.list[i] <- tmp.nls } #### End code nlsList just returns an empty list. When I try to loop through the individual temperatures, for the first temperature, nls converges when I provide starting values, but when I try to use SSlogis(), I get the error messsage Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : NA/NaN/Inf in 'x' For the second temperature (16), I get the following error message when provided initial values using lm: Error in nls(Prop ~ theta1/(1 + exp(-(theta2 + theta3 * end))), start = list(theta1 = 0.5, : singular gradient I have tried to read through posts, but none of them seem to apply to this case. The data seem relatively simply and I am not sure what I am doing wrong. Any help would be appreciated. Wade ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.