Skip to contents

Filters a prepared data list (from prepare_phylo_niche_data() or prepare_phylo_data()) down to exactly the variables declared in the data {} block of the named Stan model. Prepare functions attach bookkeeping fields (species, masked, eta, T_anc, ...) that are useful in R but rejected by cmdstanr's type validation; this helper drops them so the list can be passed straight to fit_evolution() or CmdStanModel$sample().

Usage

stan_only(data, model)

Arguments

data

A named list of Stan data, as returned by the prepare functions.

model

Character string specifying the model whose data block is parsed (e.g. "bm_evolving"). See model_path().

Value

A named list containing only the declared fields, in the original order.

Details

The parser reads the bundled .stan file at install time of each call, so the field set always matches the shipped model – adding a data variable to a Stan file automatically whitelists it.

Examples

if (FALSE) { # \dontrun{
stan_data <- prepare_phylo_niche_data(env_occ_list, env_m_list, tree)
stan_data <- stan_only(stan_data, "bm_evolving")
fit <- fit_evolution(stan_data, model = "bm_evolving")
} # }