[R] What's going on? (strange standard deviation)

Roger Peng rpeng at stat.ucla.edu
Fri Nov 15 23:33:48 CET 2002


I believe R computes:

sum((x - mean(x))^2) / (N-1)

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

On Fri, 15 Nov 2002, Matej Cepl wrote:

> I have probably misunderstood something (again :-():
> 
> 	> CEMPLOY<-TEMPLOY[!is.na(TEMPLOY)]
> 	> sum(CEMPLOY^2/length(CEMPLOY))-mean(CEMPLOY)^2
> 	[1] 30877.28
> 	> var(TEMPLOY,na.rm=TRUE)
> 	[1] 30981.25
> 
> Could anybody tell me, what's going on? I suppose that
> 
> 	var=sum(x^2/N)-xbar^2
> 
> or what did I enter wrong?
> 
> 	Thanks
> 
> 		Matej
> 
> -- 
> Matej Cepl, matej at ceplovi.cz,
> Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
> 138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488
>  
> Courage is resistance of fear, mastery of fear, not absence of
> fear.
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

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