6767# ' \code{s}). Default: \code{exponential_prior(eta = 1)}; with the
6868# ' default \code{normal_prior(scale = 1)} interaction prior this
6969# ' resolves to \eqn{K_{ii}/2 \sim \textrm{Exponential}(1)}.
70- # ' @param step_size Positive numeric. Initial NUTS step size used to seed
71- # ' dual-averaging adaptation. Default \code{0.1}. Used only for
72- # ' \code{spec = "conditional"} (NUTS path); ignored for the
73- # ' \code{"joint"} MH path.
70+ # ' @param step_size `r lifecycle::badge("deprecated")` Deprecated and ignored.
71+ # ' The NUTS warmup determines its own initial step size; earlier versions
72+ # ' accepted this argument but never used it.
7473# ' @param max_depth Integer. Maximum NUTS tree depth. Default \code{10}.
7574# ' Used only for \code{spec = "conditional"}.
7675# ' @param seed Integer. RNG seed for the chain. Default \code{1L}.
8584# ' \eqn{(K, \Gamma)} jointly from the un-normalised joint prior), or
8685# ' \code{"hierarchical"} (sample \eqn{(K, \Gamma)} from the per-graph
8786# ' normalized specification via the Z-ratio approximation).
88- # ' @param edge_inclusion_prob Probability in \eqn{(0, 1)} for the
89- # ' Bernoulli edge prior used when \code{spec = "joint"}. Default
90- # ' \code{0.5}. Ignored when \code{spec = "conditional"}.
87+ # ' @param edge_inclusion_prob Probability in \eqn{(0, 1)} for the Bernoulli
88+ # ' edge prior the chain falls back to when \code{edge_prior} is
89+ # ' \code{NULL}. Default \code{0.5}. Read only when \code{spec = "joint"}
90+ # ' or \code{"hierarchical"} \emph{and} \code{edge_prior = NULL}: it is
91+ # ' ignored for \code{spec = "conditional"} (the graph is fixed) and
92+ # ' whenever an \code{edge_prior} object is supplied, including
93+ # ' \code{bernoulli_prior()}, which carries its own probability.
9194# ' @param update_method One of \code{"adaptive-metropolis"} (default) or
9295# ' \code{"gibbs"}. Sampler driving the \code{spec = "joint"} chain; the
9396# ' Gibbs chain uses the conjugate row and edge updates and needs no
97100# ' or \code{\link{sbm_prior}()}, or \code{NULL} (default) for a Bernoulli
98101# ' prior with probability \code{edge_inclusion_prob}. Only for
99102# ' \code{spec = "joint"}.
100- # ' @param apply_correction Logical. For the hierarchical edge priors
101- # ' (\code{beta_bernoulli_prior()}, \code{sbm_prior()}), apply the
102- # ' normalizing-constant correction to the hyperparameter updates (default
103- # ' \code{TRUE}; the correction table is built from the tilted prior
104- # ' sampler and cached across calls). With \code{FALSE} the plain conjugate
105- # ' updates are used, whose hyperparameter marginals do not match the
106- # ' hyperpriors under the determinant tilt.
103+ # ' @param apply_correction Logical. Apply the normalizing-constant correction
104+ # ' to the hyperparameter updates (default \code{TRUE}; the correction table
105+ # ' is built from the tilted prior sampler and cached across calls). With
106+ # ' \code{FALSE} the plain conjugate updates are used, whose hyperparameter
107+ # ' marginals do not match the hyperpriors under the determinant tilt. Read
108+ # ' only when \code{spec = "joint"} \emph{and} the edge prior is a
109+ # ' hierarchical one (\code{beta_bernoulli_prior()}, \code{sbm_prior()});
110+ # ' it is ignored for \code{spec = "conditional"} (the graph is fixed), for
111+ # ' \code{spec = "hierarchical"} (the per-edge Z-ratio carries the
112+ # ' normalizer instead, and the hyperparameter updates stay clean
113+ # ' conjugate), and for a Bernoulli edge prior (no hyperparameters to
114+ # ' correct).
107115# ' @param zratio_diagnostics Logical (default \code{TRUE}). Only for
108116# ' \code{spec = "hierarchical"}: run the trust gauge
109117# ' (\code{\link{summarize_zratio_gauge}}) on the returned chain and attach
@@ -196,7 +204,7 @@ sample_ggm_prior = function(
196204 n_warmup = 2e3 ,
197205 interaction_prior = normal_prior(scale = 1 ),
198206 precision_scale_prior = exponential_prior(eta = 1 ),
199- step_size = 0.1 ,
207+ step_size = lifecycle :: deprecated() ,
200208 max_depth = 10L ,
201209 seed = 1L ,
202210 verbose = TRUE ,
@@ -211,6 +219,15 @@ sample_ggm_prior = function(
211219) {
212220 spec = match.arg(spec )
213221 update_method = match.arg(update_method )
222+ if (lifecycle :: is_present(step_size )) {
223+ lifecycle :: deprecate_warn(
224+ " 0.2.1" , " sample_ggm_prior(step_size = )" ,
225+ details = paste0(
226+ " The NUTS warmup determines its own initial step size; the supplied " ,
227+ " value was never used."
228+ )
229+ )
230+ }
214231 ep = if (is.null(edge_prior )) {
215232 NULL
216233 } else {
@@ -235,7 +252,6 @@ sample_ggm_prior = function(
235252 validate_integer(n_samples , " n_samples" , min_value = 1L )
236253 validate_integer(n_warmup , " n_warmup" , min_value = 0L )
237254 validate_integer(max_depth , " max_depth" , min_value = 1L )
238- validate_finite_scalar(step_size , " step_size" , positive = TRUE )
239255 validate_integer(seed , " seed" , min_value = 0L )
240256 if (is.null(delta )) {
241257 delta = 0.5 * log(p )
@@ -277,7 +293,6 @@ sample_ggm_prior = function(
277293 scale_prior_type = sp $ scale_prior_type ,
278294 gamma_shape = sp $ scale_shape ,
279295 gamma_rate = sp $ scale_rate ,
280- step_size = step_size ,
281296 max_depth = as.integer(max_depth ),
282297 seed = as.integer(seed ),
283298 verbose = verbose ,
@@ -367,6 +382,16 @@ sample_ggm_prior = function(
367382 no_chains = 1L ,
368383 edge_selection = TRUE ,
369384 sampler_type = update_method ,
385+ # Same target bgm() resolves for this update method (validate_sampler()):
386+ # 0.44 is the componentwise RW MH optimum the adaptive-metropolis chain
387+ # tunes its between-model proposal SDs to, and gibbs tunes nothing. The
388+ # C++ default is 0.80, the NUTS target, so leaving this out gave the
389+ # prior chain a different proposal tuning than the deployed path this
390+ # function is the SBC reference for.
391+ target_acceptance = switch (update_method ,
392+ " adaptive-metropolis" = 0.44 ,
393+ " gibbs" = NA_real_
394+ ),
370395 seed = as.integer(seed ),
371396 no_threads = 1L ,
372397 progress_type = if (verbose ) 2L else 0L ,
@@ -545,16 +570,6 @@ validate_integer = function(x, name, min_value = 1L) {
545570 invisible (as.integer(x ))
546571}
547572
548- validate_finite_scalar = function (x , name , positive = FALSE ) {
549- if (! is.numeric(x ) || length(x ) != 1L || is.na(x ) || ! is.finite(x )) {
550- stop(sprintf(" '%s' must be a single finite numeric." , name ))
551- }
552- if (positive && x < = 0 ) {
553- stop(sprintf(" '%s' must be positive." , name ))
554- }
555- invisible (x )
556- }
557-
558573validate_ggm_prior_edge_indicators = function (edge_indicators , p ) {
559574 if (is.null(edge_indicators )) {
560575 return (NULL )
0 commit comments