R/plot_fit_bd.R

Defines functions plot_fit_bd

Documented in plot_fit_bd

plot_fit_bd <- function(fit.bd,tot_time)
{
  if (!inherits(fit.bd, "fit.bd"))
      stop("object \"fit.bd\" is not of class \"fit.bd\"")
  t <- seq(0,tot_time, length.out=100)
  dev.new()
  plot(-t, sapply(t,fit.bd$f.lamb), type='l', xlab="time", ylab="speciation rate", main="Fitted speciation rate")

  if ("f.mu" %in% attributes(fit.bd)$names)
  {
    # Attribute f.mu ==> not fixed extinction
    dev.new()
    plot(-t, sapply(t,fit.bd$f.mu), type='l', xlab="time", ylab="extinction rate", main="Fitted extinction rate")
    r <- function(t) {fit.bd$f.lamb(t) - fit.bd$f.mu(t)}
    dev.new()
    plot(-t, sapply(t,r), type='l', xlab="time", ylab="net diversification rate", main="Fitted net diversification rate")
  }
  else
  {
    dev.new()
    plot(-t, sapply(t,fit.bd$f.lamb), type='l', xlab="time", ylab="net diversification rate", main="Fitted net diversification rate")
  }
}
hmorlon/PANDA documentation built on April 24, 2024, 3:27 a.m.