[R-SIG-Finance] histogram, sd and mean questions

donahchoo at me.com donahchoo at me.com
Wed Dec 30 03:26:37 CET 2009


Thanks, Brian.  I didn't include the data as I have over 500 data  
points and didn't think it would be much use.

I'll redirect my other questions to r-help.


On Dec 29, 2009, at 8:22 PM, Brian G. Peterson wrote:

> donahchoo at me.com wrote:
>> Hi,
>> I'm trying to plot the histogram, sd and mean of some range data I  
>> have collected and I have several questions.  First off, my  
>> statistics is ancient at best, so if I get things wrong forgive me.
>> What I'm trying to do is determine the range of the YM for 30  
>> minute periods throughout the day.  I've got the code the  
>> determining range working, but my standard deviation plots appear  
>> to be off.
>> In the graph below the orange dotted line is the mean and the  
>> dotted red lines are +/- 1sd.  What I want to determine what ranges  
>> are within 1 sd of the mean and this graph looks off to me.
>> Can anyone confirm that I have (not) done this correctly?  Is there  
>> a way I can get a finer scale on the x axis? So far I haven't found  
>> a way to set tick marks on the charts...
>> Here's my R code:
>> > hist(range_tmp, breaks=250, xlim=c(0,250))
>> > abline(v=mean(range_tmp), col='orange', lty=2, lwd=2.5)
>> > abline(v=mean(range_tmp) + sd(range_tmp), col='red', lty=2,  
>> lwd=2.5)
>> > abline(v=mean(range_tmp) - sd(range_tmp), col='red', lty=2,  
>> lwd=2.5)
>
> I know better than to guess at whether a statistical calculation is  
> correct by looking at the graph, and you didn't include your data.
>
> Your code looks fine, without having access to the data to check it.
>
> In the future, please send Stats 101 and R 101 questions to the  
> general r-help list, as this has nothing at all to do with finance.
>
> Regards,
>
>    - Brian
>
> -- 
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock



More information about the R-SIG-Finance mailing list