grapes-select-grapes: Extract subsets from a parameter block

%select%R Documentation

Extract subsets from a parameter block

Description

This operator extracts particular parameter quantities from a param_block array.

Usage

x %select% select

x %s% select

Arguments

x

An object of class "param_block" with any param_type.

select

A list with two elements (2nd element is optional):

  • A character or numeric vector for selecting parameters. If a character vector, entries are matched to parameter names using partial matching. If a numeric vector, a number i will select the ith parameter in x.

  • A numeric or character vector for specifying samples, quantiles, or diagnostics based on the param_type of x. This is ignored if x is of param_type "means". If unsupplied, defaults to including all samples/quantiles/diagnostics. If a numeric vector, a number i will select the ith sample/quantile/diagnostic in x. If a character vector, entries are matched to sample/quantile/diagnostic names using partial matching. Note that samples don't have names in the case chains param_block arrays–in this case, character vectors are automatically converted to numeric vectors.

Details

This function can be used instead of the other param_block operators to emulate a more "traditional" means of subsetting arrays comparable to data.frame objects. Since it relies on partial matching, rather than regular expressions, any name will extract either 0 or 1 parameters, samples, quantiles, or diagnostics, depending on whether the name had a clear match or not. Furthermore, any number i will extract that ith parameter, sample, quantile, or diagnostic, rather than using "special" rules (branchwise rate searching, etc.). Note that out of bound numbers are ignored, rather than returning NA's. Other param_block conventions are still enforced: collapsed dimensions have their information stored as attributes and specific chains cannot be selected. You still have to use select.chains on entire evorates_fit objects for selecting particular chains.

Value

An array of class "param_block" with the same param_type as x. The dimension of these arrays will generally go in the order of samples/quantiles/diagnostics, then parameters, then chains. Any dimensions of length 1 are collapsed and stored as attributes.

See Also

This function relies on pmatch for partial matching.

Other param_block operators: %chains%(), %diagnostics%(), %means%(), %quantiles%()

Examples

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

#get a chains param_block array
par <- cet_fit %chains% "R"
#note partial match vs. regular expressions behavior
par %select% "R_1"
par %select% list(NULL)
#note numeric index selection behavior change too
par %select% 1

#get a quantiles param_block array
par <- cet_fit %quantiles% "R"
#note numeric index selection behavior change for quantiles
par %select% list(1, 1)

#get a means param_block array
par <- cet_fit %means% "R"
#note 2nd element of list is ignored
par %select% list(1, 2)

#get a diangostics param_block array
par <- cet_fit %diagnostics% "R"
#note partial vs. regular expressions behavior for selecting diagnostics
par %select% list(1, "bulk")
par %select% list(1, "ess") #returns empty array with warning



bstaggmartin/evorates documentation built on May 31, 2024, 5:56 a.m.