rage: Random clade age generator

Description Usage Arguments Details Value Examples

View source: R/rage.R

Description

This function uses the quantile function above to generate random clade ages from the corresponding models.

Usage

1
rage(n, min.ages, max.ages = NULL, max.p = 1, ...)

Arguments

n

Number of samples to be frawn

min.ages

A vector of minimum ages, potentially accounting for age uncertainty.

max.ages

A vector of minimum ages, potentially accounting for age uncertainty.

max.p

Option for sampling up to a certain probability, useful for avoiding extremely large values when using Solow (2003). Useful for exploratory analysis and histograms but the maximum probability should not be restricted if the sample is used in Monte Carlo simulations.

...

Other options passed to qage

Details

If ages are known exactly, only min.ages is used. If some or all ages have uncertainty, typically upper and lower bounds defined by bracketing geological strata, age maximums and minimums are set for each fossil.

Value

A numeric vector of length n representing simulated clade ages

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Not run: 
  # Example using the default method of Strauss & Sadler (1989)
  hist(rage(n=10000, min.ages=c(50, 30, 25, 14, 3.5)), breaks=500,
    freq=FALSE, xlim=c(50,120), xlab="Clade Age",
    main="Strauss & Sadler Example\nn=1000, min.ages=c(50, 30, 25, 14, 3.5), max.p=0.95");
  curve(dexp(x-50, rate=0.07), col='blue', lwd=2, add=TRUE);
  legend("right", legend="dexp", col="blue", lty=1, lwd=2, box.lty=0);
  
  # Example using the method of Solow (2003)
  hist(rage(n=10000, min.ages=c(50, 30, 25, 14, 3.5), max.p=0.95,
    method="Solow"), breaks=500, freq=FALSE, xlim=c(50,120), xlab="Clade Age",
    main="Solow Example\nn=1000, min.ages=c(50, 30, 25, 14, 3.5), max.p=0.95");
  curve(dexp(x-50, rate=0.04), col='blue', lwd=2, add=TRUE); # heavy on intermediate values
  curve(dlnorm(x-50, meanlog=log(50-30), sdlog=pi/sqrt(3)), col='orange', lwd=2, add=TRUE);
  legend("right", legend=c("dexp", "dlnorm"), col=c("blue", "orange"), lty=1, lwd=2, box.lty=0);
  
  # Strauss & Sadler (1989) method incorporating fossil age uncertainty
  hist(rage(n=10000, min.ages=c(50, 30, 25, 14, 3.5),
    max.ages=c(56, 35, 25, 14, 6)), breaks=500, freq=FALSE, xlim=c(50,120),
    xlab="Age", main="Solow Example (with fossil age uncertainty)\nn=1000,
    min.ages=c(50, 30, 25, 14, 3.5), max.ages=c(56, 35, 25, 14, 6))\nmax.p=0.95");
  curve(dlnorm(x-50, meanlog=2.6, sdlog=0.9), col='blue', lwd=2, add=TRUE);
  legend("right", legend="dlnorm", col="blue", lty=1, lwd=2, box.lty=0);
  
## End(Not run)

evolucionario/cladeage documentation built on Dec. 31, 2021, 8:48 a.m.