[R] Confidence Interval

Ben Bolker bolker at ufl.edu
Sun Jan 18 03:49:03 CET 2009


Rachel Keyes <rkeyes87 <at> hotmail.com> writes:

> 
> 
> I am new to R and Im some trouble with the following question... Generate 100
standard normal N(0,1) samples
> of size 100, X1(k),...,X100(k)  where k=1,...,100 (The k is and indicie in
brackets) Calculate the sample
> mean for each sample. For each sample mean Xbark the 0.95-confidence interval
for the mean mew=0 is given
> by... Ik= ( Xbark plus or minus 1.96/10) Find the number of intervals such
that 0 does not belong to Ik.  How
> many of them do you expect to see? Well so far I have come up with... N<-100;
Nsamp<-100
> A<-matrix(rnorm(N*Nsamp,0,1),ncol=Nsamp) means<-apply(A,2,mean) However I have
no idea what I am
> doing and no idea if that even makes sense. Any help would be greatly
appreciated as I have no experience of
> statistical software whatsoever. Thanks in Advance. Rachel
> 

  This sounds an awful lot like a homework problem.
Can you convince us not by giving us a little more context?

I will say that you seem to have made a pretty good start.
A hint is that if you have a logical condition,
sum(condition) will count the number of cases. For
example, sum(means>0) will count the number of positive
means.  ?abs and ?">" may help too.

 By the way, I think that's supposed to be "mu" and not "mew".

  Ben Bolker




More information about the R-help mailing list