sample.basic.models: Samples simple increase/decrease models through time with...

Description Usage Arguments Value Examples

View source: R/sample.rates.R

Description

Samples simple increase/decrease models through time with noise.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
sample.basic.models(
  times,
  rate0 = NULL,
  model = "exponential",
  direction = "decrease",
  noisy = TRUE,
  MRF.type = "HSMRF",
  monotonic = FALSE,
  fc.mean = 3,
  rate0.median = 0.1,
  rate0.logsd = 1.17481,
  min.rate = 0,
  max.rate = 10
)

Arguments

times

the time knots

rate0

The rate at present, otherwise drawn randomly.

model

"MRF" for pure MRF model, otherwise MRF has a trend of type "exponential","linear", or "episodic<n>"

direction

"increase" or "decrease" (measured in past to present)

noisy

If FALSE, no MRF noise is added to the trajectory

MRF.type

"HSMRF" or "GMRF", type for stochastic noise.

monotonic

Whether the curve should be forced to always move in one direction.

fc.mean

Determines the average amount of change when drawing from the model.

rate0.median

When not specified, rate at present is drawn from a lognormal distribution with this median.

rate0.logsd

When not specified, rate at present is drawn from a lognormal distribution with this sd

min.rate

The minimum rate (rescaling fone after after drawing rates).

max.rate

The maximum rate (rescaling fone after after drawing rates).

Value

Speciation or extinction rate at a number of timepoints.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data("primates_ebd")

l <- approxfun(primates_ebd[["time"]], primates_ebd[["lambda"]])
mu <- approxfun(primates_ebd[["time"]], primates_ebd[["mu"]])
times <- primates_ebd[["time"]]

model <- create.model(l, mu, times)

mus <- sample.basic.models(times = times, 
                               rate0 = 0.05, 
                               "MRF", 
                               MRF.type = "HSMRF", 
                               fc.mean = 2.0, 
                               min.rate = 0.0, 
                               max.rate = 1.0)

model_set <- congruent.models(model, mus = mus)

model_set

ACDC documentation built on Jan. 13, 2022, 1:08 a.m.