I was surprised to find that the variance of a scalar, using var(), is NA. Surely this should be zero? Cheers, Jonathan. --please do not edit the information below-- Version: platform = sparc-sun-solaris2.7 arch = sparc os = solaris2.7 system = sparc, solaris2.7 status = Patched major = 0 minor = 99.0 year = 2000 month = February day = 9 language = R Search Path: .GlobalEnv, package:HistoryMatch, package:zmatrix, package:stepfun, package:Simulator, Autoloads, package:base -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> From: J.C.Rougier@durham.ac.uk > Date: Fri, 19 May 2000 10:42:04 +0200 (MET DST) > > I was surprised to find that the variance of a scalar, using > var(), is NA. Surely this should be zero? >Do you mean a vector of length 1? (S has no scalars.) No, it should be NA, as sum((x-xbar)^2)/(n-1) is NaN, or, in statistical terms, one has no idea at all of the variability from a single sample. S gives NA too. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 19 May 2000, Prof Brian Ripley wrote:> > I was surprised to find that the variance of a scalar, using > > var(), is NA. Surely this should be zero? > > > > Do you mean a vector of length 1? (S has no scalars.) No, it should be > NA, as sum((x-xbar)^2)/(n-1) is NaN, or, in statistical terms, one has > no idea at all of the variability from a single sample.I thought that might be the reason. There is no mention of using n-1 rather than n in the denominator on the help page. Perhaps that might be added? Jonathan Rougier Science Laboratories Department of Mathematical Sciences South Road University of Durham Durham DH1 3LE http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
J.C.Rougier@durham.ac.uk wrote:> > I was surprised to find that the variance of a scalar, using > var(), is NA. Surely this should be zero?1. This is ok. var(.) is defined as: var(x)= (1 / (n - 1)) * sum(x - mean(x))^2 ^^^^^ If you has got a scalar: n - 1 = 0, so it is undefined!> > Version: > platform = sparc-sun-solaris2.7 > arch = sparc > os = solaris2.7 > system = sparc, solaris2.7 > status = Patched > major = 0 > minor = 99.0You should upgrade to 1.0.1 Regards, Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Date: Fri, 19 May 2000 09:57:10 +0100 (BST) > From: Jonathan Rougier <J.C.Rougier@durham.ac.uk> > To: Prof Brian Ripley <ripley@stats.ox.ac.uk> > cc: r-devel@stat.math.ethz.ch, R-bugs@biostat.ku.dk > Subject: Re: [Rd] variance of a scalar (PR#546) > > On Fri, 19 May 2000, Prof Brian Ripley wrote: > > > > I was surprised to find that the variance of a scalar, using > > > var(), is NA. Surely this should be zero? > > > > > > > Do you mean a vector of length 1? (S has no scalars.) No, it should be > > NA, as sum((x-xbar)^2)/(n-1) is NaN, or, in statistical terms, one has > > no idea at all of the variability from a single sample. > > I thought that might be the reason. There is no mention of using n-1 > rather than n in the denominator on the help page. Perhaps that might be > added?Um. What professional statistics package uses n, then? Are you suggesting that there is serious room for doubt? -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
J.C.Rougier@durham.ac.uk writes:> I was surprised to find that the variance of a scalar, using > var(), is NA. Surely this should be zero?I don't think so. There's a divide by zero involved. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 19 May 2000, Prof Brian Ripley wrote:> > I thought that might be the reason. There is no mention of using n-1 > > rather than n in the denominator on the help page. Perhaps that might be > > added? > > Um. What professional statistics package uses n, then? Are you > suggesting that there is serious room for doubt?Well, I may not be the gold standard for statisticians but I just called var(x) when x was the population, not a sample. Unfortunately I did this without thinking as it corresponds closely to my notes. So although a statistics package might use n-1 without question, I think a statistical computing environment could be a little more flexible, at least in its documentation. Jonathan Rougier Science Laboratories Department of Mathematical Sciences South Road University of Durham Durham DH1 3LE http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
At 10:04 AM 5/19/00 +0100, Prof Brian Ripley wrote:> >> On Fri, 19 May 2000, Prof Brian Ripley wrote: >> >> >> I thought that might be the reason. There is no mention of using n-1 >> rather than n in the denominator on the help page. Perhaps that might be >> added? > >Um. What professional statistics package uses n, then? Are you >suggesting that there is serious room for doubt? >S-PLUS, actually. Not in this context, of course, but princomp() when given a data matrix uses n as the divisor for the variance matrix. Amazing stuff. This in turn is translated into the eigenvalues (principal variances) of course. I was really puzzled about this while I was trying to explain to one of my colleagues what a simple generic calculation principal components really was and I was getting the same coefficients as princomp but slightly different variances. In a flash of inspiration I tried multiplying them by n/(n-1) and hey presto! Of course the case for an n-1 divisor is much less convincing in this context because even though it gives an unbiased (REML, maximum marginal likelihood, ...) estimator of the variance, the eigenvalues are certainly not unbiased estimators of the eigenvalues of the population variance matrix (but it can't hurt, either!). Bill. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._