View source: R/OUT_GET_get.R.R
get.R | R Documentation |
This is a convenient function for extracting branchwise rate parameters from an
evorates_fit
object. It even works when the object has no branchwise
rate parameters (i.e., a Brownian Motion model).
get.R(
fit,
select = seq_len(Nedge(fit)),
type = c("chains", "quantiles", "means", "diagnostics"),
extra.select = NULL,
simplify = TRUE
)
fit |
An object of class " |
select |
A numeric vector specifying edge indices in |
type |
A string specifying whether to extract posterior samples (" |
extra.select |
A numeric, integer, or character vector specifying the specific samples/
quantiles/diagnostics to extract, depending on |
simplify |
|
The edge indices of fit$call$tree
can be viewed by running:
plot(fit$call$tree); edgelabels()
.
In the case of a fit
with constrained rate variance (R_sig2
) and trend
(R_mu
) parameters, fit
doesn't contain explicit branchwise rate parameters (
R_i
, where i
is the index of the corresponding edge). In this case, a simple Brownian
Motion model of trait evolution has been fitted, and the branchwise rate parameters are all
equivalent to the rate at the root (R_0
). As such, this function just creates a
param_block
array of R_0
replicated the appropriate number of times, with parameters
renamed with the appropriate R_i
's.
An array of class "param_block
" with a param_type
set to whatever
type
is. The dimension of these arrays will generally go in the order of
iterations/quantiles/diagnostics, then parameters, then chains. Any dimensions of length 1 are
collapsed and stored as attributes if simplify
is TRUE
. Note that branchwise
rate parameters go by the name R_i
, where i
is the index of the corresponding
edge in fit$call$tree
.
Other parameter extraction functions:
get.bg.rate()
,
get.post.traits()
,
remove.trend()
#get whale/dolphin evorates fit
data("cet_fit")
#get posterior samples of branchwise rates
Rs <- get.R(cet_fit)
#let's say we want to get some of the edges towards the root
plot(cet_fit$call$tree); edgelabels()
#select particular edges
Rs <- get.R(cet_fit, select = c(1, 2, 9, 28, 29, 30))
#maybe specific samples too?
Rs <- get.R(cet_fit, select = c(1, 2, 9, 28, 29, 30),
extra.select=c(1, 23, 47))
#this may be a more common way to get edge indices; say we want to look at the genus Mesoplodon
edges <- get.clade.edges(cet_fit$call$tree, "Mesoplodon")
Meso.Rs <- get.R(cet_fit, select = edges)
#or at everything EXCEPT Mesoplodon
notMeso.Rs <- get.R(cet_fit, select = -edges)
#could also look at quantiles, means, or diagnostics
med.Rs <- get.R(cet_fit, select = edges,
type = "quantiles",
extra.select = 0.5)
mean.Rs <- get.R(cet_fit, select = edges,
type = "means")
init.Rs <- get.R(cet_fit, select = edges,
type = "diagnostics",
extra.select = c("inits", "ess"))
#here's an example of what happens when you don't simplify the result
med.Rs <- get.R(cet_fit, select = edges,
type = "quantiles",
extra.select = 0.5,
simplify = FALSE)
#note that all this is equivalent to running <fit> %<type>% list(<select>, <extra.select>)
#at least when <fit> includes branchwise rate parameters
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.