Displaying 20 results from an estimated 20000 matches similar to: "Determine area between two density plots"
2010 Sep 23
2
Plotting densities
Hi group,
I am currently plotting two densities using the following code:
x1 <- c(1,2,1,3,5,6,6,7,7,8)
x2 <- c(1,2,1,3,5,6,5,7)
plot(density(x1, na.rm = TRUE))
polygon(density(x2, na.rm = TRUE), border="blue")
However, I would like to avoid bordering the second density as it adds
a nasty bottom line which I would like to avoid.
I would also rather have a dashed or dotted line
2010 Sep 21
5
Combined plot: Scatter + density plot
Hi,
in order to save space for a publication, it would be nice to have a
combined scatter and density plot similar to what is shows on
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=78
I wonder if anybody perhaps has already developed code for this and is
willing to share. This is the reproducible code for the histogram
version obtained from the site:
def.par <-
2007 Oct 03
2
Shading area under density curves
Hello,
I have a question regarding shading regions under curves to display
95% confidence intervals. I generated bootstrap results for the slope
and intercept of a simple linear regression model using the following
code (borrowed from JJ Faraway 2005):
> attach(allposs.nine.d)
> x<-model.matrix(~log(d.dist,10))[,-1]
> bcoef<-matrix(0,1000,2)
> for(i in 1:1000){
+
2012 Sep 27
3
Comparing density plots using same axes or same axes scale
Good Evening-
I have a set of nine scenarios I want to plot to see how the distribution
is changing, if one tail is getting larger in certain scenario, currently I
am using this code
colnames<-dimnames(sag_pdfs)[[2]]
par(mfrow=c(3,3))
for(i in 1:9) {
d<-density(sag[,i])
plot(d,type="n", main=colnames[i])
polygon(d,col="red",border="grey")}
where sag is
2007 Aug 05
1
Selectively shading areas under two density curves
Dear Listers,
I am drawing a plot of two density curves, for male and female incomes. I would
like to shade/hatch/color (whatever) the areas under the curves which are
distinctive for each gender. This is the code I have tried so far:
m <- density(topmal.d$y, bw = "sj")
f <- density(topfem.d$y, bw = "sj")
par(mfrow = c(1,1))
plot(x = c(0,400), y = c(0,0.02), type =
2009 Aug 19
2
how to fill the area under the density line with semitransparent colors
Dear R-listers,
I have created a plot to display the density lines for the same
variable by different entities. Now, I want to fill the area under the
density lines with semitransparent colors.
Though I have checked that in web-searching and book-reading, I still
do not perform that.
Could anyone please give me any helps or advice? Thank you in advance.
The data and code I used listed below:
#
2002 Mar 31
1
How to get the datapoints of an density estimationwithlocfit?
Hello!!
At first thank you all for your suggestions and your help.
But I would like to get another group of datas from the density estimation. I don't know if these information are provided by locfit or I should use an other function like plot().
Description:
Each number between 1 and 100 (only integer) for example should have only one density value. But I also would like to have the density
2007 Mar 15
2
Density estimation graphs
Dear all,
I'm struggling with a plot and would value any help!
I'm attempting to highlight a histogram and density plot to show a
proportion of cases above a threshold value. I wanted to cross-hatch the
area below the density curve. The breaks and bandwidth are deliberate
integer values because of the type of data I'm looking at.
I've managed to do this, but I don't think it
2002 Mar 29
2
How to get the datapoints of an density estimation with locfit?
Hello!!!
I'm just a beginner of R.
I work with locfit to get the density from an numeric vector. It looks good when I plot the graph, but I need the output data of locfit.
For example I need somthing like that (only integer values for the input):
numeric vector (input of locfit) density (output of locfit)
1 0.05....
2 0.04..
3 0.01
...
Thank you for your help and your time.
2005 May 04
1
Questions about the intersection area under two kernel densities
Hi there,
I am working on a project which needs the value of the interaction area under two distributions( eatimated by kernel density estimators).
For example:
x<-rnorm(100,0,1)
y<-rnorm(100,0.2,1)
density(x) # This produces the summary of dependent variable and independent variable.
How can I get the individual values of variables and reform a curve to calculate the area under
2008 Apr 25
3
How to overlap two density plots?
Hi,
How can I overlap two density plots?
A <- c(8,10,10,11,11,11,12,12,12,12,11,11,11,10,10,7)
B <- c(11,13,13,14,14,14,15,15,15,15,14,14,14,13,13,10)
plot(density(A))
plot(density(B))
Regards,
Emre
P.S. There's a overlap.density function in package DAAG
Is there another way to do this?
--
---
Emre ÜNAL
http://www.geocities.com/dusemre
[[alternative HTML version
2007 Mar 13
3
Highlight overlapping area between two curves
Dear R helpers,
I have a graph as following; I would like to highlight the overlapping area
between the two curves. Do you know how to do this?
Thank you in advance for your help.
Nguyen
###START
x1 <- rnorm(10000, 0.70,0.12)
x2 <- rnorm(10000, 0.90,0.12)
d1 <- density(x1)
d2 <- density(x2)
plot(range(d1$x,d2$x), range(d1$y, d2$y), type = "n",
xlab = "X
2005 Sep 28
1
scatterplot3d + density() + polygon(color)
Hi R Users,
How to use the function polygon()
together with the package scatterplot3d?
I am trying to color below of the curves
defined for the function density().
I tried to use the site: R GRAPH GALLERY
as tutorial.
I tried to adapt the example of this page:
[figure]:
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=30
[code]:
2011 Jan 26
2
Colour area under density curve
Hello,
I have this code to plot a certain normal distribution and represent the pnorm
value for a certain "x":
x<-300
xx <- seq(2.5,7.5, by=0.1)
yy <- dnorm(xx,5.01,0.77)
d<-signif(pnorm(log(x), 5.01,0.77),4)
xpts <- round(exp(0:8))
par(bg = "antiquewhite")
plot(xx,yy, type="l", col="blue", lwd=2, xaxt="n",
2009 Mar 10
2
How to color certain area under curve
For a given random variable rv, for instance, rv = rnorm(1000),
I plot its density curve and calculate some quantiles:
plot(density(rv))
P10P50P90 = = quantile(rv,probs = c(10,50,90)/100)
I would like to color the area between P10 and P90 and under the curve
and mark the P50 on the curve.
> rv = rnorm(1000)
> plot(density(rv))
> P10P50P90 = = quantile(rv,probs = c(10,50,90)/100)
Could
2010 Jun 23
4
Comparing distributions
I am trying to do something in R and would appreciate a push into the
right direction. I hope some of you experts can help.
I have two distributions obtrained from 10000 datapoints each (about
10000 datapoints each, non-normal with multi-model shape (when
eye-balling densities) but other then that I know little about its
distribution). When plotting the two distributions together I can see
that
2013 Mar 20
3
highlight overlapping region of two densities
Hi all.
I would like to highlight overlapping regions of two densities and I could
not find a way to do it.
Here is the sample code:
myd <- c(2,4,5, 4,3,2,2,3,3,3,2,3,3,4,2,4,3,3,3,2,2.5,
2, 3,3, 2.3, 3, 3, 2, 3)
myd1 <- myd-2
plot(range(density(myd)$x, density(myd1)$x), range(density(myd)$y,
density(myd1)$y), type = "n")
lines(density(myd), col=1, lwd=4)
2010 Sep 03
2
density() with confidence intervals
Hello R users & R friends,
I just want to ask you if density() can produce a confidence interval, indicating how "certain" the density() line follows the true frequency distribution based on the sample you feed into density().
I've heard of loess.predict(loess(y ~ x), se=TRUE) which gives you a SE estimate of the smoothed scatterplot - but density() kernel smoothing is not the
2007 Jan 25
7
filling the area
Please, how to fill the area under the curve?
x <- c(1:10)
y <- c(rnorm(10))
plot(x,y)
lines(x,y)
Thanks,
Mauricio Cardeal
2002 May 19
3
How to shade part of a density plot
I'm trying to shade part of a density plot. The code I'm trying (using
the Old Faithful data as an example) is something like this:
# The Old Faithful geyser data
data(faithful)
d <- density(faithful$eruptions, bw = "sj")
plot(d)
polygon(d[d$x>4], col = "wheat")
I expected that the part of the curve to the right of 4 on the x axis
should be shaded, but nothing