mercredi 1 novembre 2017

Confidence interval loop

I'm trying to write a loop to see what is the smallest n that satisfies a Confidence interval upper bound lower than 7. For some reason, my loop isn't working properly (it returns 1 no matter what), and I'm not sure where I'm going wrong.

sd=1.316561
xmean=6.2
mu=7
ci<-function(n){
    for (n in 11:100){
      if ((xmean+sqrt(n)*(xmean-mu)/sd*sd/sqrt(n))<7){
        break
      } 
    }
    print(n)
}

Aucun commentaire:

Enregistrer un commentaire