Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-08-02 Thread Rolf Turner
On Mon, 2 Aug 2021 17:53:34 +0100 Rui Barradas wrote: > Hello, > > I'm glad it helped. > Here are a couple of ideas for theme. Thanks Rui. The scope of your knowledge and understanding is simply amazing! cheers, Rolf -- Honorary Research Fellow Department of Statistics University of Au

Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-08-02 Thread Rui Barradas
Hello, I'm glad it helped. Here are a couple of ideas for theme. 1) From ?theme: Theme inheritance Theme elements inherit properties from other theme elements hierarchically. For example, axis.title.x.bottom inherits from axis.title.x which inherits from axis.title, which in turn inherits fro

Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-08-02 Thread Rolf Turner
I would like to tie off this thread (?!?!) by thanking Jeff Newmiller, Rui Barradas, Avi Gross and Bill Dunlap for their advice and insight. I have attached the code that I finally put together, on the basis of the aforementioned advice, in the file ciPlot.txt. I have also attached the necessary

Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-07-20 Thread Rolf Turner
Thanks to Bill Dunlap and Avi Gross for their clear and helpful answers to my questions. cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ R-help@r-project.org mailin

Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-07-19 Thread Avi Gross via R-help
Of Rolf Turner Sent: Monday, July 19, 2021 7:24 PM To: r-help@r-project.org Subject: Re: [R] Plotting confidence intervals with ggplot, in multiple facets. Thanks to Jeff Newmiller, Rui Barradas and Avi Gross for their extremely helpful replies. I have got both Jeff's and Rui&#

Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-07-19 Thread Bill Dunlap
ggplot2::labs() interprets expressions as plotmath. E.g., data.frame(X=1:10,Y=(1:10)^2) %>% ggplot(aes(X,Y)) + geom_point() + labs(x = expression(beta), y = expression(beta^2)) -Bill On Mon, Jul 19, 2021 at 4:24 PM Rolf Turner wrote: > > > Thanks to Jeff Newmiller, Rui Barradas and

Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-07-19 Thread Rolf Turner
Thanks to Jeff Newmiller, Rui Barradas and Avi Gross for their extremely helpful replies. I have got both Jeff's and Rui's code to run. I am currently experimenting with Avi's suggestion of producing multiple plots and then putting them together using plotgrid() or grid.arrange(). This idea s

Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-07-18 Thread Avi Gross via R-help
Rolf, Your example shows two plots with one above the other. If that is what you want, then a solution like the one Jeff provided using facet_grid() to separate data based on the parameter value. It also scales up if you add additional sets of data for gamma and delta up to a point. An alterna

Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-07-18 Thread Rui Barradas
Hello, Something like this? library(ggplot2) eg <- dget("data/egData.txt") ggplot(eg, aes(Ndat, estimate)) + � geom_errorbar(aes(ymin = lower, ymax = upper), width = 20) + � geom_point(colour = "slateblue", size = 1) + � geom_hline(yintercept = 0, colour = "red") + � facet_grid(param ~ .) +

Re: [R] Plotting confidence intervals with ggplot, in multiple facets.

2021-07-17 Thread Jeff Newmiller
ggplot(dta,aes(x=Ndat,y=estimate, ymin=lower,ymax=upper))+ geom_point() + geom_errorbar(width=30) + facet_grid(param~1) + theme_minimal() Width parameter seems odd... play with it I suppose. For facets, you can also use facet_wrap(~param, ncol=1). ggplot is very much about the data and t

Re: [R] Plotting confidence intervals

2019-12-08 Thread phil
Thanks so much Jim. Yes, this is giving me what I want. Philip On 2019-12-08 05:00, Jim Lemon wrote: Hi Philip, This may be a starter: attach(airquality) heights <- tapply(Temp,Month,mean) temp_sd<-tapply(Temp,Month,sd) lower <- tapply(Temp,Month,function(v) t.test(v)$conf.int[1]) upper <- tap

Re: [R] Plotting confidence intervals

