How this calculation works
A regression coefficient can look precise after one predictor set has been selected while the selection itself remains uncertain. Model averaging assigns probability to competing subsets and carries that uncertainty into the summary.
Center y and every candidate column; intercept is always included with common flat prior. For each full-rank subset M of k predictors use beta_M|sigma² ~ N(0,g sigma²(X_M^T X_M)^-1), sigma² ~ IG(a0,b0), a0,b0,g>0 and uniform subset prior. Log unnormalized model posterior = -.5*k*log1p(g) -(a0+(n-1)/2)*log(b0+.5*(SST-g/(1+g)*SSR_M)). Normalize by log-sum-exp. Include null subset; use QR for SSR. Model-conditional coefficient mean =g/(1+g) OLS; absent coefficient=0. PIP is sum of posterior masses of subsets containing predictor. State all priors rather than claiming equivalence to every BMS mode.A worked example
With the prefilled inputs, inclusionProbabilities = [0.33333333333333176]. Rows [response,predictor1,...]. Centered slopes; proper inverse-gamma variance prior and common flat intercept.
Good to know
Fixed g-prior on centered slopes; proper inverse-gamma(a0,b0) variance prior and common flat intercept prior.
Reference: Primary method reference or author-maintained documentation (opens in a new tab) ↗
What averaging changes
A regression coefficient can look precise after one predictor set has been selected while the selection itself remains uncertain. Model averaging assigns probability to competing subsets and carries that uncertainty into the summary.
Posterior inclusion probability is the combined mass of models containing a variable. It answers a model-dependent inclusion question; it does not measure the probability that changing the variable would cause an outcome change.
Compare with the Bayesian linear regression posterior calculator. Integrate over all predictor subsets and report model uncertainty, inclusion probabilities and averaged prediction; existing Bayesian regression conditions on one chosen design.
Choose priors before comparing models
Rows [response,predictor1,...]. Centered slopes; proper inverse-gamma variance prior and common flat intercept.The g parameter controls how strongly slopes shrink toward zero within each subset. A larger value spreads prior slope mass more widely and changes both the fit reward and the model-complexity penalty.
The inverse-gamma shape and scale keep the residual-variance prior proper. Reporting their values matters because two analyses with the same observations can favor different model sizes under different prior assumptions. The public design begins with twenty observations and allows up to ten candidate predictors. The first column is the response; the intercept is always present and is handled by centering both response and predictor columns. A predictor that duplicates another centered column prevents the full candidate design from being identified. Remove or combine such predictors explicitly before interpreting inclusion probabilities. Changing a predictor's units changes the reported slope units, while the corresponding g-prior covariance changes with the centered design. The prediction vector contains predictor values in exactly the same column order, without an extra intercept entry.
Prepare candidate predictors
Centering gives the intercept the same role in every model and keeps predictor inclusion focused on departures from the response mean. Supply genuinely distinct columns rather than duplicated units or exact linear combinations.
Enumerating all subsets includes the intercept-only model. A singular subset cannot receive the standard g-prior calculation because its coefficient covariance requires an invertible cross-product matrix.
How posterior weights are formed
Each subset receives a marginal-likelihood score after its slopes and residual variance have been integrated out. The score balances explained variation against the prior volume used by additional coefficients.
Scores are normalized together, so their probabilities sum to one. Calculating in logarithms prevents a collection of very small evidence values from underflowing before the comparison is made.
A small exact example
For centered observations x=(-1,0,1) and y=(-1,0,1), choose g=3 and inverse-gamma parameters a=1,b=1. The common-factor-free evidence is 0.25 for the null model and 0.32 for the slope model.
The slope model therefore has posterior probability 32/57, about 0.5614. Perfect sample alignment does not force inclusion probability to one: this tiny sample still competes with a simpler model under the stated prior.
Read coefficient summaries carefully
An averaged slope includes a point mass at zero from models where that predictor is absent. Averaging only coefficients from included models answers a different question and usually changes both the mean and uncertainty.
A variable can share its inclusion support with a highly correlated alternative. Inspect model probabilities alongside inclusion probabilities instead of interpreting a low individual value as proof that the underlying signal is irrelevant.
Check sensitivity and scope
Repeat a justified analysis across plausible prior settings rather than choosing the setting that produces the strongest inclusion claim. Keep the candidate-variable list fixed when comparing those sensitivity results.
The calculation describes Gaussian linear models with the selected priors. Nonlinear relationships, outliers, dependent errors and omitted causes require further modeling rather than additional decimal places in the posterior table. The variance prior is inverse gamma with the supplied positive shape a0 and scale b0; it is not the improper scale prior sometimes used by other packages. The inclusion-prior input assigns independent Bernoulli probabilities to candidate predictors, so it changes prior model mass when the model size changes. Compare inclusion probabilities across defensible choices of g and the inclusion prior instead of reading one posterior ranking as a definitive variable-selection result. The averaged intercept must be recovered after averaging the centered slopes. Averaged prediction is a posterior mean across models and contains neither a prediction interval nor an automatic decision threshold. Fixed g-prior on centered slopes; proper inverse-gamma(a0,b0) variance prior and common flat intercept prior.
A few questions, answered
Is inclusion probability a p-value?
No. It is posterior probability summed over the specified model space and depends on the model and coefficient priors.
Why include the empty predictor set?
It represents the intercept-only explanation and prevents the analysis from assuming in advance that at least one candidate slope is needed.
Can I enter the same predictor twice?
No. Duplicate columns make some subset cross-products singular and also count the same scientific explanation more than once.
Does g change the data?
No. It changes the prior spread and resulting shrinkage and evidence penalty; the observations remain the same.