Hi.
I am performing a MonteCarlo Test for a set of more than 1 million values. Is time consuming to make it run for every single value so I decided to go for a sample size of 10000, 20000, 30000 etc. But, I am having problems re arreging the SaSi.
y<-c()
p<-c()
ET=(TestA$ET)
flux<-c(ET)
SaSi<- c(flux)
for(j in 1:SaSi)
{
run<-100 # run 1000 times (the more often you run, the smoother the output curve becomes, but the longer it takes)
for (i in 1:run) #loop
{
a<-sample(as.numeric(flux), j, replace=TRUE, prob=NULL) #draw random sample from flux, sample size j
b<-mean(a) #mean value of sample
y[i]<-b # write mean value into empty vector
}
cv<-sd(y)/mean(y)*100 #calculate Coefficiant of variance for respective sample size
p[j]<-cv
}
SS<-c(1:SaSi)
CV<-p
plot(SS, CV, type="l", ylab="CV (%)", xlab= "sample size")
I did it manually like SaSi<-c(100000, 200000, ...), but it does not work. I got this error> Warning message:
In 1:SaSi : numerical expression has 2 elements: only the first used
Any suggestion is very welcome.