2019-12-08 Thread Jim Lemon
Hi Philip, This may be a starter: attach(airquality) heights <- tapply(Temp,Month,mean) temp_sd<-tapply(Temp,Month,sd) lower <- tapply(Temp,Month,function(v) t.test(v)$conf.int[1]) upper <- tapply(Temp,Month,function(v) t.test(v)$conf.int[2]) library(plotrix) barp(heights,ylim=c(0,100),names.arg=m

Re: [R] Plotting confidence intervals

2019-12-08 Thread phil
Thanks for these helpful suggestions. These options don't work in my case because I don't know the individual observations (the dots). A statistical agency collects the observations and keeps them confidential. It provides the mean value and the standard deviation, plus the fact that the obser

Re: [R] Plotting confidence intervals

2019-12-07 Thread Ben Tupper
Hi, Would something like yarrr do the trick? https://ndphillips.github.io/yarrr.html Or gghalves? https://github.com/erocoar/gghalves Cheers, Ben On Sat, Dec 7, 2019 at 9:32 PM wrote: > I want to show little bell curves on my bar chart to illustrate the > confidence ranges. The following ex

Re: [R] Plotting Confidence Intervals into a density plot

2016-12-02 Thread Elysa Mitova
Hi, sadly it does not work either, because my index (x axis) is an atomic vector. Error Message: $ operator is invalid for atomic vectors I think I have to stick to displaying the confidence intervals with straight lines (ablines) , instead of a shaded area (polygon) Thank you so much for your he

Re: [R] Plotting Confidence Intervals into a density plot

2016-12-02 Thread Jim Lemon
Hang on, maybe you mean something like this: erupt_dens<-density(faithful$eruptions) plot(erupt_dens,ylim=c(0,0.65)) dispersion(erupt_dens$x,erupt_dens$y,ulim=erupt_dens$y/5, type="l",fill="lightgray",interval=TRUE) lines(erupt_dens) Jim On Fri, Dec 2, 2016 at 9:36 PM, Jim Lemon wrote: > In o

Re: [R] Plotting Confidence Intervals into a density plot

2016-12-02 Thread Jim Lemon
In order to display a polygon, you need x/y pairs for each point. If you just want a rectangle, you only need four x/y pairs, e.g.: plot(0,xlim=x(2.44,2.57),ylim=c(0,1),type="n") polygon(c(2.44,2.57,2.57,2.44),c(0,0,1,1),col="lightgray") Now if you have a series of x values and want to display a

Re: [R] Plotting Confidence Intervals into a density plot

2016-12-02 Thread Elysa Mitova
Thank you, this seems to work, but it is not exactly what I need (it indeed looks great, but a bit beyond my understanding) I just need a shaded area between 2.44 to 2.57 along the x-axis - a polygon inserted into my density plot (and not a confidence line along a scatter plot like your suggeste

Re: [R] Plotting Confidence Intervals into a density plot

2016-12-02 Thread Jim Lemon
Hi Elysa, I think you are going a bit off course in your example. Try this and see if it is close to what you want: data<-rnorm(100)+runif(100,0,15) smu_data<-supsmu(1:100,data) rollfun<-function(x,window=10,FUN=sd) { xlen<-length(x) xout<-NA forward<-window%/%2 backward<-window-forward for(i

Re: [R] Plotting Confidence Intervals into a density plot

2016-12-02 Thread Elysa Mitova
Hi, thank you! I've constructed the upper and lower bounds with a <- 2.505766 s <- 0.7789832 n <- 607 error <- qnorm(0.975)*s/sqrt(n) left <- a-error right <- a+error left right Now, I have the numbers I need, but I have no idea how to plot them. I was thinking of using a polygon, but som

Re: [R] Plotting Confidence Intervals into a density plot

2016-12-01 Thread David Winsemius
> On Dec 1, 2016, at 12:10 PM, Elysa Mitova wrote: > > Hi, > > I am desperately looking for a way to plot confidence intervals into a > density plot of only one variable (not a scatter plot etc.) > > Have you any advice how to do this? > > I've only found manual ways to do with "abline", but

Re: [R] Plotting Confidence Intervals

2015-05-03 Thread Steve Taylor
Have you tried: library(effects) plot(allEffects(ines),ylim=c(460,550)) -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Andre Roldao Sent: Saturday, 2 May 2015 2:50p To: r-help@r-project.org Subject: [R] Plotting Confidence Intervals Hi Guys, It's the

Re: [R] Plotting Confidence Intervals

2015-05-03 Thread Jim Lemon
Hi Andre, Perhaps you want something like this: plot(c(p_conf[1],p_conf1[1],p_pred2[1],p_pred3[1]),xaxt="n", xlab="Model",ylab="Estimate") axis(1,at=1:4,labels=c("p_conf","p_conf1","p_pred2","p_pred3")) library(plotrix) dispersion(1:4,c(p_conf[1],p_conf1[1],p_pred2[1],p_pred3[1]), ulim=c(p_conf[

Re: [R] Plotting Confidence Intervals

2015-05-02 Thread Andre Roldao
Hi Kehl, First i would like to thank you for the support. to respond your question i want rather the 4 intervals with the labels, but another one with the 4 bars with the intervals, it was fantastic! Thank you again! 2015-05-02 9:24 GMT+01:00 Kehl Dániel : > Hi Andre, > > I think you'll have t

Re: [R] Plotting Confidence Intervals

2015-05-02 Thread Kehl Dániel
Hi Andre, I think you'll have to give some more information about what you want to see on your plot. The 4 intervals with labels? A bar with an interval maybe? Four bars with the intervals? Only two showing differences between conf and pred intervals? Also you do miss a 1 here I guess: p_conf

Re: [R] Plotting Confidence Intervals with a proiri calculated Intervals

2012-01-23 Thread R. Michael Weylandt
Would you like to do this plot in base graphics or in ggplot2? If the latter, I'd suggest you look over Hadley's online documentation and the archives of the dedicated ggplot2 mailing list. If you want to do it in base graphics, you'll have to say what your data set looks like and what sort of gra

Re: [R] Plotting Confidence Intervals with a proiri calculated Intervals

2012-01-23 Thread David Winsemius
On Jan 23, 2012, at 7:37 PM, klakoh wrote: I have already obtained my confidence intervals from a bootstrapping procedure and now I want to plot the estimates and the confidence intervals similar to the plots obtained when the geom_smooth function is used in ggplot2. Thanks You should look

Re: [R] Plotting confidence intervals of two response on same graph (panel).

2010-06-17 Thread Kim Jung Hwa
I actually need to plot all of my confidence interval for x and y axis but it seems error.crosses only plot the common ones. But thanks for suggesting error.crosses. Please let me know if I can specify some option in eror.crosses to implement that. Any idea about how to plot all confidence interva

Re: [R] Plotting confidence intervals of two response on same graph (panel).

2010-06-17 Thread William Revelle
Kim, It is possible that error.crosses in the psych package will do what you want. Bill At 9:25 AM -0400 6/17/10, Kim Jung Hwa wrote: Hello! I would like to draw a graph like the following: http://www.optics.rochester.edu/workgroups/cml/opt307/spr04/pavel/plot_small.jpg Aim is to plot confi

Re: [R] plotting confidence intervals

2009-07-15 Thread Greg Snow
I believe there is a set of options in the ggplot2 package that will create a plot and add the confidence region to it, you will need to look at the documentation for ggplot2, I don't know the details (have not made it that far on my to do list, not anything against the package). -- Gregory (G

Re: [R] plotting confidence intervals

2009-07-15 Thread Jim Lemon
Erin Hodgess wrote: Hi R People: If I have a fitted values from a model, how do I plot the (1-alpha)100% confidence intervals along with the fitted values, please? Also, if the intervals are "shaded" gray, that would be nice too, please? I check confint, but that doesn't seem to do what I want

Re: [R] plotting confidence intervals

2009-07-14 Thread Daniel Malter
Erin and all, I lavishly used the factor 2 for the confidence intervals. Of course this should be approximately 1.96 for the 95% CI under the assumption of normality. So just adjust the factor accordingly or according to your desired alpha level when you create the CI data frame. Otherwise, my exam

Re: [R] plotting confidence intervals

2009-07-14 Thread Daniel Malter
Hi Erin, have a look at the following example: #Simulate data n=1000 x1=rnorm(n,0,0.05) x2=rnorm(n,0,0.1) x3=rnorm(n,0,0.02) e=rnorm(n,0,1) y=x1+2*x2-0.5*x3+e #Run regression reg=lm(y~x1+x2+x3) #Regression output summary(reg)$coef #Create dataset with confidence intervals and an index CI=data.

Re: [R] plotting confidence intervals

2009-07-14 Thread Marc Schwartz
On Jul 14, 2009, at 10:40 AM, Erin Hodgess wrote: Hi R People: If I have a fitted values from a model, how do I plot the (1-alpha)100% confidence intervals along with the fitted values, please? Also, if the intervals are "shaded" gray, that would be nice too, please? I check confint, but

Re: [R] plotting confidence intervals of regression line

2007-11-20 Thread Eik Vettorazzi
you can use the newdata statement in the predict function, as in n<-50 x<-sample(40:70,n,rep=T) y<-.7*x+rnorm(n,sd=5) plot(x,y,xlim=c(20,90),ylim=c(0,80)) mylm<-lm(y~x) abline(mylm,col="red") newx<-seq(20,90) prd<-predict(mylm,newdata=data.frame(x=newx),interval = c("confidence"), level = 0.90,ty