Hi, All: The following identifies apparent inconsistencies and proposed fixes between the documentation and the behavior of 'nls'. Specifically, the help file says 'data' 'Can also be a list'. However, I got an error when I tried it with a list that could not be coerced to a data.frame. This is documented in the first example below. Also, the help file says 'data' is 'optional'. Unfortunately, the second example below bombs, apparently while checking the wrong thing for parameters to estimate. Attached is a version of 'nls' that fixes these problems and otherwise produces the same answers (per 'all.equal') as the current official version on the "Examples" in 'nls' help file. What do you think about adopting these code changes and adding these examples to the 'nls' help file (see the attached 'nls-new examples.R')? I am using this in preparing for a presentation on the 'fda' package at UseR! in Ames (Aug. 8-10). I am temporarily adding the attached version of 'nls' to the 'fda' package with a help file primarily consisting of a pointer to help(nls, package=stats) and the attached examples. However, I'm hoping that someone will find the time to review this and either disabuse me of some of my deficiencies in this area or announce a plan to have something like this incorporated in a future version of R. Thanks, Best Wishes, Spencer Graves p.s. How can I find the official source code for this? I tried "https://svn.r-project.org/R-packages/trunk" and found 'nlme' and other packages but not core R like 'stats'. ##################### ## ## SLIGHT MODIFICATIONS TO CURRENT EXAMPLES ## THAT DON'T WORK (except with my modifications) ## # Weighted Michaelis-Menten model # with data = a list that can not be coerced to a data.frame TreatIrreg <- with(Treated, list(conc1=conc[1], conc.1=conc[-1], rate=rate)) # Passing arguments using a list that can not be coerced to a data.frame weighted.MM1 <- function(resp, conc1, conc.1, Vm, K){ conc <- c(conc1, conc.1) resp <- TI$rate # pred <- (Vm * conc)/(K + conc) (resp - pred) / sqrt(pred) } Pur.wt1 <- nls( ~ weighted.MM1(rate, conc1, conc.1, Vm, K), data=TreatIrreg, start = list(Vm = 200, K = 0.1), trace = TRUE) ## ## ERROR MESSAGE: ## Error in data.frame(conc1 = 0.02, conc.1 = c(0.02, 0.06, 0.06, 0.11, 0.11, : ## arguments imply differing number of rows: 1, 11, 12 ## # Passing arguments via 'get' weignted.MM0 <- function(Vm, K){ TI <- get("TreatIrreg") conc <- with(TI, c(conc1, conc.1)) resp <- TI$rate # pred <- (Vm * conc)/(K + conc) (resp - pred) / sqrt(pred) } Pur.wt0 <- nls( ~ weighted.MM0(Vm, K), start = list(Vm = 200, K = 0.1), trace = TRUE) ## ## ERROR MESSAGE: ## Error in nls(~weighted.MM0(Vm, K), start = list(Vm = 200, K = 0.1), trace = TRUE) : ## no parameters to fit ## ############################ -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: nls.R Url: https://stat.ethz.ch/pipermail/r-devel/attachments/20070604/45e4d0d8/attachment.pl -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: nls-new examples.R Url: https://stat.ethz.ch/pipermail/r-devel/attachments/20070604/45e4d0d8/attachment-0001.pl