JAGS_deterministic_nodes() lists the deterministic nodes that BayesTools generates in the JAGS model of a fit (other than the internal intermediates of random-effect blocks, which the random-effect reconstruction recomputes), with the family that defines them, the coordinates they produce, and the coordinates they are computed from. JAGS_evaluate_deterministic() recomputes their values from draws of those coordinates. JAGS_deterministic_evaluator() resolves the nodes of a fit once and returns a function that evaluates them on draws, for repeated evaluations (e.g. one draw at a time).

JAGS_deterministic_nodes(fit)

JAGS_evaluate_deterministic(fit, draws = NULL, nodes = NULL)

JAGS_deterministic_evaluator(fit, nodes = NULL)

Arguments

fit

a model fitted with JAGS_fit().

draws

draws to evaluate the nodes on: a numeric matrix with one column per coordinate (for example posterior draws with some columns replaced, or prior draws from transform_prior_samples() with formula_scale = list()), an mcmc or mcmc.list object, or a named numeric vector holding a single draw. Coordinates that have a point prior do not need a column. Defaults to the posterior draws of fit.

nodes

optional character vector of node names (the node column of JAGS_deterministic_nodes()) to evaluate. By default, every node whose dependencies are available in draws is evaluated.

Value

JAGS_deterministic_nodes() returns a data frame with one row per node and the columns node (node name), family, parameter (the formula parameter or prior name the node belongs to), block (the random-effect block, NA otherwise), coordinates and dependencies (list columns of coordinate names), and monitored (whether all coordinates of the node are monitored in fit).

JAGS_evaluate_deterministic() returns a numeric matrix with one row per draw and one column per coordinate of the evaluated nodes.

JAGS_deterministic_evaluator() returns a function with one argument, draws (in the forms accepted by JAGS_evaluate_deterministic(); a named numeric vector for one draw), that returns the matrix JAGS_evaluate_deterministic(fit, draws, nodes) returns, with the nodes of fit resolved when the evaluator is created. JAGS_evaluate_deterministic() is this evaluator applied once.

Details

Each generated node belongs to one family, which defines both the JAGS syntax of the node and the R evaluator used everywhere BayesTools needs its value (prior draws, parameter-catalog quantities, bridge sampling, marginal-likelihood parameters, prediction, marginal posteriors of formula parameters, random-effect unscaling, and convergence roles):

"random_sd"

random-effect SDs derived from a variance allocation (random_variance_allocation()): the source SD (the allocation's own SD or an external scalar SD source) times the chain of allocation factors from the root allocation, sqrt(w[i]) (total variance) or sqrt(K * w[i]) (mean variance) of the Dirichlet weights and the inclusion gates. The family also contains the parent allocation components that a child allocation splits further.

"random_rho"

scalar correlations of structured random-effect blocks sampled on the Fisher-z (rho = tanh(z)) or logit scale (rho = lower + (upper - lower) * plogis(z)).

"lkj"

the Cholesky factor L, the correlation matrix \(R = L L^T\) (with an exact unit diagonal), and the monitored partial correlations cpc = 2 u - 1 of an LKJ-Cholesky block, computed from its primitives u with the kernel of the BayesTools JAGS module.

"omega"

the publication weights of a weight-function prior (alone, as the selection of prior_bias(), or as branches of a publication-bias mixture) on the one-sided global p-value bins, with the bins of two-sided weight functions mirrored. The dependencies are the free coordinates of the weights (eta, the monitored omega[2] of a binary cumulative weight function, or the independent omega or log_omega); mixture branches are read from their own component nodes and the bias_indicator.

"phacking"

the nodes of the p-hacking branches of a prior_phacking(), prior_bias(), or publication-bias mixture prior (experimental): the form code phack_kind, the null masses pi_null = alpha * a and beta_null = alpha * b with the constants of the form, the z geometry phack_z_source and phack_z_dest, and the sel_vector_rule of the selection kernel. A publication-bias mixture composes them from its branches (zeros for a branch without p-hacking) and the bias_indicator, and adds the severity alpha composed from the component severities alpha_component_k. pi_null and beta_null are computed from the coordinate alpha, so a fit that monitors it needs no component severities.

"prior_mixture"

parameters with spike-and-slab (p = p_variable * p_indicator) or mixture priors (p = sum_k p_component_k * (p_indicator == k)), and the PET and PEESE terms of publication-bias mixtures (PET <- PET_1 * equals(bias_indicator, k)), per coefficient of factor priors. Only the components that are active in some draw need to be available; literal point components are constants. Multi-slice ordered spike totals use indexed slab sources and one shared inclusion state.

"prior_dirichlet"

the coordinates of an ordinary Dirichlet prior, theta[i] = eta[i] / sum(eta), from its gamma auxiliaries eta. The Dirichlet weights of a variance allocation belong to the allocation family.

"prior_mt"

the coordinates of a multivariate-t prior (also of an orthonormal or meandif multivariate-t factor, or of a component of a mixture), theta[i] = z[i] / sqrt(s) + location, from the normal coordinates z and the scale coordinate s. A location that is an expression leaves the node unavailable to the evaluator.

"ordered_allocation"

normalized Gamma coordinates of an ordered allocation. Gamma values take precedence over supplied normalized weights. Replay accepts nonnegative Gamma values with a positive row sum; bridge stochastic-source checks retain their positive-coordinate rule.

"ordered_coefficient"

each ordered increment from its declared total slice and factor allocations. Shared allocation keys have one node.

"point_expression"

scalar expression-valued formula point coefficients and their declared expression-point parents. Replay uses the retained location AST, owned data, and available declared parents. It replaces stale coefficient monitors before dependent formula replay. A coefficient monitor can supply a formula when its parents are absent; that coefficient is then unavailable for explicit recomputation.

"linear_predictor"

the linear predictor of a formula parameter on the fitted rows: the intercept (or its logarithm), the continuous and factor terms with their multiply_by multipliers, the expression() terms, and the contributions of the sampled random-effect blocks, evaluated with JAGS_evaluate_formula(). It is evaluated only by JAGS_evaluate_deterministic(), and only when the standardized latent effects of the sampled blocks are among the draws. A block whose SDs come from a row-shaped external source (random_sd_source(..., shape = "row")) depends on the source rows source[1], ..., source[N], or, when the source's values function reconstructs them, on the inputs that function declares (parameter_source(inputs = )), and on the Dirichlet weights and inclusion gates of its allocation.

Nodes are evaluated with the arithmetic of the R evaluator, which reproduces the JAGS monitors exactly or to the last bits of floating-point rounding. Successful parent outputs replace stale derived columns before dependent nodes are evaluated, for every family. Point coefficient replay uses the bounded formula-expression arithmetic subset, requires one finite scalar per draw, and does not bind the loop index i. Unsupported replay syntax retains valid fitting and monitored-value routes, and reports BayesTools_formula_point_unavailable when replay is requested. Missing affected declaration ownership requires refitting.