22#include " bgm_helper.h"
33#include " bgm_logp_and_grad.h"
44#include " common_helpers.h"
5+
56using namespace Rcpp ;
67
78
@@ -145,7 +146,7 @@ double log_pseudoposterior_main_effects_component (
145146 * - inclusion_indicator: Symmetric binary matrix of active pairwise effects.
146147 * - is_ordinal_variable: Indicator (1 = ordinal, 0 = Blume–Capel).
147148 * - baseline_category: Reference categories for Blume–Capel variables.
148- * - interaction_scale : Scale parameter of the Cauchy prior on interactions.
149+ * - pairwise_scale : Scale parameter of the Cauchy prior on interactions.
149150 * - pairwise_stats: Sufficient statistics for pairwise counts.
150151 * - var1, var2: Indices of the variable pair being updated.
151152 *
@@ -165,7 +166,7 @@ double log_pseudoposterior_interactions_component (
165166 const arma::imat& inclusion_indicator,
166167 const arma::uvec& is_ordinal_variable,
167168 const arma::ivec& baseline_category,
168- const double interaction_scale ,
169+ const double pairwise_scale ,
169170 const arma::imat& pairwise_stats,
170171 const int var1,
171172 const int var2
@@ -210,7 +211,7 @@ double log_pseudoposterior_interactions_component (
210211
211212 // Add Cauchy prior terms for included pairwise effects
212213 if (inclusion_indicator (var1, var2) == 1 ) {
213- log_pseudo_posterior += R::dcauchy (pairwise_effects (var1, var2), 0.0 , interaction_scale , true );
214+ log_pseudo_posterior += R::dcauchy (pairwise_effects (var1, var2), 0.0 , pairwise_scale , true );
214215 }
215216
216217 return log_pseudo_posterior;
@@ -241,7 +242,7 @@ double log_pseudoposterior_interactions_component (
241242 * - baseline_category: Reference categories for Blume–Capel variables.
242243 * - is_ordinal_variable: Indicator (1 = ordinal, 0 = Blume–Capel).
243244 * - main_alpha, main_beta: Hyperparameters for the Beta priors.
244- * - interaction_scale : Scale parameter of the Cauchy prior on interactions.
245+ * - pairwise_scale : Scale parameter of the Cauchy prior on interactions.
245246 * - pairwise_stats: Pairwise sufficient statistics.
246247 * - residual_matrix: Matrix of residual scores (persons × variables).
247248 *
@@ -265,7 +266,7 @@ double log_pseudoposterior (
265266 const arma::uvec& is_ordinal_variable,
266267 const double main_alpha,
267268 const double main_beta,
268- const double interaction_scale ,
269+ const double pairwise_scale ,
269270 const arma::imat& pairwise_stats,
270271 const arma::mat& residual_matrix
271272) {
@@ -304,7 +305,7 @@ double log_pseudoposterior (
304305
305306 double value = pairwise_effects (var1, var2);
306307 log_pseudoposterior += 2.0 * pairwise_stats (var1, var2) * value;
307- log_pseudoposterior += R::dcauchy (value, 0.0 , interaction_scale , true ); // Cauchy prior
308+ log_pseudoposterior += R::dcauchy (value, 0.0 , pairwise_scale , true ); // Cauchy prior
308309 }
309310 }
310311
@@ -371,7 +372,7 @@ double log_pseudoposterior (
371372 * - baseline_category: Reference categories for Blume–Capel variables.
372373 * - is_ordinal_variable: Indicator (1 = ordinal, 0 = Blume–Capel).
373374 * - main_alpha, main_beta: Hyperparameters for Beta priors.
374- * - interaction_scale : Scale parameter of the Cauchy prior on interactions.
375+ * - pairwise_scale : Scale parameter of the Cauchy prior on interactions.
375376 * - pairwise_stats: Sufficient statistics for pairwise effects.
376377 * - residual_matrix: Matrix of residual scores (persons × variables).
377378 *
@@ -396,7 +397,7 @@ arma::vec gradient_log_pseudoposterior (
396397 const arma::uvec& is_ordinal_variable,
397398 const double main_alpha,
398399 const double main_beta,
399- const double interaction_scale ,
400+ const double pairwise_scale ,
400401 const arma::imat& pairwise_stats,
401402 const arma::mat& residual_matrix
402403) {
@@ -551,7 +552,7 @@ arma::vec gradient_log_pseudoposterior (
551552 // ---- Gradient contribution from Cauchy prior
552553 int location = index_matrix (var1, var2);
553554 const double effect = pairwise_effects (var1, var2);
554- gradient (location) -= 2.0 * effect / (effect * effect + interaction_scale * interaction_scale );
555+ gradient (location) -= 2.0 * effect / (effect * effect + pairwise_scale * pairwise_scale );
555556 }
556557 }
557558
@@ -579,7 +580,7 @@ arma::vec gradient_log_pseudoposterior (
579580 * - baseline_category: Reference categories for Blume–Capel variables.
580581 * - is_ordinal_variable: Indicator (1 = ordinal, 0 = Blume–Capel).
581582 * - main_alpha, main_beta: Hyperparameters for Beta priors.
582- * - interaction_scale : Scale parameter of the Cauchy prior on interactions.
583+ * - pairwise_scale : Scale parameter of the Cauchy prior on interactions.
583584 * - pairwise_stats: Sufficient statistics for pairwise effects.
584585 * - residual_matrix: Matrix of residual scores (persons × variables).
585586 *
@@ -603,7 +604,7 @@ arma::vec gradient_log_pseudoposterior_active (
603604 const arma::uvec& is_ordinal_variable,
604605 const double main_alpha,
605606 const double main_beta,
606- const double interaction_scale ,
607+ const double pairwise_scale ,
607608 const arma::imat& pairwise_stats,
608609 const arma::mat& residual_matrix
609610) {
@@ -613,7 +614,7 @@ arma::vec gradient_log_pseudoposterior_active (
613614 main_effects, pairwise_effects, inclusion_indicator, observations,
614615 num_categories, counts_per_category, blume_capel_stats,
615616 baseline_category, is_ordinal_variable, main_alpha, main_beta,
616- interaction_scale , pairwise_stats, residual_matrix
617+ pairwise_scale , pairwise_stats, residual_matrix
617618 );
618619
619620 // Step 2: Extract compressed gradient (same layout as new vectorizer)
0 commit comments