The latest code I have put together is this. Could you point out what is 
missing here ? 

#Reference values plotted on x-axis. These are constant.
 #These values could be time of day. So every day at the same
 #time we could collect other measurements
 referenceset <- data.frame(c(5,10,15,20,25,30,35,40,50,60))
 colnames( referenceset) <- c("reference")

 #These are the sets of measurements. So every day at the same
 #time we could collect several samples. This is simulated now.
 sampleset <- data.frame( matrix(sample(1:2, c(20000), replace = TRUE), 
ncol = 2000) )
 
 sampleset <- cbind( sampleset, referenceset )
 
 #Calculate mean
 sampleset$mean <- apply(sampleset[,1:10],2,mean)
 
 #Calculate Standard Deviation
 sampleset$sd <- apply(sampleset[,c(1:10)],2,sd)
 
 #Calculate Standard Error
 sampleset$se <- sampleset$sd / sqrt(2000)
 
 #print(sampleset)
 
 plot( sampleset$reference,
       sampleset$mean,
           las=1,
           ylab="Mean of 'y' values",
           xlab="x",
      );
 
arrows(sampleset$reference,
       sampleset$mean-sampleset$se,
           sampleset$reference,
           sampleset$mean+sampleset$se,
           code = 3,
           angle=90,
           length=0.2)






Thanks.



From:   Rolf Turner <r.tur...@auckland.ac.nz>
To:     Jim Lemon <j...@bitwrit.com.au>
Cc:     mohan.radhakrish...@polarisft.com, r-help@r-project.org
Date:   12/06/2013 02:53 PM
Subject:        Re: [R] Simple Error Bar




Uh, no.  You are forgetting to take the square root of 10, and to divide 
by the square root of 12.

The variance of Y is (exactly) (56^2 - 1)/12, so the variance of Y-bar 
is this quantity over 10,
so the standard deviation of Y-bar is sqrt((56^2 - 1)/12)/sqrt(10). 
Which is approximately
(ignoring the -1) 56/sqrt(12) * 1/sqrt(10).

     cheers,

     Rolf

On 12/06/13 20:26, Jim Lemon wrote:
> On 12/06/2013 04:16 PM, mohan.radhakrish...@polarisft.com wrote:
>> Hi,
>>                Basic question with basic code.   I am simulating a 
>> set of
>> 'y' values for a standard 'x' value measurement. So here the error bars
>> are very long because the
>> number of samples are very small. Is that correct ? I am plotting the 
>> mean
>> of 'y' on the 'y' axis.
>>
>>
>> Thanks,
>> Mohan
>>
>> x<- data.frame(c(5,10,15,20,25,30,35,40,50,60))
>>   colnames(x)<- c("x")
>>
>>   y<- sample(5:60,10,replace=T)
>>   y1<- sample(5:60,10,replace=T)
>>   y2<- sample(5:60,10,replace=T)
>>   y3<- sample(5:60,10,replace=T)
>>   y4<- sample(5:60,10,replace=T)
>>
>>   z<- data.frame(cbind(x,y,y1,y2,y3,y4))
>>   z$mean<- apply(z[,c(2,3,4,5,6)],2,mean)
>>   z$sd<- apply(z[,c(2,3,4,5,6)],2,sd)
>>   z$se<- z$sd / sqrt(5)
>>
>>
> Hi Mohan,
> As your samples seem to follow a discrete uniform distribution, the 
> standard deviation is approximately the number of integers in the 
> range (56) divided by the number of observations (10).




This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only.  If by an addressing or transmission error 
this mail has been misdirected to you, you are requested to delete this mail 
immediately. You are also hereby notified that any use, any form of 
reproduction, dissemination, copying, disclosure, modification, distribution 
and/or publication of this e-mail message, contents or its attachment other 
than by its intended recipient/s is strictly prohibited.

Visit us at http://www.polarisFT.com

        [[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