Learn R Programming

geiger (version 0.2-6)

area.between.curves: Area between two curves

Description

Finds the area between two curves up to a cutoff point (used to calculate the MDI statistic from Harmon et al. 2003

Usage

area.between.curves(x, f1, f2, xrange = c(0,1))

Arguments

x
Vector of values for the x axis
f1
Y values for curve 1
f2
Y values for curve 2
xrange
Range of x values over which area is calculated

Value

  • Area between f1 and f2 between 0 and cutoff

Details

Area is calculated between the two curves f1 and f2 for x values between 0 and cutoff If f1 is greater than f2, areas are positive; otherwise, areas are negative

References

Harmon et al. 2003

Examples

Run this code
data(geospiza)
attach(geospiza)

drop.tip(geospiza.tree, "olivacea")->g.tree

disp.data<-dtt(g.tree, geospiza.data)
s<-ic.sigma(g.tree, geospiza.data)
sims<-sim.char(g.tree, s, 100)

disp.sims<-dtt(g.tree, sims)
mean.sims<-rowSums(disp.sims)/ncol(disp.sims)

ltt<-sort(branching.times(g.tree), decr=TRUE)
ltt<-c(0, (max(ltt)-ltt)/max(ltt));
plot(ltt, disp.data)
lines(ltt, disp.data)
lines(ltt, mean.sims)

area.between.curves(ltt, mean.sims, disp.data, xrange=c(0, 2/3))

Run the code above in your browser using DataLab