Skip to content
Back to formatted view

Raw Message

Message-ID: <3DF5CED3.5925.A7088C@localhost>
Date: 2002-12-10T11:25:08Z
From: PIKAL Petr
Subject: Variance of a single number
In-Reply-To: <024D6AEFCB92CB47BA1085751D184BB80105F1CD@MBXSRV03.stf.nus.edu.sg>

Most probably:


     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.

from help page for var

try
?var


On 10 Dec 2002 at 15:50, Adaikalavan Ramasamy wrote:

> Just out of curiosity, can some please explain the following return
> NA.
> 
> x <- 6
> var(x)
> 
> y <- c( NA, NA, 10000 )
> var(y, na.rm=T)
> 
> 
> Unless I am seriously misguided, I believe that the variance of a
> single number (i.e. a constant) should be zero. Thanks.
> 
> Regards, Adai.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-help

Petr Pikal
petr.pikal at precheza.cz
p.pik at volny.cz