par.c: Combine parameter blocks

View source: R/PAR_combine.R

par.cR Documentation

Combine parameter blocks

Description

This function is a wrapper for the c() method for param_block arrays that allows you to also specify a fitted evorates model from which to extract parameters specified via ....

Usage

par.c(..., fit = NULL)

Arguments

...

param_block arrays and/or character/numeric parameter selections to extract from fit. Additional arguments controlling how parameters are extracted from fit are determined automatically based on any param_block arrays in .... If ... only consist of parameter selections, the function defaults to extracting posterior samples from fit. All param_block arrays in ... must have compatible rows and slices (i.e., same number of chains, same names). param_block arrays with a param_type of "chains" have rows compatible with any other param_block array (they can be coerced to another param_type on the fly), with the exception of other chains param_block arrays that have a different number of rows. Otherwise, param_block arrays generally have compatible rows with other arrays of the same param_type provided they share least one row (i.e., quantile or diagnostic) in common.

fit

An object of class "evorates_fit" from which to extract parameters given by the character/numeric elements of .... Ignored if NULL (the default).

Details

I had to create a separate function for this because R does not default to the c() method for param_block arrays if character or numeric arguments are passed to c(). This function simply ensures R calls the proper method no matter what's passed to ....

Value

An array of class "param_block" with a param_type determined by the elements of ... (tends to default "chains" when in doubt). The dimensions 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. The resulting array contains all parameters specified by ... as columns, ordered as they are in ....

See Also

param_block-class for general information on param_block arrays and %chains%(), %quantiles%(), %means%(), %diagnostics%(), and %select%() for more information on param_block operators.

Examples

#get whale/dolphin evorates fit
data("cet_fit")

#how are average rates for some focal clades affected by R_sig2/R_mu estimates?
parblock <- get.bg.rate(fit = cet_fit,
                        node.groups = setNames(list('Mesoplodon','Orcinus',c('Pseudorca','Feresa')),
                                               c('Mesoplodon','Orca','Globicephalinae')),
                        )
parblock <- par.c("R_mu", "R_sig2", parblock, fit = cet_fit)
plot(parblock %chains% "Mesoplodon" ~ parblock %chains% "R_sig2"
plot(parblock %chains% "Orca" ~ parblock %chains% "R_mu")

#automatic conversion based on param_block type
parblock <- get.bg.rate(fit = cet_fit,
                        node.groups = setNames(list('Mesoplodon','Orcinus',c('Pseudorca','Feresa')),
                                               c('Mesoplodon','Orca','Globicephalinae')),
                        type = "quantiles")
par.c("R_mu", "R_sig2", parblock, fit = cet_fit)

#can mix numeric and character selections
par.c("R_0", "R_mu", 1, 28, fit = cet_fit)



bstaggmartin/backwards-BM-simulator documentation built on June 3, 2024, 5:51 p.m.