sample.basic.models {CRABS}R Documentation

Samples simple increase/decrease models through time with noise.

Description

Samples simple increase/decrease models through time with noise.

Usage

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,
  mrf.sd.scale = 1,
  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

mrf.sd.scale

scale the sd of the mrf process up or down. defaults to 1.0

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

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

[Package CRABS version 1.2.0 Index]