Grokbase Groups R r-help April 2010
FAQ
Hello,

I need to plot multiple confidence intervals for the same model parameter e.g. so for the same value of the parameter in point x_1 I would like to see four different confidence intervals so that I can compare the accuracy e.g. boot basic vs normal vs my own vs classic lm CI etc.

I like very very much the plotCI implemented here:
http://cran.r-project.org/web/packages/plotrix/index.html

This is their example:
library(plotrix)
y <- runif(10)
err <- runif(10)
plotCI(x=1:10,y=y,uiw=err,liw=2*err,lwd=2,col="red",scol="blue",main="Add colors to the points and error bars")

but does not seem to support plotting multiple CIs but only one per point, is there a similar library somewhere but having the possibility to plot multiple CIs?

I know there is the function "segment" but I like this one above more :)

Thanks in advance,
Best regards,
Giovanni

Search Discussions

  • Ista Zahn at Apr 30, 2010 at 2:35 pm
    Hi Giovanni,
    I think the ggplot2 package might help you out here. Do you want
    something like this?

    library(ggplot2)
    data(mtcars)

    p <- ggplot(mtcars, aes(x=cyl, y=mpg))

    p + stat_summary(fun.data = "mean_cl_boot", colour = "red", geom =
    "errorbar") + stat_summary(fun.data = "mean_cl_normal", colour =
    "blue", geom = "errorbar")

    ?

    See http://had.co.nz/ggplot2/stat_summary.html for details.

    -Ista
    On Fri, Apr 30, 2010 at 3:10 PM, Giovanni Azua wrote:
    Hello,

    I need to plot multiple confidence intervals for the same model parameter e.g. so for the same value of the parameter in point x_1 I would like to see four different confidence intervals so that I can compare the accuracy e.g. boot basic vs normal vs my own vs classic lm CI etc.

    I like very very much the plotCI implemented here:
    http://cran.r-project.org/web/packages/plotrix/index.html

    This is their example:
    library(plotrix)
    y <- runif(10)
    err <- runif(10)
    plotCI(x=1:10,y=y,uiw=err,liw=2*err,lwd=2,col="red",scol="blue",main="Add colors to the points and error bars")

    but does not seem to support plotting multiple CIs but only one per point, is there a similar library somewhere but having the possibility to plot multiple CIs?

    I know there is the function "segment" but I like this one above more :)

    Thanks in advance,
    Best regards,
    Giovanni
    ______________________________________________
    R-help at 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.


    --
    Ista Zahn
    Graduate student
    University of Rochester
    Department of Clinical and Social Psychology
    http://yourpsyche.org
  • Giovanni Azua at Apr 30, 2010 at 3:09 pm
    Hello Zahn,
    On Apr 30, 2010, at 4:35 PM, Ista Zahn wrote:
    Hi Giovanni,
    I think the ggplot2 package might help you out here. Do you want
    something like this?
    Thank you for your suggestion however I could not give it a try since landed in the same issue being reported about the Hmisc package:
    install.packages("Hmisc", dependencies=TRUE)
    Warning message:
    In getDependencies(pkgs, dependencies, available, lib) :
    package ?Hmisc? is not available
    library(ggplot2)
    library(Hmisc)
    Error in library(Hmisc) : there is no package called 'Hmisc'
    data(mtcars)

    p <- ggplot(mtcars, aes(x=cyl, y=mpg))

    p + stat_summary(fun.data = "mean_cl_boot", colour = "red", geom =
    + "errorbar") + stat_summary(fun.data = "mean_cl_normal", colour =
    + "blue", geom = "errorbar")
    Error: Hmisc package required for this functionality. Please install and try again.
    >

    I am running Mac OS X Snow Leopard latest version and also have the latest R UI for Mac.

    How can Hmisc be installed manually?

    Best regards,
    Giovanni
  • Giovanni Azua at Apr 30, 2010 at 4:07 pm
    Hello David,
    On Apr 30, 2010, at 6:00 PM, David Winsemius wrote:
    Looks like you do not have the RTools bundle and perhaps not the XCode framework either?

    I am not suggesting that you do so, since it appears you are not conversant with compiling source code packages. If I am wrong about that point, then this is where you would get the gfortran compiler that Simon uses:

    http://r.research.att.com/tools/

    My advice would be to go back to R.2.10.1 if you need Rcmdr.
    I do have Xcode latest but not RTools.

    This below was my last failed attempt.

    Best regards,
    Giovanni
    install.packages("Hmisc", dependencies=TRUE, type ="source")
    trying URL 'http://cran.ch.r-project.org/src/contrib/Hmisc_3.7-0.tar.gz'
    Content type 'application/x-gzip' length 563054 bytes (549 Kb)
    opened URL
    ==================================================
    downloaded 549 Kb

    * installing *source* package �Hmisc� ...
    ** libs
    ** arch - i386
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I/usr/local/include -fPIC -g -O2 -c Hmisc.c -o Hmisc.o
    gfortran -arch i386 -fPIC -g -O2 -c cidxcn.f -o cidxcn.o
    make: gfortran: No such file or directory
    make: *** [cidxcn.o] Error 1
    ERROR: compilation failed for package �Hmisc�
    * removing �/Library/Frameworks/R.framework/Versions/2.11/Resources/library/Hmisc�

    The downloaded packages are in
    �/private/var/folders/5m/5mC0wYCSGMK8NbPZYhBEZE+++TI/-Tmp-/Rtmpz0R5nY/downloaded_packages�
    Updating HTML index of packages in '.Library'
    Warning message:
    In install.packages("Hmisc", dependencies = TRUE, type = "source") :
    installation of package 'Hmisc' had non-zero exit status
    >
  • Giovanni Azua at Apr 30, 2010 at 4:33 pm
    Hello,

    After installing gfortran from http://r.research.att.com/gfortran-4.2.3.dmg it finally works! see below.

    Thank you all.

    @Ista Zahn: Looks fantastic! :) thank you so much! ... is there a way to have a small circle on the true value?

    Best regards,
    Giovanni
    install.packages("Hmisc", dependencies=TRUE, type ="source")
    trying URL 'http://cran.ch.r-project.org/src/contrib/Hmisc_3.7-0.tar.gz'
    Content type 'application/x-gzip' length 563054 bytes (549 Kb)
    opened URL
    ==================================================
    downloaded 549 Kb

    * installing *source* package ?Hmisc? ...
    ** libs
    ** arch - i386
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I/usr/local/include -fPIC -g -O2 -c Hmisc.c -o Hmisc.o
    gfortran -arch i386 -fPIC -g -O2 -c cidxcn.f -o cidxcn.o
    gfortran -arch i386 -fPIC -g -O2 -c cidxcp.f -o cidxcp.o
    gfortran -arch i386 -fPIC -g -O2 -c hoeffd.f -o hoeffd.o
    gfortran -arch i386 -fPIC -g -O2 -c jacklins.f -o jacklins.o
    gfortran -arch i386 -fPIC -g -O2 -c largrec.f -o largrec.o
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I/usr/local/include -fPIC -g -O2 -c mChoice.c -o mChoice.o
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I/usr/local/include -fPIC -g -O2 -c nstr.c -o nstr.o
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I/usr/local/include -fPIC -g -O2 -c ranksort.c -o ranksort.o
    gfortran -arch i386 -fPIC -g -O2 -c rcorr.f -o rcorr.o
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I/usr/local/include -fPIC -g -O2 -c string_box.c -o string_box.o
    gfortran -arch i386 -fPIC -g -O2 -c wclosest.f -o wclosest.o
    gcc -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o Hmisc.so Hmisc.o cidxcn.o cidxcp.o hoeffd.o jacklins.o largrec.o mChoice.o nstr.o ranksort.o rcorr.o string_box.o wclosest.o -lgfortran -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
    installing to /Library/Frameworks/R.framework/Versions/2.11/Resources/library/Hmisc/libs/i386
    ** arch - x86_64
    gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include -fPIC -g -O2 -c Hmisc.c -o Hmisc.o
    gfortran -arch x86_64 -fPIC -g -O2 -c cidxcn.f -o cidxcn.o
    gfortran -arch x86_64 -fPIC -g -O2 -c cidxcp.f -o cidxcp.o
    gfortran -arch x86_64 -fPIC -g -O2 -c hoeffd.f -o hoeffd.o
    gfortran -arch x86_64 -fPIC -g -O2 -c jacklins.f -o jacklins.o
    gfortran -arch x86_64 -fPIC -g -O2 -c largrec.f -o largrec.o
    gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include -fPIC -g -O2 -c mChoice.c -o mChoice.o
    gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include -fPIC -g -O2 -c nstr.c -o nstr.o
    gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include -fPIC -g -O2 -c ranksort.c -o ranksort.o
    gfortran -arch x86_64 -fPIC -g -O2 -c rcorr.f -o rcorr.o
    gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -I/usr/local/include -fPIC -g -O2 -c string_box.c -o string_box.o
    gfortran -arch x86_64 -fPIC -g -O2 -c wclosest.f -o wclosest.o
    gcc -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o Hmisc.so Hmisc.o cidxcn.o cidxcp.o hoeffd.o jacklins.o largrec.o mChoice.o nstr.o ranksort.o rcorr.o string_box.o wclosest.o -lgfortran -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
    installing to /Library/Frameworks/R.framework/Versions/2.11/Resources/library/Hmisc/libs/x86_64
    ** R
    ** inst
    ** preparing package for lazy loading
    Loading required package: splines
    ** help
    *** installing help indices
    ** building package indices ...
    ** testing if installed package can be loaded

    * DONE (Hmisc)

    The downloaded packages are in
    ?/private/var/folders/5m/5mC0wYCSGMK8NbPZYhBEZE+++TI/-Tmp-/Rtmpz0R5nY/downloaded_packages?
    Updating HTML index of packages in '.Library'
    >
  • Ista Zahn at Apr 30, 2010 at 4:52 pm
    Glad you got it working!

    By "true value" do you mean the means? If so:

    library(ggplot2)
    data(mtcars)

    p <- ggplot(mtcars, aes(x=cyl, y=mpg))

    p + stat_summary(fun.data = "mean_cl_boot", colour = "red", geom =
    "errorbar") + stat_summary(fun.data = "mean_cl_normal", colour =
    "blue", geom = "errorbar") + geom_point(stat="summary", fun.y = "mean")

    Best,
    Ista
    On Fri, Apr 30, 2010 at 12:33 PM, Giovanni Azua wrote:
    Hello,

    After installing gfortran from http://r.research.att.com/gfortran-4.2.3.dmg it finally works! see below.

    Thank you all.

    @Ista Zahn: Looks fantastic! :) thank you so much! ... is there a way to have a small circle on the true value?

    Best regards,
    Giovanni
    install.packages("Hmisc", dependencies=TRUE, type ="source")
    trying URL 'http://cran.ch.r-project.org/src/contrib/Hmisc_3.7-0.tar.gz'
    Content type 'application/x-gzip' length 563054 bytes (549 Kb)
    opened URL
    ==================================================
    downloaded 549 Kb

    * installing *source* package ?Hmisc? ...
    ** libs
    ** arch - i386
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 ?-I/usr/local/include ? ?-fPIC ?-g -O2 -c Hmisc.c -o Hmisc.o
    gfortran -arch i386 ? -fPIC ?-g -O2 -c cidxcn.f -o cidxcn.o
    gfortran -arch i386 ? -fPIC ?-g -O2 -c cidxcp.f -o cidxcp.o
    gfortran -arch i386 ? -fPIC ?-g -O2 -c hoeffd.f -o hoeffd.o
    gfortran -arch i386 ? -fPIC ?-g -O2 -c jacklins.f -o jacklins.o
    gfortran -arch i386 ? -fPIC ?-g -O2 -c largrec.f -o largrec.o
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 ?-I/usr/local/include ? ?-fPIC ?-g -O2 -c mChoice.c -o mChoice.o
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 ?-I/usr/local/include ? ?-fPIC ?-g -O2 -c nstr.c -o nstr.o
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 ?-I/usr/local/include ? ?-fPIC ?-g -O2 -c ranksort.c -o ranksort.o
    gfortran -arch i386 ? -fPIC ?-g -O2 -c rcorr.f -o rcorr.o
    gcc -arch i386 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 ?-I/usr/local/include ? ?-fPIC ?-g -O2 -c string_box.c -o string_box.o
    gfortran -arch i386 ? -fPIC ?-g -O2 -c wclosest.f -o wclosest.o
    gcc -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o Hmisc.so Hmisc.o cidxcn.o cidxcp.o hoeffd.o jacklins.o largrec.o mChoice.o nstr.o ranksort.o rcorr.o string_box.o wclosest.o -lgfortran -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
    installing to /Library/Frameworks/R.framework/Versions/2.11/Resources/library/Hmisc/libs/i386
    ** arch - x86_64
    gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 ?-I/usr/local/include ? ?-fPIC ?-g -O2 -c Hmisc.c -o Hmisc.o
    gfortran -arch x86_64 ? -fPIC ?-g -O2 -c cidxcn.f -o cidxcn.o
    gfortran -arch x86_64 ? -fPIC ?-g -O2 -c cidxcp.f -o cidxcp.o
    gfortran -arch x86_64 ? -fPIC ?-g -O2 -c hoeffd.f -o hoeffd.o
    gfortran -arch x86_64 ? -fPIC ?-g -O2 -c jacklins.f -o jacklins.o
    gfortran -arch x86_64 ? -fPIC ?-g -O2 -c largrec.f -o largrec.o
    gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 ?-I/usr/local/include ? ?-fPIC ?-g -O2 -c mChoice.c -o mChoice.o
    gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 ?-I/usr/local/include ? ?-fPIC ?-g -O2 -c nstr.c -o nstr.o
    gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 ?-I/usr/local/include ? ?-fPIC ?-g -O2 -c ranksort.c -o ranksort.o
    gfortran -arch x86_64 ? -fPIC ?-g -O2 -c rcorr.f -o rcorr.o
    gcc -arch x86_64 -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 ?-I/usr/local/include ? ?-fPIC ?-g -O2 -c string_box.c -o string_box.o
    gfortran -arch x86_64 ? -fPIC ?-g -O2 -c wclosest.f -o wclosest.o
    gcc -arch x86_64 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o Hmisc.so Hmisc.o cidxcn.o cidxcp.o hoeffd.o jacklins.o largrec.o mChoice.o nstr.o ranksort.o rcorr.o string_box.o wclosest.o -lgfortran -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
    installing to /Library/Frameworks/R.framework/Versions/2.11/Resources/library/Hmisc/libs/x86_64
    ** R
    ** inst
    ** preparing package for lazy loading
    Loading required package: splines
    ** help
    *** installing help indices
    ** building package indices ...
    ** testing if installed package can be loaded

    * DONE (Hmisc)

    The downloaded packages are in
    ? ? ? ??/private/var/folders/5m/5mC0wYCSGMK8NbPZYhBEZE+++TI/-Tmp-/Rtmpz0R5nY/downloaded_packages?
    Updating HTML index of packages in '.Library'
    ______________________________________________
    R-help at 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.


    --
    Ista Zahn
    Graduate student
    University of Rochester
    Department of Clinical and Social Psychology
    http://yourpsyche.org
  • Jim Lemon at May 1, 2010 at 7:26 am

    On 05/01/2010 12:10 AM, Giovanni Azua wrote:
    Hello,

    I need to plot multiple confidence intervals for the same model parameter e.g. so for the same value of the parameter in point x_1 I would like to see four different confidence intervals so that I can compare the accuracy e.g. boot basic vs normal vs my own vs classic lm CI etc.

    I like very very much the plotCI implemented here:
    http://cran.r-project.org/web/packages/plotrix/index.html

    This is their example:
    library(plotrix)
    y<- runif(10)
    err<- runif(10)
    plotCI(x=1:10,y=y,uiw=err,liw=2*err,lwd=2,col="red",scol="blue",main="Add colors to the points and error bars")

    but does not seem to support plotting multiple CIs but only one per point, is there a similar library somewhere but having the possibility to plot multiple CIs?

    I know there is the function "segment" but I like this one above more :)
    Hi Giovanni,
    Have a look at the dispersion function. You could just call it four
    times with x positions stepped out as in the brkdn.plot or similar
    functions (see the example for brkdn.plot to see what I mean).

    Jim

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupr-help @
categoriesr
postedApr 30, '10 at 2:10p
activeMay 1, '10 at 7:26a
posts7
users3
websiter-project.org
irc#r

People

Translate

site design / logo © 2021 Grokbase