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

Deepayan Sarkar deepayan at stat.wisc.edu
Fri Nov 15 23:35:18 CET 2002


On Friday 15 November 2002 03:18 pm, 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?


Is length(CEMPLOY) approximately 300 ?

?var says:

Details:

     [...]

     The denominator n - 1 is used which gives an unbiased estimator of
     the (co)variance for i.i.d. observations. These functions return
     `NA' when there is only one observation (whereas S-plus has been
     returning `NaN'), and from R 1.2.3 fail if `x' has length zero.


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