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