parameter_source() describes an existing JAGS node that another generated model component may reference without creating or owning a prior for it.

random_sd_source() marks a parameter source as an external random-effect SD source. It is intended for variance allocations that should use an already-defined JAGS node, such as scalar tau or row-shaped tau, instead of creating a prior-owned total SD parameter.

parameter_source(
  name,
  shape = c("scalar", "row"),
  values = NULL,
  inputs = NULL
)

random_sd_source(source, shape = c("scalar", "row"))

Arguments

name

JAGS node name.

shape

source shape. "scalar" references one existing JAGS node; "row" references a vector node aligned to the formula rows. Generated row-shaped random-effect syntax indexes the node inside the observation loop.

values

optional function for R-side reconstruction of row-shaped sources. When supplied with shape = "row", it must accept named arguments parameters, data, and n_rows, or include ..., and return a numeric vector of length n_rows. Prediction and bridge-sampling reconstruction evaluate a supplied values function first; without one they use the posterior columns named name[1], ..., name[N] when present. Supply values when those columns are absent or when prediction needs source values for arbitrary new rows (missing values then errors). For formula bridge reconstruction, data contains raw row-aligned formula/model data rather than standardized design matrices. Scalar sources do not accept values.

inputs

character vector declaring the posterior coordinates (column names such as "tau_scale" or "beta[2]") that values reads from parameters; character() for a function of data alone. Required with values and supported only with it. Declared inputs are the dependencies of the source in JAGS_deterministic_nodes(), and values receives only these coordinates: reading any other parameter, or evaluating draws that lack a declared input, stops with an error.

source

JAGS node name or parameter_source() object. When source is a parameter_source() object, shape must not be supplied separately; the shape is inherited from source.

Value

A list-like parameter_source object.

A list-like random_sd_source object.

Details

Access control for formula bridge/prediction callbacks only guards named lookup of forbidden formula parameters and undeclared inputs on the stamped parameters list ($ / [[ / [). It is not a sandbox: callbacks may still close over external state, and a raw node name without values remains valid whenever the corresponding posterior columns (or non-new-row fitted mapping) suffice.

A values function without inputs stops with an error of class BayesTools_missing_source_inputs (also BayesTools_parameter_source), also when a source object without declared inputs is used.