[R] Question about biasing in sd()???

Liaw, Andy andy_liaw at merck.com
Wed Mar 9 14:55:01 CET 2005


Where in the help file of sd() do you see the claim that it produces
unbiased estimate?  Try the following:

sample.sizes <- 3:30
reps <- 5000
set.seed(1)
mean.vars <- sapply(sample.sizes, 
                    function(n) mean(sd(matrix(rnorm(n*reps), nc=reps))^2))
plot(sample.sizes,mean.vars)

I.e., the sample variance, or sd()^2, is unbiased for the true variance.  If
U is an unbiased estimator of a parameter theta, f(U) is _not_ necessarily
unbiased for f(theta).  It would be if f() is linear.

Andy


> From: Roy Werkman
> 
> Hi,
>  
> Can anyone help me with the following. I have been using R for Monte
> Carlo simulations and got some results I couldn't explain. Therefor I
> performed following short test:
>  
> --------------
> mean.sds <- NULL
> sample.sizes <- 3:30
>  
>  for(N in sample.sizes){
>  dum <- NULL
>  for(I in 1:5000){
>   x <- rnorm(N,0,1)
>   dum <- c(dum,sd(x))
>  }
>  mean.sds<- c(mean.sds,mean(dum))
> }
> plot(sample.sizes,mean.sds)
> --------------
>  
> My question is why don't I get 1 as a result from my sd() for small
> sample sizes? According to the help, sd() is unbiased, which anyway
> would not explain the small offset... Is it something in rnorm()?
>  
> Thanx,
> Roy
> 
> 
> -- 
> The information contained in this communication and any\ >...{{dropped}}




More information about the R-help mailing list