[R] Access to calculations in nls
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Sat Oct 14 22:18:51 CEST 2000
On Sat, 14 Oct 2000, Dermot MacSweeney wrote:
> Hi,
>
> I would like to be able to access the calculated results from the nls package.
> Using the example in R, fm3DNase1 we can reurn certain parts of the
> calculations:
>
> > coef(fm3DNase1)
> Asym xmid scal
> 2.345179 1.483089 1.041454
>
> > resid(fm3DNase1)
> [1] -0.0136806237 -0.0126806237 0.0089488569 0.0119488569 -0.0025803222
> [6] 0.0064196778 0.0026723396 -0.0003276604 -0.0187778127 -0.0237778127
> [11] 0.0381369952 0.0201369952 -0.0335131004 -0.0035131004 0.0150122651
> [16] -0.0049877349
> attr(,"label")
> [1] "Residuals"
>
> What I would like to be able to return are the Std. Errors shown with the
> Parameter estimates below. Is there a command such as stderr(fm3DNase1) that
> would return:
>
> [1] 0.07815 0.08135 0.03227
No, but summary itself returns them. By convention summary methods
create a new object of class print.summary.foo which is then auto-printed.
So you wanted
> summary(fm3DNase1)$parameters[, 2]
Asym xmid scal
0.078154 0.081353 0.032271
(with names, or as.vector(...) if not).
As an aside, package MASS has a generic function vcov to pull out
variance-covariance estimates of coefficient estimates, so you can do
> vcov(fm3DNase1)
Asym xmid scal
Asym 0.006108 0.0062740 0.0022720
xmid 0.006274 0.0066183 0.0023794
scal 0.002272 0.0023794 0.0010414
too. As it's generic, it works for most fitted model objects.
>
> > summary(fm3DNase1)
>
> Formula: density ~ Asym/(1 + exp((xmid - log(conc))/scal))
>
> Parameters:
> Estimate Std. Error t value Pr(>|t|)
> Asym 2.34518 0.07815 30.01 2.16e-13 ***
> xmid 1.48309 0.08135 18.23 1.22e-10 ***
> scal 1.04145 0.03227 32.27 8.50e-14 ***
> ---
> Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
>
> Residual standard error: 0.01919 on 13 degrees of freedom
>
> Correlation of Parameter Estimates:
> Asym xmid
> xmid 0.9868
> scal 0.9008 0.9063
>
> Thanks in Advance,
>
> Dermot MacSweeney.
>
> **************************************************************
>
> Dermot MacSweeney NMRC,
> Email: dsweeney at nmrc.ucc.ie Lee Maltings,
> Tel: +353 21 904178 Prospect Row,
> Fax: +353 21 270271 Cork,
> WWW: http://nmrc.ucc.ie Ireland
>
> **************************************************************
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
Brian D. Ripley, ripley at 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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list