[R] bargraph.ci - CI and color question.

David Winsemius dwinsemius at comcast.net
Tue Nov 3 15:03:56 CET 2009


On Nov 3, 2009, at 4:51 AM, Michael Just wrote:

> Hello,
> When using bargraph.CI in package sciplot can the bars for each group
> be different colors?

Yes.

?bargraph.CI

> How do I select the color for each group?


Read the help page. Fifth argument down.
>
> When I use this instead of the default (SD vs SE):
>
> bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,
>
>               ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )
>
>
> Am I getting 95% CI bars?

<Something> +/- one SD(<something> will almost never be a 95% CI. But  
this raises the question:  CI bars for what parameter or statistic?   
(And raises the question: Have you read the help page entry regarding  
that parameter?)

I do think it's good that you are considering plotting standard  
deviations rather than std errors of the mean, because the more common  
practice of plotting sem's obscures the degree of variability in the  
population. It's just that you appear to be aiming for what might be  
called a prediction interval and for it to be a 95% one, would need to  
be +/- 2 SD's. And if the numbers in each group are small, the "2"  
would get replaced with a t-statistic.

If on the other hand you want to know what would be the right label  
for mean +/- sd, then given that +/- 1.96 SD would be a 95% prediction  
interval (for large samples) then you can see from

 > 1-2*pnorm(-1.96)
[1] 0.9500042
 > 1-2*pnorm(-1)
[1] 0.6826895

... that +/- one SD would be a 68% prediction interval.

>
> Thank you kindly,
> Michael Just
--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list