Re: [R] ggplot stat_summary (mean_cl_boot)
For all those that are interested. To adjust the number of reps in the stat_summary() "mean_cl_boot" function simply specify "B" to the number of bootstrap resamples. I set B to 2000 resamplings below. stat_summary(fun.data="mean_cl_boot", geom="errorbar",width=0.1,colour = "red", B=2000 ) If you run "mean_cl_boot" within stat_summary() and ggplot setting "reps=T" does not appear to return a vector of the resampled means as an attribute that I could locate anywhere. However, you can run "smean.cl.boot" code outside of ggplot. x<-smean.cl.boot(OsmData$Mean, B=2000, reps=T) attr(x,"reps") Thus, outside of ggplot you can use reps=T to check the resampling is proceeding as you expect, before adding it to the ggplot code. I did some checks setting B=1 and B=5 as well as large numbers both inside and outside of the ggplot code to assure myself that my adjustments to B within stat_summary() within ggplot were actually doing what I thought. Finally, despite the fact that the Hmisc function is called "smean.cl.boot", as David points out, within ggplot and stat_summary you must use "mean_cl_boot" without the "s" before "mean". Within ggplot "mean_cl_boot" is the correct notation and it does work. I really like ggplot, but can agree that it isn't always clear how to get from point A to point B. My hope in writing this out is that someone else might start their own exploration of these issues a little further down the road than I found myself when I started looking into this. Thanks, Nate On Wed, Nov 9, 2011 at 1:46 PM, David Winsemius wrote: > > On Nov 9, 2011, at 4:35 PM, Nathan Miller wrote: > > Sorry, I didn't realize I was being so obscure. >> >> Within ggplot it is possible to use stat_summary() to generate confidence >> intervals about a mean. One method for generating these CI assumes >> normality. The other uses bootstrapping to generate the CI. I am using the >> second method which requires code like this >> >> stat_summary(fun.data="mean_**cl_boot", geom="errorbar",width=0.1,**colour >> = "red") >> >> I've added some extra flourishes to make them look like errorbars, alter >> the width and specify color. >> >> I would like some details regarding how this bootstrapped CI is >> calculated. If I type "?mean_cl_boot" at the R command line I get a minimal >> help file for "wrap_hmisc {ggplot2}" which is described "wrap up a >> selection of Hmisc to make it easy to use with stat_summary" >> >> I did not mean to suggest that ggplot2 calls Hmisc when I run >> stat_summary(), >> > > Actually it does. > > > but simply that it appears that stat_summary() seems to have been based >> upon a selection of Hmisc, hence I went looking in Hmisc to try to find >> details regarding stat_summary(). I was unsuccessful in this attempt. >> >> I don't believe a great deal of debugging is necessary. I am simply >> looking for details regarding how "mean_cl_boot" works. >> > > It doesn't. That is not the right name. > > > If you don't have information regarding how it works (such as the default >> number of resamplings) there is no need to respond. >> > > Hadley's help files in ggplot2 are terse (or the links to outside > resources crash my R sessions) to the point of being too frustrating for > me to consider using that package, so I don't know if optional parameters > can be passed to the Hmisc functions. If they are, then you should set > reps=TRUE and then see what happens to the number of reps from the returned > object ... if the wrap_hmisc function does happen to catch it. > > > x <- rnorm(100) > > smean.cl.boot(x) > Mean Lower Upper > -0.0211511 -0.2013623 0.1469728 > > > smean.cl.boot(x, reps=TRUE) > Mean Lower Upper > -0.03465361 -0.21233213 0.15178655 > attr(,"reps") > [1] 0.0283330508 -0.1250784237 0.0744640779 0.1310826601 -0.1373094536 > [6] 0.0629291714 0.0145916070 -0.0860141221 0.0549134451 0.0732892908 > snipped pages of intervening output. > [991] 0.1029922424 0.0613358597 -0.0645577851 -0.1664905503 > -0.1249615180 > [996] -0.0751783377 -0.0043747455 -0.1155948060 -0.0750075659 > 0.1244430930 > > I don't see where the number of reps is returned, but the B setting > defaults to 1000. > > -- > david. > > >> Thanks for any assistance, >> Nate >> >> >> >> On Wed, Nov 9, 2011 at 1:10 PM, David Winsemius >> wrote: >> >> On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: >> >> Hello, >> >> This is a pretty simple question, but after spending quite a bit of time >> looking at "Hmisc" and using Google, I can't find the answer. >> >> If I use stat_summary(fun.data="mean_**cl_boot") in ggplot to generate >> 95% >> confidence intervals, how many bootstrap iterations are preformed by >> default? Can this be changed? I would at least like to be able to report >> the number of boot strap interations used to generate the CIs. >> >> I haven't been able to find "mean_cl_boot" as a function itself or >> something ressembling it in the Hmisc documentation, but it se
Re: [R] ggplot stat_summary(mean_cl_boot)
On Nov 9, 2011, at 4:30 PM, Ben Bolker wrote: David Winsemius comcast.net> writes: On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: Hello, This is a pretty simple question, but after spending quite a bit of time looking at "Hmisc" and using Google, I can't find the answer. If I use stat_summary(fun.data="mean_cl_boot") in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find "mean_cl_boot" as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute "mean_cl_boot". You seem really, really confused (and you offer very little in the way of context to support debugging efforts). You are referring to ggplot functions. As far as I know there is no connection between the Hmisc and ggplot (or ggplot2) packages. Al things change, I know, but Frank just completed switching over to Lattice a couple of years ago. In defense of the OP, this is a very confusing situation. mean_cl_boot is a ggplot2 function Another ggplot2 function with no help page, although it does bring up a help page with a link to smean.cl.boot that wraps smean.cl.boot from the Hmisc package: it's almost impossible to figure this out from looking at the raw code of mean_cl_boot, although the help page for ?mean_cl_boot does reference smean.cl.boot. Right. And the code for mean_cl_boot threatens to pass any extra parameters. But I'm still scratching my head about how smean.cl.boot get called because it is never mentioned by name and then there is an ignore.dots parameter that apparently renegs on the promise to pass the B argument. ?smean.cl.boot (in Hmisc, so you'll need to have that package loaded) has a B=1000 parameter for bootstrapping. As I almost always do. I don't know if stat_summary(fun.data="mean_cl_boot",B=1) Might need to be: stat_summary(fun.data="mean_cl_boot",B=1, ignore.dots=FALSE) will work or not, but it would be worth a try (try setting B to a small number and see if your CIs get very noisy, or set it to a large number and see if your plot starts taking a lot longer to compute ...) __ 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. David Winsemius, MD West Hartford, CT __ 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.
Re: [R] ggplot stat_summary (mean_cl_boot)
On Nov 9, 2011, at 4:35 PM, Nathan Miller wrote: Sorry, I didn't realize I was being so obscure. Within ggplot it is possible to use stat_summary() to generate confidence intervals about a mean. One method for generating these CI assumes normality. The other uses bootstrapping to generate the CI. I am using the second method which requires code like this stat_summary(fun.data="mean_cl_boot", geom="errorbar",width=0.1,colour = "red") I've added some extra flourishes to make them look like errorbars, alter the width and specify color. I would like some details regarding how this bootstrapped CI is calculated. If I type "?mean_cl_boot" at the R command line I get a minimal help file for "wrap_hmisc {ggplot2}" which is described "wrap up a selection of Hmisc to make it easy to use with stat_summary" I did not mean to suggest that ggplot2 calls Hmisc when I run stat_summary(), Actually it does. but simply that it appears that stat_summary() seems to have been based upon a selection of Hmisc, hence I went looking in Hmisc to try to find details regarding stat_summary(). I was unsuccessful in this attempt. I don't believe a great deal of debugging is necessary. I am simply looking for details regarding how "mean_cl_boot" works. It doesn't. That is not the right name. If you don't have information regarding how it works (such as the default number of resamplings) there is no need to respond. Hadley's help files in ggplot2 are terse (or the links to outside resources crash my R sessions) to the point of being too frustrating for me to consider using that package, so I don't know if optional parameters can be passed to the Hmisc functions. If they are, then you should set reps=TRUE and then see what happens to the number of reps from the returned object ... if the wrap_hmisc function does happen to catch it. > x <- rnorm(100) > smean.cl.boot(x) Mean Lower Upper -0.0211511 -0.2013623 0.1469728 > smean.cl.boot(x, reps=TRUE) Mean Lower Upper -0.03465361 -0.21233213 0.15178655 attr(,"reps") [1] 0.0283330508 -0.1250784237 0.0744640779 0.1310826601 -0.1373094536 [6] 0.0629291714 0.0145916070 -0.0860141221 0.0549134451 0.0732892908 snipped pages of intervening output. [991] 0.1029922424 0.0613358597 -0.0645577851 -0.1664905503 -0.1249615180 [996] -0.0751783377 -0.0043747455 -0.1155948060 -0.0750075659 0.1244430930 I don't see where the number of reps is returned, but the B setting defaults to 1000. -- david. Thanks for any assistance, Nate On Wed, Nov 9, 2011 at 1:10 PM, David Winsemius > wrote: On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: Hello, This is a pretty simple question, but after spending quite a bit of time looking at "Hmisc" and using Google, I can't find the answer. If I use stat_summary(fun.data="mean_cl_boot") in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find "mean_cl_boot" as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute "mean_cl_boot". You seem really, really confused (and you offer very little in the way of context to support debugging efforts). You are referring to ggplot functions. As far as I know there is no connection between the Hmisc and ggplot (or ggplot2) packages. Al things change, I know, but Frank just completed switching over to Lattice a couple of years ago. -- David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT __ 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.
Re: [R] ggplot stat_summary (mean_cl_boot)
Ok, I got it. smean.cl.boot(x, conf.int=.95, B=1000, na.rm=TRUE, reps=FALSE) Looks like its 1000. Cool. Thanks for the help, Nate On Wed, Nov 9, 2011 at 1:35 PM, Nathan Miller wrote: > Sorry, I didn't realize I was being so obscure. > > Within ggplot it is possible to use stat_summary() to generate confidence > intervals about a mean. One method for generating these CI assumes > normality. The other uses bootstrapping to generate the CI. I am using the > second method which requires code like this > > stat_summary(fun.data="mean_cl_boot", geom="errorbar",width=0.1,colour = > "red") > > I've added some extra flourishes to make them look like errorbars, alter > the width and specify color. > > I would like some details regarding how this bootstrapped CI is > calculated. If I type "?mean_cl_boot" at the R command line I get a minimal > help file for "wrap_hmisc {ggplot2}" which is described "wrap up a > selection of Hmisc to make it easy to use with stat_summary" > > I did not mean to suggest that ggplot2 calls Hmisc when I run > stat_summary(), but simply that it appears that stat_summary() seems to > have been based upon a selection of Hmisc, hence I went looking in Hmisc to > try to find details regarding stat_summary(). I was unsuccessful in this > attempt. > > I don't believe a great deal of debugging is necessary. I am simply > looking for details regarding how "mean_cl_boot" works. If you don't have > information regarding how it works (such as the default number of > resamplings) there is no need to respond. > > Thanks for any assistance, > Nate > > > > > On Wed, Nov 9, 2011 at 1:10 PM, David Winsemius wrote: > >> >> On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: >> >> Hello, >>> >>> This is a pretty simple question, but after spending quite a bit of time >>> looking at "Hmisc" and using Google, I can't find the answer. >>> >>> If I use stat_summary(fun.data="mean_**cl_boot") in ggplot to generate >>> 95% >>> confidence intervals, how many bootstrap iterations are preformed by >>> default? Can this be changed? I would at least like to be able to report >>> the number of boot strap interations used to generate the CIs. >>> >>> I haven't been able to find "mean_cl_boot" as a function itself or >>> something ressembling it in the Hmisc documentation, but it seems as >>> though >>> Hmisc is wrapped up in stat_summary() and is called to compute >>> "mean_cl_boot". >>> >> >> You seem really, really confused (and you offer very little in the way of >> context to support debugging efforts). You are referring to ggplot >> functions. As far as I know there is no connection between the Hmisc and >> ggplot (or ggplot2) packages. Al things change, I know, but Frank just >> completed switching over to Lattice a couple of years ago. >> >> >> -- >> David Winsemius, MD >> West Hartford, CT >> >> > [[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.
Re: [R] ggplot stat_summary (mean_cl_boot)
Sorry, I didn't realize I was being so obscure. Within ggplot it is possible to use stat_summary() to generate confidence intervals about a mean. One method for generating these CI assumes normality. The other uses bootstrapping to generate the CI. I am using the second method which requires code like this stat_summary(fun.data="mean_cl_boot", geom="errorbar",width=0.1,colour = "red") I've added some extra flourishes to make them look like errorbars, alter the width and specify color. I would like some details regarding how this bootstrapped CI is calculated. If I type "?mean_cl_boot" at the R command line I get a minimal help file for "wrap_hmisc {ggplot2}" which is described "wrap up a selection of Hmisc to make it easy to use with stat_summary" I did not mean to suggest that ggplot2 calls Hmisc when I run stat_summary(), but simply that it appears that stat_summary() seems to have been based upon a selection of Hmisc, hence I went looking in Hmisc to try to find details regarding stat_summary(). I was unsuccessful in this attempt. I don't believe a great deal of debugging is necessary. I am simply looking for details regarding how "mean_cl_boot" works. If you don't have information regarding how it works (such as the default number of resamplings) there is no need to respond. Thanks for any assistance, Nate On Wed, Nov 9, 2011 at 1:10 PM, David Winsemius wrote: > > On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: > > Hello, >> >> This is a pretty simple question, but after spending quite a bit of time >> looking at "Hmisc" and using Google, I can't find the answer. >> >> If I use stat_summary(fun.data="mean_**cl_boot") in ggplot to generate >> 95% >> confidence intervals, how many bootstrap iterations are preformed by >> default? Can this be changed? I would at least like to be able to report >> the number of boot strap interations used to generate the CIs. >> >> I haven't been able to find "mean_cl_boot" as a function itself or >> something ressembling it in the Hmisc documentation, but it seems as >> though >> Hmisc is wrapped up in stat_summary() and is called to compute >> "mean_cl_boot". >> > > You seem really, really confused (and you offer very little in the way of > context to support debugging efforts). You are referring to ggplot > functions. As far as I know there is no connection between the Hmisc and > ggplot (or ggplot2) packages. Al things change, I know, but Frank just > completed switching over to Lattice a couple of years ago. > > > -- > David Winsemius, MD > West Hartford, CT > > [[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.
Re: [R] ggplot stat_summary (mean_cl_boot)
On Nov 9, 2011, at 4:10 PM, David Winsemius wrote: mean_cl_boot OK. Things do change. Hadley has written a wrapper for some of the Hmisc functions and you appear to be looking for smean.cl.boot() (Note that Hadley's functions use "_"'s and Harrells use "."'s. And this could be found by ??"mean_cl_boot" # at the R console And then reading the help page for the wrap_hmisc function, the only entry that came up on my machine. David Winsemius, MD West Hartford, CT __ 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.
Re: [R] ggplot stat_summary(mean_cl_boot)
David Winsemius comcast.net> writes: > On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: > > > Hello, > > > > This is a pretty simple question, but after spending quite a bit of > > time > > looking at "Hmisc" and using Google, I can't find the answer. > > > > If I use stat_summary(fun.data="mean_cl_boot") in ggplot to generate > > 95% > > confidence intervals, how many bootstrap iterations are preformed by > > default? Can this be changed? I would at least like to be able to > > report > > the number of boot strap interations used to generate the CIs. > > > > I haven't been able to find "mean_cl_boot" as a function itself or > > something ressembling it in the Hmisc documentation, but it seems as > > though > > Hmisc is wrapped up in stat_summary() and is called to compute > > "mean_cl_boot". > > You seem really, really confused (and you offer very little in the way > of context to support debugging efforts). You are referring to ggplot > functions. As far as I know there is no connection between the Hmisc > and ggplot (or ggplot2) packages. Al things change, I know, but Frank > just completed switching over to Lattice a couple of years ago. In defense of the OP, this is a very confusing situation. mean_cl_boot is a ggplot2 function that wraps smean.cl.boot from the Hmisc package: it's almost impossible to figure this out from looking at the raw code of mean_cl_boot, although the help page for ?mean_cl_boot does reference smean.cl.boot. ?smean.cl.boot (in Hmisc, so you'll need to have that package loaded) has a B=1000 parameter for bootstrapping. I don't know if stat_summary(fun.data="mean_cl_boot",B=1) will work or not, but it would be worth a try (try setting B to a small number and see if your CIs get very noisy, or set it to a large number and see if your plot starts taking a lot longer to compute ...) __ 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.
Re: [R] ggplot stat_summary (mean_cl_boot)
On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: Hello, This is a pretty simple question, but after spending quite a bit of time looking at "Hmisc" and using Google, I can't find the answer. If I use stat_summary(fun.data="mean_cl_boot") in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find "mean_cl_boot" as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute "mean_cl_boot". You seem really, really confused (and you offer very little in the way of context to support debugging efforts). You are referring to ggplot functions. As far as I know there is no connection between the Hmisc and ggplot (or ggplot2) packages. Al things change, I know, but Frank just completed switching over to Lattice a couple of years ago. -- David Winsemius, MD West Hartford, CT __ 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.
[R] ggplot stat_summary (mean_cl_boot)
Hello, This is a pretty simple question, but after spending quite a bit of time looking at "Hmisc" and using Google, I can't find the answer. If I use stat_summary(fun.data="mean_cl_boot") in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find "mean_cl_boot" as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute "mean_cl_boot". Many thanks for clearing this up for me, Nate [[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.