[Rd] Extractor function for standard deviation.
Rolf Turner
r.turner at auckland.ac.nz
Fri Apr 4 01:24:08 CEST 2008
I have from time to time seen inquiries on r-help in respect of
how to obtain the estimated standard deviation from the output of
fitting a linear model. And have had occasion to want to do this
myself.
The way I currently do it is something like summary(fit)$sigma
(where fit is returned by lm()).
It strikes me that it might be a good idea to have an extractor
function, analogous with coef() and resid(), to dig out this value.
This would be in keeping with the R philosophy of ``don't muck
about with the internal components of objects returned by functions,
because the internal structure of such objects might change in future
releases''.
I'm not sure what the name of the extractor function should be.
One idea would be to make sd() generic, and create a function
sd.lm() which could currently have code
sd.lm <- function(x,...) {
summary(x)$sigma
}
The sd.default() function would have the code of the current sd().
Does this idea have any merit?
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
More information about the R-devel
mailing list