From rpeng at jhsph.edu  Fri Apr  4 14:32:33 2008
From: rpeng at jhsph.edu (Roger D. Peng)
Date: Fri, 04 Apr 2008 08:32:33 -0400
Subject: [Rd] Extractor function for standard deviation.
In-Reply-To: <A9088058-CF1A-4FF0-B44D-4F701F708F6E@auckland.ac.nz>
References: <A9088058-CF1A-4FF0-B44D-4F701F708F6E@auckland.ac.nz>
Message-ID: <47F61FE1.4050504@jhsph.edu>

I'm not sure the idea of having a generic 'sd' extract the residual standard 
deviation from a linear model quite jives with me.  Personally, I think a 
generic function with name like 'residSD' or something similar would be better.

Either way, I think it would be nice to have some function like this.

-roger

Rolf Turner wrote:
> 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}}
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/



[Rd] Extractor function for standard deviation.
Roger D. Peng