betaMC: Monte Carlo for Regression Effect Sizes
Ivan Jacob Agaloos Pesigan
2026-11-30 05:07:44
Source:vignettes/betaMC.Rmd
betaMC.RmdDescription
Generates Monte Carlo confidence intervals for standardized
regression coefficients (beta) and other effect sizes, including
multiple correlation, semipartial correlations, improvement in
R-squared, squared partial correlations, and differences in standardized
regression coefficients, for models fitted by lm().
betaMC combines ideas from Monte Carlo confidence intervals
for the indirect effect (Pesigan and Cheung, 2024, doi:10.3758/s13428-023-02114-4)
and the sampling covariance matrix of regression coefficients (Dudgeon,
2017, doi:10.1007/s11336-017-9563-z)
to generate confidence intervals for effect sizes in regression.
Installation
You can install the CRAN release of betaMC with:
install.packages("betaMC")You can install the development version of betaMC from
GitHub with:
if (!require("pak")) install.packages("pak")
pak::pkg_install("jeksterslab/betaMC")Example
In this example, a multiple regression model is fitted using program
quality ratings (QUALITY) as the regressand/outcome
variable and number of published articles attributed to the program
faculty members (NARTIC), percent of faculty members
holding research grants (PCTGRT), and percentage of program
graduates who received support (PCTSUPP) as
regressor/predictor variables using a data set from 1982 ratings of 46
doctoral programs in psychology in the USA (National Research Council, 1982). Confidence
intervals for the standardized regression coefficients are generated
using the BetaMC() function from the betaMC
package.
library(package = betaMC)
df <- betaMC::nas1982Fit the regression model using the lm() function.
object <- stats::lm(formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP, data = df)Generate the sampling distribution of the regression parameters using the Monte Carlo method.
mc <- MC(object = object, type = "mvn", R = 20000L, seed = 0508)Estimate the standardized regression slopes and the corresponding confidence intervals.
BetaMC(object = mc, alpha = 0.05)
#> Call:
#> BetaMC(object = mc, alpha = 0.05)
#>
#> Standardized regression slopes
#> type = "mvn"
#> est se R 2.5% 97.5%
#> NARTIC 0.4951 0.0755 20000 0.3393 0.6334
#> PCTGRT 0.3915 0.0765 20000 0.2376 0.5374
#> PCTSUPP 0.2632 0.0744 20000 0.1182 0.4087Other Features
The package provides the following functions.
| Function | Purpose |
|---|---|
MC() |
Monte Carlo sampling distribution of the regression parameters
(type = "mvn", "adf", or HC0-HC5) |
MCMI() |
MC() for multiply imputed data |
BetaMC() |
Standardized regression coefficients |
RSqMC() |
R-squared and adjusted R-squared |
DiffBetaMC() |
Differences of standardized regression coefficients |
SCorMC() |
Semipartial correlations |
SCorSqMC() |
Squared semipartial correlations (squared signed interval) |
PCorMC() |
Squared partial correlations |
DeltaRSqMC() |
Improvement in R-squared |
FSqMC() |
Cohen’s f-squared and local f-squared |
The coef(), vcov(), confint(),
summary(), and print() methods are available
for the returned objects. The example above uses the normal-theory
sampling covariance matrix; the asymptotically distribution-free
(type = "adf") and heteroskedasticity-consistent
(type = "hc3" and others) matrices are chosen with the
type argument of MC(). Examples for each
function are in the package vignettes.
Effect Sizes
The definitions, formulas, and notes on the intervals are in the help pages of the functions and in the example vignettes.
Documentation
See GitHub Pages for package documentation.