Repository navigation
scmBayesPost v0.4.0
scmBayesPost v0.4.0 — Architectural overhaul
Why this exists
Versions 0.3.x introduced the Bayesian probit first stage but remained
slow because all Gibbs samplers operated on a stacked block-diagonal
design matrix X_block. On the motivating dataset with J0 = 1,879
treated units and N_obs = 292,199 observations this matrix had
157 million rows, making every matrix multiply inside the Gibbs
loop catastrophically expensive regardless of optimisation. Profiling
consistently showed %*% consuming >90% of iteration time.
What changed
X_block is never built. prepare_data_general() now returns the J0
unit-level matrices and vectors (X_list, y_list, w_list,
row_idx_list) directly. All four Gibbs samplers operate on these
lists, reducing every matrix operation inside the loop to unit-level
arithmetic. For K=1 (the standard single-treatment case) each unit's
beta update is a scalar division and a single normal draw — no matrix
operations at all.
Breaking change
gdata$X_block, gdata$Y_block, and gdata$W no longer exist.
Code accessing these directly must be updated to use gdata$X_list,
gdata$y_list, and gdata$w_list.
Expected performance
The dominant remaining cost is X_fs %*% delta — a 292k × p_fs
dense matrix-vector product for the first-stage probit, which is
unavoidable but benefits from multi-threaded BLAS. All other
operations are now unit-level and fast.
Installation
remotes::install_github("andrebonfrer/scmBayesPost@v0.4.0")