Re: [R] Variance for Vector of Constants is Not Zero

From: Spencer Graves <spencer.graves_at_pdf.com>
Date: Fri 17 Feb 2006 - 07:30:04 EST

          Could you please provide "sessionInfo()"; I can't replicate the problem:

 > var(x)
[1] 0
 > sessionInfo()
R version 2.2.1, 2005-12-20, i386-pc-mingw32

attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils" "datasets" [7] "base"

          spencer graves

Barry Zajdlik wrote:

> Hi All,
>
> An annoying but not critical problem I am having is that the variance of
> a vector of constants is reported as > 0. I imagine there is a simple
> workaround for the following but could not find it after having spent an
> embarrassing amount of time.
>
> In Splus:
>
>

>>x<-rep(0.02,10)
>>var(x)
>>0

>
>
> In R:
>
> x<-rep(0.02,10)
> var(x)
> 1.337451e-35
>
> I assumed the problem had to do with machine precision and suitably
> modified .Machine$double.eps and .Machine$double.neg.eps which I thought
> would fix the problem but without success. Any pointers to a solution
> would be appreciated!

>
> Cheers,
> Barry Zajdlik
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Feb 17 08:22:08 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:31 EST