berwin@maths.uwa.edu.au
2004-May-21 08:41 UTC
[Rd] Buglet/omission in nls package (PR#6901)
Dear all, I noticed the following under R 1.8.1 (when nls was still a separate package) but the same problem occurs under R 1.9.0 (where most (all?) of nls is now in the stats package):> data(Puromycin) > fm <- nls(rate~SSmicmen(conc,b0,b1), Puromycin, subset = state=="treated") > coef(summary(fm))NULL The problem seems to be that summary.nls uses the name "parameters" instead of the name "coefficients" for the matrix with the estimates, standard errors, t values and p values:> summary(fm)$parametersEstimate Std. Error t value Pr(>|t|) b0 212.68370728 6.947153198 30.614512 3.241160e-11 b1 0.06412123 0.008280944 7.743227 1.565136e-05 Thus, coef.default fails on an object of class "summary.nls". Possible fixes: 1) Rename that part of the summary.nls structure from parameters to coefficients (not sure if that breaks something else); or 2) Write a coef.summary.nls method that returns the structure parameter from a summary.nls object passed to it. Cheers, Berwin --please do not edit the information below-- Version: platform = i686-pc-linux-gnu arch = i686 os = linux-gnu system = i686, linux-gnu status = major = 1 minor = 9.0 year = 2004 month = 04 day = 12 language = R Search Path: .GlobalEnv, package:methods, package:stats, package:graphics, package:utils, Autoloads, package:base
Berwin, No one has said the coef() will work on a summary object, but it would be nice if it did where appropriate. I've added an summary.nls method for 2.0.0. Brian On Fri, 21 May 2004 berwin@maths.uwa.edu.au wrote:> Dear all, > > I noticed the following under R 1.8.1 (when nls was still a separate > package) but the same problem occurs under R 1.9.0 (where most (all?) > of nls is now in the stats package):`all of nls', indeed.> > data(Puromycin) > > fm <- nls(rate~SSmicmen(conc,b0,b1), Puromycin, subset = state=="treated") > > coef(summary(fm)) > NULL > > The problem seems to be that summary.nls uses the name "parameters" > instead of the name "coefficients" for the matrix with the estimates, > standard errors, t values and p values: > > > summary(fm)$parameters > Estimate Std. Error t value Pr(>|t|) > b0 212.68370728 6.947153198 30.614512 3.241160e-11 > b1 0.06412123 0.008280944 7.743227 1.565136e-05 > > Thus, coef.default fails on an object of class "summary.nls". > > Possible fixes: > 1) Rename that part of the summary.nls structure from parameters to > coefficients (not sure if that breaks something else); or > 2) Write a coef.summary.nls method that returns the structure > parameter from a summary.nls object passed to it. > > Cheers, > > Berwin > > --please do not edit the information below-- > > Version: > platform = i686-pc-linux-gnu > arch = i686 > os = linux-gnu > system = i686, linux-gnu > status = > major = 1 > minor = 9.0 > year = 2004 > month = 04 > day = 12 > language = R > > Search Path: > .GlobalEnv, package:methods, package:stats, package:graphics, package:utils, Autoloads, package:base > > ______________________________________________ > R-devel@stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-devel > >-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595