bargraph.ci - CI and color question.

6 messages Options
Embed this post
Permalink
Michael Just

bargraph.ci - CI and color question.

Reply Threaded More More options
Print post
Permalink
Hello,
When using bargraph.CI in package sciplot can the bars for each group
be different colors?  How do I select the color for each group?

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?

Thank you kindly,
Michael Just

______________________________________________
[hidden email] 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.
David Winsemius

Re: bargraph.ci - CI and color question.

Reply Threaded More More options
Print post
Permalink

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

______________________________________________
[hidden email] 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.
Manuel Morales

Re: bargraph.ci - CI and color question.

Reply Threaded More More options
Print post
Permalink
In reply to this post by Michael Just
On Tue, 2009-11-03 at 03:51 -0600, Michael Just wrote:
> Hello,
> When using bargraph.CI in package sciplot can the bars for each group
> be different colors?  How do I select the color for each group?

With the option err.col

bargraph.CI(dose, len, group = supp, data =ToothGrowth,
err.col=c("gray","black"))

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

No. You're plotting +/- 1 SD.
>
> Thank you kindly,
> Michael Just
>
> ______________________________________________
> [hidden email] 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.


--
http://mutualism.williams.edu

______________________________________________
[hidden email] 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.
Michael Just

Re: bargraph.ci - CI and color question.

Reply Threaded More More options
Print post
Permalink
Hello,

Thanks for the responses.  Yes, I did try to use ?bargraph.CI for the
colors. When I said bars,  I meant the main bars on the graph not the
error bars. However, this "col=c("color", "color")" is what I was
needed and while it didn't find in the ?bargraph.ci help, I suspect
its a  more fundamental R thing that I was unaware of.  Regardless,
thank you for the example.

bargraph.CI(dose, len, group = supp, data =ToothGrowth,
+ col=c("gray","black"))

Regarding the confidence intervals.  Yes, I am looking for the 95%
confidence interval of the mean.  Using the ci.fun can I get +/- 1.96
SD?

bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,
ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )

I tried variations on this like,

ci.fun= function(x) c(mean(x)-(1.96*sd(x))), mean(x) + (1.96*sd(x))) )

but this didn't work.  Maybe this approach above seems silly, but I
hope I am exhibiting that I do indeed what the 95% CI for the mean,
but that I am unsure how to have the error bars reflect this using the
ci.fun argument.  Can I use this argument or is some pre-processing
necessary?  If this information is located somewhere besides the
?bargraph.ci help I would greatly appreciate an indication of where it
is.

Thank you kindly,
Michael Just

On Tue, Nov 3, 2009 at 8:53 AM, Manuel Morales
<[hidden email]> wrote:

> On Tue, 2009-11-03 at 03:51 -0600, Michael Just wrote:
>> Hello,
>> When using bargraph.CI in package sciplot can the bars for each group
>> be different colors?  How do I select the color for each group?
>
> With the option err.col
>
> bargraph.CI(dose, len, group = supp, data =ToothGrowth,
> err.col=c("gray","black"))
>
>> 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?
>
> No. You're plotting +/- 1 SD.
>>
>> Thank you kindly,
>> Michael Just
>>
>> ______________________________________________
>> [hidden email] 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.
>
>
> --
> http://mutualism.williams.edu
>
>

______________________________________________
[hidden email] 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.
Manuel Morales

Re: bargraph.ci - CI and color question.

Reply Threaded More More options
Print post
Permalink
On Tue, 2009-11-03 at 10:20 -0600, Michael Just wrote:

> Hello,
>
> Thanks for the responses.  Yes, I did try to use ?bargraph.CI for the
> colors. When I said bars,  I meant the main bars on the graph not the
> error bars. However, this "col=c("color", "color")" is what I was
> needed and while it didn't find in the ?bargraph.ci help, I suspect
> its a  more fundamental R thing that I was unaware of.  Regardless,
> thank you for the example.
>
> bargraph.CI(dose, len, group = supp, data =ToothGrowth,
> + col=c("gray","black"))
>
> Regarding the confidence intervals.  Yes, I am looking for the 95%
> confidence interval of the mean.  Using the ci.fun can I get +/- 1.96
> SD?
>
> bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,
> ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )
>
> I tried variations on this like,
>
> ci.fun= function(x) c(mean(x)-(1.96*sd(x))), mean(x) + (1.96*sd(x))) )

You do +/- 1.96*se to get the approximate 95% CI of the mean. +/-
1.96*SD gives the 95% CI of the distribution.

