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