Dear R-Helpers,

I am trying to bootstrap the coefficient of variation on a suite of  
vectors, here I provide an example using one of the vectors in my  
study. When I ran this script with the vector x <-c(0.625,  
0.071428571, 0.133333333, 0.125, 0), it returned CV(boot) [the second  
one], and stderr(boot) [the second one] without problem. However, when  
I ran it with the vector in the following example, I received NA for  
the latter two statistics. I cannot figure out what is missing, why it  
won't work with this vector, and how I can rectify this situation.  
Your input would be greatly appreciated!

x <-c(1, 0, 0.153846154, 0, 0.142857143)
mean (x)
sample(x,replace=T)
mean(sample(x,replace=T))
boot <-numeric(991)
for (i in 1:991) boot[i] <- mean(sample(x,replace=T))
mean(boot)
var(boot)
sd(boot)
stderr <- function(boot) sqrt(var(boot)/length(boot))
stderr(boot)
median(boot)
min(boot)
max(boot)
range(boot)
IQR(boot)
quantile(boot,0.975)
quantile(boot,0.025)
bias <- mean(boot) - mean(x)
mean(x) - bias
mean(x) - bias - 1.96*sqrt(var(boot))
mean(x) - bias + 1.96*sqrt(var(boot))
CV <- function(x) sqrt(var(x))/mean(x)
CV(x)
CV(boot)
N <- boot
CV(x)
CV(sample(x,replace=T))
boot <-numeric(991)
for (i in 1:991) boot[i] <- CV(sample(x,replace=T))
CV(boot)
stderr(boot)
P <- boot
hist(N)
t.test (x, N)
ks.test(x, N)

Many thanks,
D.

p.s. I am very new to R.



        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to