From r.turner at auckland.ac.nz  Fri Apr  4 01:24:08 2008
From: r.turner at auckland.ac.nz (Rolf Turner)
Date: Fri, 4 Apr 2008 12:24:08 +1300
Subject: [Rd] Extractor function for standard deviation.
Message-ID: <A9088058-CF1A-4FF0-B44D-4F701F708F6E@auckland.ac.nz>


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}}



[Rd] Extractor function for standard deviation.
Rolf Turner