Rainer M Krug
2011-Jul-26 12:58 UTC
[R] Comparing two pdf resulting from density() and identify where significantly smaller or larger?
Hi
this might be a little bit off topic, but here it goes: lets assume I have
the following:
set.seed(13)
dat1 <- rnorm(2000, mean=10, sd=10)
dat2 <- rnorm(100, mean=10, sd=20)
d.all <- density(dat, n=1024)
d.co <- density(x[[v]], , from=min(d.all$x), to=max(d.all$x),
n=1024)
d.diff <- list(
x = d.all$x,
y = d.all$y - d.co$y
)
ylim <- range(c(d.all$y, d.co$y, d.diff$y))
plot(
d.all,
ylim = ylim
)
abline(h=0)
lines(d.co, col="red")
lines(d.diff$x, d.diff$y, col="blue")
Now I would like to identify the areas where d.all is significantly larger
then d.co and where it is significantly smaller.
What is the easiest approach to do this? At the moment I am not doing any
tests, but I am sure there is a way to determine the ranges statistically?
Thanks,
Rainer
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa
Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax (F): +33 - (0)9 58 10 27 44
Fax (D): +49 - (0)3 21 21 25 22 44
email: Rainer@krugs.de
Skype: RMkrug
[[alternative HTML version deleted]]
Rainer M Krug
2011-Jul-27 09:36 UTC
[R] Comparing two pdf resulting from density() and identify where significantly smaller or larger?
Sorry for re-iterating - but are there any suggestions on how I could tackle this problem? Thanks, Rainer On Tue, Jul 26, 2011 at 2:58 PM, Rainer M Krug <r.m.krug@gmail.com> wrote:> Hi > > this might be a little bit off topic, but here it goes: lets assume I have > the following: > > set.seed(13) > dat1 <- rnorm(2000, mean=10, sd=10) > dat2 <- rnorm(100, mean=10, sd=20) > d.all <- density(dat, n=1024) > d.co <- density(x[[v]], , from=min(d.all$x), to=max(d.all$x), > n=1024) > d.diff <- list( > x = d.all$x, > y = d.all$y - d.co$y > ) > > ylim <- range(c(d.all$y, d.co$y, d.diff$y)) > plot( > d.all, > ylim = ylim > ) > abline(h=0) > lines(d.co, col="red") > lines(d.diff$x, d.diff$y, col="blue") > > Now I would like to identify the areas where d.all is significantly larger > then d.co and where it is significantly smaller. > > What is the easiest approach to do this? At the moment I am not doing any > tests, but I am sure there is a way to determine the ranges statistically? > > Thanks, > > Rainer > > -- > Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, > UCT), Dipl. Phys. (Germany) > > Centre of Excellence for Invasion Biology > Stellenbosch University > South Africa > > Tel : +33 - (0)9 53 10 27 44 > Cell: +33 - (0)6 85 62 59 98 > Fax (F): +33 - (0)9 58 10 27 44 > > Fax (D): +49 - (0)3 21 21 25 22 44 > > email: Rainer@krugs.de > > Skype: RMkrug > >-- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) Centre of Excellence for Invasion Biology Stellenbosch University South Africa Tel : +33 - (0)9 53 10 27 44 Cell: +33 - (0)6 85 62 59 98 Fax (F): +33 - (0)9 58 10 27 44 Fax (D): +49 - (0)3 21 21 25 22 44 email: Rainer@krugs.de Skype: RMkrug [[alternative HTML version deleted]]