bargraph.CI(x.factor = dose, response = len, data = ToothGrowth, ci.fun=
function(x) c(mean(x)-1.96*se(x), mean(x)+1.96*se(x)) )

>
> but this didn't work.  Maybe this approach above seems silly, but I
> hope I am exhibiting that I do indeed what the 95% CI for the mean,
> but that I am unsure how to have the error bars reflect this using the
> ci.fun argument.  Can I use this argument or is some pre-processing
> necessary?  If this information is located somewhere besides the
> ?bargraph.ci help I would greatly appreciate an indication of where it
> is.
>
> Thank you kindly,
> Michael Just
>
> On Tue, Nov 3, 2009 at 8:53 AM, Manuel Morales
> <[hidden email]> wrote:
> > On Tue, 2009-11-03 at 03:51 -0600, Michael Just wrote:
> >> Hello,
> >> When using bargraph.CI in package sciplot can the bars for each group
> >> be different colors?  How do I select the color for each group?
> >
> > With the option err.col
> >
> > bargraph.CI(dose, len, group = supp, data =ToothGrowth,
> > err.col=c("gray","black"))
> >
> >> 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?
> >
> > No. You're plotting +/- 1 SD.
> >>
> >> Thank you kindly,
> >> Michael Just
> >>
> >> ______________________________________________
> >> [hidden email] 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.
> >
> >
> > --
> > http://mutualism.williams.edu
> >
> >


--
http://mutualism.williams.edu

______________________________________________
[hidden email] 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.
Michael Just

Re: bargraph.ci - CI and color question.

Reply Threaded More More options
Print post
Permalink
Thank you.

On Tue, Nov 3, 2009 at 3:08 PM, Manuel Morales
<[hidden email]> wrote:

> On Tue, 2009-11-03 at 10:20 -0600, Michael Just wrote:
>> Hello,
>>
>> Thanks for the responses.  Yes, I did try to use ?bargraph.CI for the
>> colors. When I said bars,  I meant the main bars on the graph not the
>> error bars. However, this "col=c("color", "color")" is what I was
>> needed and while it didn't find in the ?bargraph.ci help, I suspect
>> its a  more fundamental R thing that I was unaware of.  Regardless,
>> thank you for the example.
>>
>> bargraph.CI(dose, len, group = supp, data =ToothGrowth,
>> + col=c("gray","black"))
>>
>> Regarding the confidence intervals.  Yes, I am looking for the 95%
>> confidence interval of the mean.  Using the ci.fun can I get +/- 1.96
>> SD?
>>
>> bargraph.CI(x.factor = dose, response = len, data = ToothGrowth,
>> ci.fun= function(x) c(mean(x)-sd(x), mean(x) + sd(x)) )
>>
>> I tried variations on this like,
>>
>> ci.fun= function(x) c(mean(x)-(1.96*sd(x))), mean(x) + (1.96*sd(x))) )
>
> You do +/- 1.96*se to get the approximate 95% CI of the mean. +/-
> 1.96*SD gives the 95% CI of the distribution.
>
> bargraph.CI(x.factor = dose, response = len, data = ToothGrowth, ci.fun=
> function(x) c(mean(x)-1.96*se(x), mean(x)+1.96*se(x)) )
>>
>> but this didn't work.  Maybe this approach above seems silly, but I
>> hope I am exhibiting that I do indeed what the 95% CI for the mean,
>> but that I am unsure how to have the error bars reflect this using the
>> ci.fun argument.  Can I use this argument or is some pre-processing
>> necessary?  If this information is located somewhere besides the
>> ?bargraph.ci help I would greatly appreciate an indication of where it
>> is.
>>
>> Thank you kindly,
>> Michael Just
>>
>> On Tue, Nov 3, 2009 at 8:53 AM, Manuel Morales
>> <[hidden email]> wrote:
>> > On Tue, 2009-11-03 at 03:51 -0600, Michael Just wrote:
>> >> Hello,
>> >> When using bargraph.CI in package sciplot can the bars for each group
>> >> be different colors?  How do I select the color for each group?
>> >
>> > With the option err.col
>> >
>> > bargraph.CI(dose, len, group = supp, data =ToothGrowth,
>> > err.col=c("gray","black"))
>> >
>> >> 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?
>> >
>> > No. You're plotting +/- 1 SD.
>> >>
>> >> Thank you kindly,
>> >> Michael Just
>> >>
>> >> ______________________________________________
>> >> [hidden email] 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.
>> >
>> >
>> > --
>> > http://mutualism.williams.edu
>> >
>> >
>
>
> --
> http://mutualism.williams.edu
>
>

______________________________________________
[hidden email] 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.