You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#' \item \strong{Beta–Bernoulli}: inclusion probability given a Beta prior.
48
45
#' }
49
46
#'
50
-
#' @section Variable Selection:
51
-
#' Bayesian variable selection enables testing of parameter differences or equivalence across groups. Independent spike-and-slab priors are applied to difference parameters:
47
+
#' @section Sampling Algorithms and Warmup:
48
+
#' Parameters are updated within a Gibbs framework, using the same
49
+
#' sampling algorithms and staged warmup scheme described in
50
+
#' \code{\link{bgm}}:
52
51
#' \itemize{
53
-
#' \item \strong{Bernoulli Model}: Assigns a fixed probability to parameter inclusion.
54
-
#' \item \strong{Beta-Bernoulli Model}: Incorporates a beta prior to model inclusion probabilities.
#' \code{posterior_mean_pairwise_baseline}: posterior mean matrices
137
+
#' (legacy style).
138
+
#' \item \code{raw_samples}: list of raw draws per chain for main,
139
+
#' pairwise, and indicator parameters.
140
+
#' \item \code{arguments}: list of function call arguments and metadata.
64
141
#' }
65
-
#' This warmup strategy improves stability of adaptive Metropolis-Hastings proposals and starting values.
66
142
#'
67
-
#' @section Saving Options:
68
-
#' Users can store sampled states for parameters (\code{main_effects}, \code{pairwise_effects}, \code{indicator}) during Gibbs sampling. Enabling these options (\code{save_main}, \code{save_pairwise}, \code{save_indicator}) increases output size and memory usage, so use them judiciously.
143
+
#' The \code{summary()} method prints formatted summaries,
144
+
#' \code{coef()} extracts posterior means, and \code{as_draws()} converts
145
+
#' raw samples to a \pkg{posterior} \code{draws_df}.
69
146
#'
70
-
#' @param x Data frame or matrix with binary and ordinal responses. Regular ordinal variables should be coded as integers starting from 0. Missing categories are collapsed for regular ordinal variables but retained for Blume-Capel variables.
71
-
#' @param y A data frame or matrix similar to \code{x}, used for two-group designs. \code{x} contains Group 1 data, and \code{y} contains Group 2 data. Ignored for multi-group designs.
72
-
#' @param g Group membership vector for rows in \code{x}. Required for multi-group designs; ignored if \code{y} is provided.
73
-
#' @param difference_selection Logical. If \code{TRUE}, the function models the inclusion or exclusion of parameter differences. Default: \code{TRUE}.
74
-
#' @param save_main,save_pairwise,save_indicator Logical. Enable saving sampled states for \code{main_effects}, \code{pairwise_effects}, and \code{indicator}, respectively. Default: \code{FALSE}.
75
-
#' @param main_difference_model Character. Specifies how to handle threshold differences when categories are unmatched. Options: \code{"Collapse"}, \code{"Free"}. The option "Collapse" collapses categories unobserved in one or more groups. The option "Free" option estimates thresholds separately for each group and does not model their difference. Default: \code{"Free"}.
76
-
#' @param variable_type Character or vector. Specifies the type of variables in \code{x} (\code{"ordinal"} or \code{"blume-capel"}). Default: \code{"ordinal"}.
77
-
#' @param reference_category Integer or vector. Reference category for Blume-Capel variables. Required if there is at least one Blume-Capel variable.
78
-
#' @param pairwise_difference_scale Double. Scale parameter for the Cauchy prior on pairwise differences. Default: \code{1}.
79
-
#' @param main_difference_scale Double. Scale parameter for the Cauchy prior on threshold differences. Default: \code{1}.
80
-
#' @param pairwise_difference_prior,main_difference_prior Character. Specifies the inclusion probability model (\code{"Bernoulli"} or \code{"Beta-Bernoulli"}). Default: \code{"Bernoulli"}.
81
-
#' @param pairwise_difference_probability A numeric value or a \eqn{p \times p} matrix specifying the prior inclusion probability of a pairwise difference in the Bernoulli model. A single value applies the same probability to all pairs, while a matrix allows for edge-specific probabilities. Default: 0.5 for equal prior probability for inclusion and exclusion.
82
-
#' @param main_difference_probability A numeric value or a length-\eqn{p} vector specifying the prior inclusion probability of a threshold difference in the Bernoulli model. A single value applies the same probability to all variables, while a vector allows for variable-specific probabilities. Default: 0.5 to indicate no prior preference.
83
-
#' @param iter,warmup Integer. Number of Gibbs iterations (\code{iter}) and burn-in iterations (\code{warmup}). Defaults: \code{iter = 1e4}, \code{warmup = 1e3}.
84
-
#' @param na_action Character. Specifies handling of missing data. \code{"listwise"} deletes rows with missing values; \code{"impute"} imputes values during Gibbs sampling. Default: \code{"listwise"}.
85
-
#' @param display_progress Logical. Show progress bar during computation. Default: \code{TRUE}.
86
-
#' @param main_alpha,main_beta Double. Shape parameters for the beta-prime prior on nuisance threshold parameters.
87
-
#' @param pairwise_scale Double. Scale of the Cauchy prior for nuisance pairwise interactions. Default: \code{2.5}.
88
-
#' @param main_beta_bernoulli_alpha,main_beta_bernoulli_beta Double. Shape parameters for the Beta-Bernoulli prior on threshold differences.
89
-
#' @param pairwise_beta_bernoulli_alpha,pairwise_beta_bernoulli_beta Double. Shape parameters for the Beta-Bernoulli prior on pairwise differences.
90
-
#' @param save Logical. If true, sampled states for all parameters are returned. Deprecated.
91
-
#' @param save_main,save_pairwise,save_indicator Logical. Enable saving sampled states for `main_effects`, `pairwise_effects`, and `indicator`, respectively. Default: `FALSE`.
147
+
#' NUTS diagnostics (tree depth, divergences, energy, E-BFMI) are included
148
+
#' in \code{fit$nuts_diag} if \code{update_method = "nuts"}.
92
149
#'
93
-
#' @return A list containing the posterior means and, optionally, sampled states based on the \code{save_*} options. The returned components include:
94
-
#' \itemize{
95
-
#' \item \code{posterior_mean_main}, \code{posterior_mean_pairwise}, and \code{posterior_mean_indicator} for posterior means.
96
-
#' \item If saving options are enabled, the list also includes:
97
-
#' \itemize{
98
-
#' \item \code{raw_samples_main} – sampled states of main effects.
99
-
#' \item \code{raw_samples_pairwise} – sampled states of pairwise effects.
100
-
#' \item \code{raw_samples_indicator} – sampled states of inclusion indicators.
101
-
#' }
150
+
#' @references
151
+
#' \insertAllCited{}
152
+
#'
153
+
#' @examples
154
+
#' \dontrun{
155
+
#' # Run bgmCompare on subset of the Boredom dataset
156
+
#' x = Boredom[Boredom$language == "fr", 2:6]
157
+
#' y = Boredom[Boredom$language != "fr", 2:6]
158
+
#'
159
+
#' fit <- bgmCompare(x, y)
160
+
#'
161
+
#' # Posterior inclusion probabilities
162
+
#' summary(fit)$indicator
163
+
#'
164
+
#' # Bayesian model averaged main effects for the groups
165
+
#' coef(fit)$main_effects_groups
166
+
#'
167
+
#' # Bayesian model averaged pairwise effects for the groups
168
+
#' coef(fit)$pairwise_effects_groups
102
169
#' }
103
-
#' In addition to the results of the analysis, the output lists some of the
104
-
#' arguments of its call. This is useful for post-processing the results.
0 commit comments