[R] Simulation of data
Marcioestat
marcioestat at POP.COM.BR
Tue Oct 21 05:12:59 CEST 2008
Hi listers,
I am working on a program of statistical analysis of simulated data and I've
been searching the error at the program, but I didn't find it!
It is something about the WHILE procedure, the error says: Error in while
(ecart >= d) { : missing value where TRUE/FALSE needed
Thanks in advance!
Márcio
k<-100
d<-0.00112
z<-rnorm(100, 0, 1)
prop<-rep(0,100)
for (i in 1:100){
if (z[i]>1.75){
prop[i]<-1}
else{prop[i]<-0}}
proportion<-mean(prop)
ecart<-sqrt((proportion*(1-proportion))/k)
while(ecart>=d){
prop_<-0
w<- rnorm(1, 0, 1)
z<-c(z,w)
{if (w>1.75){
prop_<-1}
else{
prop_<-0}
}
prop<-c(prop, prop_)
proportion<-proportion+(prop[k+1]-proportion/(k+1))
ecart<-sqrt((proportion*(1-proportion))/(k+1))
k<-k+1
}
--
View this message in context: http://www.nabble.com/Simulation-of-data-tp20082754p20082754.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list