Package 'betaMC'

Title: Monte Carlo for Regression Effect Sizes
Description: 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, Cohen's f-squared, 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.
Authors: Ivan Jacob Agaloos Pesigan [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-4818-8420>)
Maintainer: Ivan Jacob Agaloos Pesigan <[email protected]>
License: MIT + file LICENSE
Version: 1.3.5
Built: 2026-11-23 04:40:12 UTC
Source: https://github.com/jeksterslab/betaMC

Help Index


Estimate Standardized Regression Coefficients and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Description

Estimate Standardized Regression Coefficients and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Usage

BetaMC(object, alpha = c(0.05, 0.01, 0.001), std_y = TRUE, std_x = NULL)

Arguments

object

Object of class mc, that is, the output of the MC() function.

alpha

Numeric vector. Significance level α\alpha.

std_y

Logical. Standardize yy.

std_x

Character vector or NULL. Names of the regressors to standardize. NULL (default) standardizes all regressors; character(0) standardizes none.

Details

By default, both yy and the regressors are standardized. With std_y = FALSE, yy is left in its original units (bjσxjb_j \sigma_{x_j}); with std_x, only the named regressors are standardized (for example, std_x = character(0) gives bj/σyb_j / \sigma_y, and leaving a dummy variable out of std_x keeps its 0-1 contrast). The standard deviations are taken from each draw.

The vector of standardized regression coefficients (β^\boldsymbol{\hat{\beta}}) is derived from each randomly generated vector of parameter estimates. Confidence intervals are generated by obtaining percentiles corresponding to 100(1−α)%100(1 - \alpha)\% from the generated sampling distribution of β^\boldsymbol{\hat{\beta}}, where α\alpha is the significance level.

From the regression parameters θ={b,σ2,vech⁡(ΣXX)}\boldsymbol{\theta} = \left\{ \boldsymbol{b}, \sigma^{2}, \operatorname{vech} \left( \boldsymbol{\Sigma}_{\boldsymbol{X} \boldsymbol{X}} \right) \right\} of each draw (see MC()), the variance of the outcome and the standardized regression slopes are

σy2=b′ΣXXb+σ2,βj∗=bjσxjσy,\sigma^{2}_{y} = \boldsymbol{b}^{\prime} \boldsymbol{\Sigma}_{\boldsymbol{X} \boldsymbol{X}} \boldsymbol{b} + \sigma^{2}, \quad \beta^{\ast}_{j} = b_{j} \frac{\sigma_{x_{j}}}{\sigma_{y}},

where σxj\sigma_{x_{j}} is the square root of the jjth diagonal element of ΣXX\boldsymbol{\Sigma}_{\boldsymbol{X} \boldsymbol{X}}. The estimates are computed from the fitted model, the draws β^r∗\hat{\boldsymbol{\beta}}^{\ast}_{r} from each Monte Carlo draw, and vcov is the sample covariance matrix of the draws. The percentile interval is [G^−1(α/2),G^−1(1−α/2)]\left[ \hat{G}^{-1} \left( \alpha / 2 \right), \hat{G}^{-1} \left( 1 - \alpha / 2 \right) \right], where G^\hat{G} is the empirical distribution function of the draws.

Value

Returns an object of class betamc which is a list with the following elements:

call

Function call.

args

Function arguments.

thetahatstar

Sampling distribution of β^\boldsymbol{\hat{\beta}}.

vcov

Sampling variance-covariance matrix of β^\boldsymbol{\hat{\beta}}.

est

Vector of estimated β^\boldsymbol{\hat{\beta}}.

fun

Function used ("BetaMC").

Author(s)

Ivan Jacob Agaloos Pesigan

References

Dudgeon, P. (2017). Some improvements in confidence intervals for standardized regression coefficients. Psychometrika, 82(4), 928–951. doi:10.1007/s11336-017-9563-z

MacKinnon, D. P., Lockwood, C. M., & Williams, J. (2004). Confidence limits for the indirect effect: Distribution of the product and resampling methods. Multivariate Behavioral Research, 39(1), 99–128. doi:10.1207/s15327906mbr3901_4

Pesigan, I. J. A., & Cheung, S. F. (2024). Monte Carlo confidence intervals for the indirect effect with missing data. Behavior Research Methods. doi:10.3758/s13428-023-02114-4

Preacher, K. J., & Selig, J. P. (2012). Advantages of Monte Carlo confidence intervals for indirect effects. Communication Methods and Measures, 6(2), 77–98. doi:10.1080/19312458.2012.679848

See Also

Other Beta Monte Carlo Functions: DeltaRSqMC(), DiffBetaMC(), FSqMC(), MC(), MCMI(), PCorMC(), RSqMC(), SCorMC(), SCorSqMC()

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# BetaMC -------------------------------------------------------------------
out <- BetaMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
print(x = out)
summary(object = out)
coef(object = out)
vcov(object = out)
confint(object = out, level = 0.95)

Estimated Parameter Method for an Object of Class betamc

Description

Estimated Parameter Method for an Object of Class betamc

Usage

## S3 method for class 'betamc'
coef(object, ...)

Arguments

object

Object of Class betamc, that is, the output of the BetaMC(), RSqMC(), SCorMC(), DeltaRSqMC(), PCorMC(), FSqMC(), or DiffBetaMC() functions.

...

additional arguments.

Value

Returns a vector of estimated parameters.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# BetaMC -------------------------------------------------------------------
out <- BetaMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
coef(object = out)

Confidence Intervals Method for an Object of Class betamc

Description

Confidence Intervals Method for an Object of Class betamc

Usage

## S3 method for class 'betamc'
confint(object, parm = NULL, level = 0.95, ...)

Arguments

object

Object of Class betamc, that is, the output of the BetaMC(), RSqMC(), SCorMC(), DeltaRSqMC(), PCorMC(), FSqMC(), or DiffBetaMC() functions.

parm

a specification of which parameters are to be given confidence intervals, either a vector of numbers or a vector of names. If missing, all parameters are considered.

level

the confidence level required.

...

additional arguments.

Details

The confidence intervals are percentile intervals, [G^−1(α/2),G^−1(1−α/2)]\left[ \hat{G}^{-1} \left( \alpha / 2 \right), \hat{G}^{-1} \left( 1 - \alpha / 2 \right) \right], where G^\hat{G} is the empirical distribution function of the Monte Carlo draws (type 7 quantiles). The standard errors are the standard deviations of the draws.

Value

Returns a matrix of confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# BetaMC -------------------------------------------------------------------
out <- BetaMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
confint(object = out, level = 0.95)

Estimate Improvement in R-Squared and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Description

Estimate Improvement in R-Squared and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Usage

DeltaRSqMC(object, alpha = c(0.05, 0.01, 0.001))

Arguments

object

Object of class mc, that is, the output of the MC() function.

alpha

Numeric vector. Significance level α\alpha.

Details

The vector of improvement in R-squared (ΔR2\Delta R^{2}) is derived from each randomly generated vector of parameter estimates. Confidence intervals are generated by obtaining percentiles corresponding to 100(1−α)%100(1 - \alpha)\% from the generated sampling distribution of ΔR2\Delta R^{2}, where α\alpha is the significance level.

Value

Returns an object of class betamc which is a list with the following elements:

call

Function call.

args

Function arguments.

thetahatstar

Sampling distribution of ΔR2\Delta R^{2}.

vcov

Sampling variance-covariance matrix of ΔR2\Delta R^{2}.

est

Vector of estimated ΔR2\Delta R^{2}.

fun

Function used ("DeltaRSqMC").

Author(s)

Ivan Jacob Agaloos Pesigan

References

Algina, J., Keselman, H. J., & Penfield, R. D. (2007). Confidence intervals for an effect size measure in multiple linear regression. Educational and Psychological Measurement, 67(2), 207–218. doi:10.1177/0013164406292030

Algina, J., Keselman, H. J., & Penfield, R. D. (2008a). Confidence intervals for the squared multiple semipartial correlation coefficient. Journal of Modern Applied Statistical Methods, 7(1), 2–10. doi:10.22237/jmasm/1209614460

Algina, J., Keselman, H. J., & Penfield, R. D. (2008b). Note on a confidence interval for the squared semipartial correlation coefficient. Educational and Psychological Measurement, 68(5), 734–741. doi:10.1177/0013164407313371

Algina, J., Keselman, H. J., & Penfield, R. D. (2010). Confidence intervals for squared semipartial correlation coefficients: The effect of nonnormality. Educational and Psychological Measurement, 70(6), 926–940. doi:10.1177/0013164410379335

See Also

Other Beta Monte Carlo Functions: BetaMC(), DiffBetaMC(), FSqMC(), MC(), MCMI(), PCorMC(), RSqMC(), SCorMC(), SCorSqMC()

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# DeltaRSqMC ---------------------------------------------------------------
out <- DeltaRSqMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
print(x = out)
summary(object = out)
coef(object = out)
vcov(object = out)
confint(object = out, level = 0.95)

Estimate Differences of Standardized Regression Coefficients and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Description

Estimate Differences of Standardized Regression Coefficients and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Usage

DiffBetaMC(object, alpha = c(0.05, 0.01, 0.001))

Arguments

object

Object of class mc, that is, the output of the MC() function.

alpha

Numeric vector. Significance level α\alpha.

Details

The vector of differences of standardized regression slopes is derived from each randomly generated vector of parameter estimates. Confidence intervals are generated by obtaining percentiles corresponding to 100(1−α)%100(1 - \alpha)\% from the generated sampling distribution of differences of standardized regression slopes, where α\alpha is the significance level.

For every pair of regressors j<lj < l, the difference of the standardized regression slopes (see BetaMC()) is

Δβjl∗=βj∗−βl∗,\Delta \beta^{\ast}_{jl} = \beta^{\ast}_{j} - \beta^{\ast}_{l},

computed from the fitted model for the estimate and from each Monte Carlo draw (see MC()) for the draws.

Value

Returns an object of class betamc which is a list with the following elements:

call

Function call.

args

Function arguments.

thetahatstar

Sampling distribution of differences of standardized regression slopes.

vcov

Sampling variance-covariance matrix of differences of standardized regression slopes.

est

Vector of estimated differences of standardized regression slopes.

fun

Function used ("DiffBetaMC").

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other Beta Monte Carlo Functions: BetaMC(), DeltaRSqMC(), FSqMC(), MC(), MCMI(), PCorMC(), RSqMC(), SCorMC(), SCorSqMC()

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# DiffBetaMC ---------------------------------------------------------------
out <- DiffBetaMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
print(x = out)
summary(object = out)
coef(object = out)
vcov(object = out)
confint(object = out, level = 0.95)

Estimate Cohen's f-Squared and Local f-Squared and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Description

Estimate Cohen's f-Squared and Local f-Squared and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Usage

FSqMC(object, alpha = c(0.05, 0.01, 0.001))

Arguments

object

Object of class mc, that is, the output of the MC() function.

alpha

Numeric vector. Significance level α\alpha.

Details

Cohen's f2f^2 for the whole model, f2=R2/(1−R2)f^2 = R^2 / (1 - R^2), and the local f2f^2 of each regressor, fj2=srj2/(1−R2)f^2_j = sr^2_j / (1 - R^2), where srjsr_j is the semipartial correlation, are derived from each randomly generated vector of parameter estimates. Confidence intervals are generated by obtaining percentiles corresponding to 100(1−α)%100(1 - \alpha)\% from the generated sampling distribution, where α\alpha is the significance level.

Value

Returns an object of class betamc which is a list with the following elements:

call

Function call.

args

Function arguments.

thetahatstar

Sampling distribution of f2f^2 (column fsq) and the local f2f^2 (one column per regressor).

est

Vector of estimates.

fun

Function used ("FSqMC").

Author(s)

Ivan Jacob Agaloos Pesigan

References

Selya, A. S., Rose, J. S., Dierker, L. C., Hedeker, D., & Mermelstein, R. J. (2012). A practical guide to calculating Cohen's f2, a measure of local effect size, from PROC MIXED. Frontiers in Psychology, 3, 111. doi:10.3389/fpsyg.2012.00111

See Also

Other Beta Monte Carlo Functions: BetaMC(), DeltaRSqMC(), DiffBetaMC(), MC(), MCMI(), PCorMC(), RSqMC(), SCorMC(), SCorSqMC()

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# FSqMC -----------------------------------------------------------------
out <- FSqMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
print(x = out)
summary(object = out)
coef(object = out)
vcov(object = out)
confint(object = out, level = 0.95)

Generate the Sampling Distribution of Regression Parameters Using the Monte Carlo Method

Description

Generate the Sampling Distribution of Regression Parameters Using the Monte Carlo Method

Usage

MC(
  object,
  R = 20000L,
  type = "hc3",
  g1 = 1,
  g2 = 1.5,
  k = 0.7,
  decomposition = "eigen",
  pd = TRUE,
  tol = 1e-06,
  fixed_x = FALSE,
  seed = NULL
)

Arguments

object

Object of class lm.

R

Positive integer. Number of Monte Carlo replications.

type

Character string. Sampling covariance matrix type. Possible values are "mvn", "adf", "hc0", "hc1", "hc2", "hc3", "hc4", "hc4m", and "hc5". type = "mvn" uses the normal-theory sampling covariance matrix. type = "adf" uses the asymptotic distribution-free sampling covariance matrix. type = "hc0" through "hc5" uses different versions of heteroskedasticity-consistent sampling covariance matrix.

g1

Numeric. g1 value for type = "hc4m".

g2

Numeric. g2 value for type = "hc4m".

k

Numeric. Constant for type = "hc5"

decomposition

Character string. Matrix decomposition of the sampling variance-covariance matrix for the data generation. If decomposition = "chol", use Cholesky decomposition. If decomposition = "eigen", use eigenvalue decomposition. If decomposition = "svd", use singular value decomposition.

pd

Logical. If pd = TRUE, check if the sampling variance-covariance matrix is positive definite using tol.

tol

Numeric. Tolerance used for pd.

fixed_x

Logical. If fixed_x = TRUE, treat the regressors as fixed. If fixed_x = FALSE, treat the regressors as random.

seed

Integer. Seed number for reproducibility.

Details

Let the parameter vector of the unstandardized regression model be given by

θ={b,σ2,vech⁡(ΣXX)}\boldsymbol{\theta} = \left\{ \boldsymbol{b}, \sigma^{2}, \operatorname{vech} \left( \boldsymbol{\Sigma}_{\boldsymbol{X}\boldsymbol{X}} \right) \right\}

where b\boldsymbol{b} is the vector of regression slopes, σ2\sigma^{2} is the error variance, and vech⁡(ΣXX)\operatorname{vech} \left( \boldsymbol{\Sigma}_{\boldsymbol{X}\boldsymbol{X}} \right) is the vector of unique elements of the covariance matrix of the regressor variables. The empirical sampling distribution of θ\boldsymbol{\theta} is generated using the Monte Carlo method, that is, random values of parameter estimates are sampled from the multivariate normal distribution using the estimated parameter vector as the mean vector and the specified sampling covariance matrix using the type argument as the covariance matrix. A replacement sampling approach is implemented to ensure that the model-implied covariance matrix is positive definite.

Value

Returns an object of class mc which is a list with the following elements:

call

Function call.

args

Function arguments.

lm_process

Processed lm object.

scale

Sampling variance-covariance matrix of parameter estimates.

location

Parameter estimates.

thetahatstar

Sampling distribution of parameter estimates (a matrix, one draw per row).

vechsigmacap

Sampling distribution of the half-vectorization of the model-implied covariance matrix (a matrix, one draw per row).

es

Sampling distribution of the effect sizes (a list of matrices).

fun

Function used ("MC").

Author(s)

Ivan Jacob Agaloos Pesigan

References

Dudgeon, P. (2017). Some improvements in confidence intervals for standardized regression coefficients. Psychometrika, 82(4), 928–951. doi:10.1007/s11336-017-9563-z

MacKinnon, D. P., Lockwood, C. M., & Williams, J. (2004). Confidence limits for the indirect effect: Distribution of the product and resampling methods. Multivariate Behavioral Research, 39(1), 99–128. doi:10.1207/s15327906mbr3901_4

Pesigan, I. J. A., & Cheung, S. F. (2024). Monte Carlo confidence intervals for the indirect effect with missing data. Behavior Research Methods. doi:10.3758/s13428-023-02114-4

Preacher, K. J., & Selig, J. P. (2012). Advantages of Monte Carlo confidence intervals for indirect effects. Communication Methods and Measures, 6(2), 77–98. doi:10.1080/19312458.2012.679848

See Also

Other Beta Monte Carlo Functions: BetaMC(), DeltaRSqMC(), DiffBetaMC(), FSqMC(), MCMI(), PCorMC(), RSqMC(), SCorMC(), SCorSqMC()

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)
mc
# The `mc` object can be passed as the first argument
# to the following functions
#   - BetaMC
#   - DeltaRSqMC
#   - DiffBetaMC
#   - FSqMC
#   - PCorMC
#   - RSqMC
#   - SCorMC
#   - SCorSqMC

Generate the Sampling Distribution of Regression Parameters Using the Monte Carlo Method for Data with Missing Values

Description

Generate the Sampling Distribution of Regression Parameters Using the Monte Carlo Method for Data with Missing Values

Usage

MCMI(
  object,
  mi,
  R = 20000L,
  type = "hc3",
  g1 = 1,
  g2 = 1.5,
  k = 0.7,
  decomposition = "eigen",
  pd = TRUE,
  tol = 1e-06,
  fixed_x = FALSE,
  seed = NULL
)

Arguments

object

Object of class lm.

mi

Object of class mids (output of mice::mice()), object of class amelia (output of Amelia::amelia()), or a list of multiply imputed data sets.

R

Positive integer. Number of Monte Carlo replications.

type

Character string. Sampling covariance matrix type. Possible values are "mvn", "adf", "hc0", "hc1", "hc2", "hc3", "hc4", "hc4m", and "hc5". type = "mvn" uses the normal-theory sampling covariance matrix. type = "adf" uses the asymptotic distribution-free sampling covariance matrix. type = "hc0" through "hc5" uses different versions of heteroskedasticity-consistent sampling covariance matrix.

g1

Numeric. g1 value for type = "hc4m".

g2

Numeric. g2 value for type = "hc4m".

k

Numeric. Constant for type = "hc5"

decomposition

Character string. Matrix decomposition of the sampling variance-covariance matrix for the data generation. If decomposition = "chol", use Cholesky decomposition. If decomposition = "eigen", use eigenvalue decomposition. If decomposition = "svd", use singular value decomposition.

pd

Logical. If pd = TRUE, check if the sampling variance-covariance matrix is positive definite using tol.

tol

Numeric. Tolerance used for pd.

fixed_x

Logical. If fixed_x = TRUE, treat the regressors as fixed. If fixed_x = FALSE, treat the regressors as random.

seed

Integer. Seed number for reproducibility.

Details

Multiple imputation is used to deal with missing values in a data set. The vector of parameter estimates and the corresponding sampling covariance matrix are estimated for each of the imputed data sets. Results are combined to arrive at the pooled vector of parameter estimates and the corresponding sampling covariance matrix. The pooled estimates are then used to generate the sampling distribution of regression parameters. See MC() for more details on the Monte Carlo method.

Let θ^m\hat{\boldsymbol{\theta}}_{m} and V^m\hat{\boldsymbol{V}}_{m} be the parameter estimates and their sampling covariance matrix in imputed data set m=1,…,Mm = 1, \dots, M. The pooled estimates and covariance matrices (Rubin's rules) are

θˉ=1M∑m=1Mθ^m,Wˉ=1M∑m=1MV^m,B=1M−1∑m=1M(θ^m−θˉ)(θ^m−θˉ)′,\bar{\boldsymbol{\theta}} = \frac{1}{M} \sum_{m = 1}^{M} \hat{\boldsymbol{\theta}}_{m}, \quad \bar{\boldsymbol{W}} = \frac{1}{M} \sum_{m = 1}^{M} \hat{\boldsymbol{V}}_{m}, \quad \boldsymbol{B} = \frac{1}{M - 1} \sum_{m = 1}^{M} \left( \hat{\boldsymbol{\theta}}_{m} - \bar{\boldsymbol{\theta}} \right) \left( \hat{\boldsymbol{\theta}}_{m} - \bar{\boldsymbol{\theta}} \right)^{\prime},

T=Wˉ+(1+1M)B.\boldsymbol{T} = \bar{\boldsymbol{W}} + \left( 1 + \frac{1}{M} \right) \boldsymbol{B}.

The draws are generated from N(θˉ,T)\mathcal{N} \left( \bar{\boldsymbol{\theta}}, \boldsymbol{T} \right), with the replacement sampling of MC() for a positive definite model-implied covariance matrix.

Value

Returns an object of class mc which is a list with the following elements:

call

Function call.

args

Function arguments.

lm_process

Processed lm object.

scale

Sampling variance-covariance matrix of parameter estimates.

location

Parameter estimates.

thetahatstar

Sampling distribution of parameter estimates (a matrix, one draw per row).

vechsigmacap

Sampling distribution of the half-vectorization of the model-implied covariance matrix (a matrix, one draw per row).

es

Sampling distribution of the effect sizes (a list of matrices).

fun

Function used ("MCMI").

Author(s)

Ivan Jacob Agaloos Pesigan

References

Dudgeon, P. (2017). Some improvements in confidence intervals for standardized regression coefficients. Psychometrika, 82(4), 928–951. doi:10.1007/s11336-017-9563-z

MacKinnon, D. P., Lockwood, C. M., & Williams, J. (2004). Confidence limits for the indirect effect: Distribution of the product and resampling methods. Multivariate Behavioral Research, 39(1), 99–128. doi:10.1207/s15327906mbr3901_4

Pesigan, I. J. A., & Cheung, S. F. (2024). Monte Carlo confidence intervals for the indirect effect with missing data. Behavior Research Methods. doi:10.3758/s13428-023-02114-4

Preacher, K. J., & Selig, J. P. (2012). Advantages of Monte Carlo confidence intervals for indirect effects. Communication Methods and Measures, 6(2), 77–98. doi:10.1080/19312458.2012.679848

See Also

Other Beta Monte Carlo Functions: BetaMC(), DeltaRSqMC(), DiffBetaMC(), FSqMC(), MC(), PCorMC(), RSqMC(), SCorMC(), SCorSqMC()

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")
# data set with missing values
nas1982_missing <- mice::ampute(data = nas1982)$amp

# Multiple Imputation
mi <- mice::mice(data = nas1982_missing, m = 5, seed = 42, print = FALSE)

# Fit Model in lm ----------------------------------------------------------
## Note that this does not deal with missing values.
## The fitted model (`object`) is updated with each imputed data
## within the `MCMI()` function.
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982_missing
)

# Monte Carlo --------------------------------------------------------------
mc <- MCMI(
  object = object,
  mi = mi,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)
mc
# The `mc` object can be passed as the first argument
# to the following functions
#   - BetaMC
#   - DeltaRSqMC
#   - DiffBetaMC
#   - FSqMC
#   - PCorMC
#   - RSqMC
#   - SCorMC
#   - SCorSqMC

1982 National Academy of Sciences Doctoral Programs Data

Description

1982 National Academy of Sciences Doctoral Programs Data

Usage

nas1982

Format

Ratings of 46 doctoral programs in psychology in the USA with the following variables:

QUALITY

Program quality ratings.

NFACUL

Number of faculty members in the program.

NGRADS

Number of program graduates.

PCTSUPP

Percentage of program graduates who received support.

PCTGRT

Percent of faculty members holding research grants.

NARTIC

Number of published articles attributed to program faculty member.

PCTPUB

Percent of faculty with one or more published article.

References

National Research Council. (1982). An assessment of research-doctorate programs in the United States: Social and behavioral sciences. doi:10.17226/9781. Reproduced with permission from the National Academy of Sciences, Courtesy of the National Academies Press, Washington, D.C.


Estimate Squared Partial Correlation Coefficients and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Description

Estimate Squared Partial Correlation Coefficients and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Usage

PCorMC(object, alpha = c(0.05, 0.01, 0.001))

Arguments

object

Object of class mc, that is, the output of the MC() function.

alpha

Numeric vector. Significance level α\alpha.

Details

The vector of squared partial correlation coefficients (rp2r^{2}_{p}) is derived from each randomly generated vector of parameter estimates. Confidence intervals are generated by obtaining percentiles corresponding to 100(1−α)%100(1 - \alpha)\% from the generated sampling distribution of rp2r^{2}_{p}, where α\alpha is the significance level.

Value

Returns an object of class betamc which is a list with the following elements:

call

Function call.

args

Function arguments.

thetahatstar

Sampling distribution of rp2r^{2}_{p}.

vcov

Sampling variance-covariance matrix of rp2r^{2}_{p}.

est

Vector of estimated rp2r^{2}_{p}.

fun

Function used ("PCorMC").

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other Beta Monte Carlo Functions: BetaMC(), DeltaRSqMC(), DiffBetaMC(), FSqMC(), MC(), MCMI(), RSqMC(), SCorMC(), SCorSqMC()

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# PCorMC -------------------------------------------------------------------
out <- PCorMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
print(x = out)
summary(object = out)
coef(object = out)
vcov(object = out)
confint(object = out, level = 0.95)

Print Method for an Object of Class betamc

Description

Print Method for an Object of Class betamc

Usage

## S3 method for class 'betamc'
print(x, alpha = NULL, digits = 4, ...)

Arguments

x

Object of Class betamc, that is, the output of the BetaMC(), RSqMC(), SCorMC(), DeltaRSqMC(), PCorMC(), FSqMC(), or DiffBetaMC() functions.

alpha

Numeric vector. Significance level α\alpha. If alpha = NULL, use the argument alpha used in x.

digits

Digits to print.

...

additional arguments.

Value

Prints a matrix of estimates, standard errors, number of Monte Carlo replications, and confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# BetaMC -------------------------------------------------------------------
out <- BetaMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
print(x = out)

Print Method for an Object of Class mc

Description

Print Method for an Object of Class mc

Usage

## S3 method for class 'mc'
print(x, ...)

Arguments

x

Object of Class mc.

...

additional arguments.

Value

Prints the first set of simulated parameter estimates and model-implied covariance matrix.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(object = object, R = 100)

## Methods -----------------------------------------------------------------
print(x = mc)

Estimate R-Squared and Adjusted R-Squared and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Description

Estimate R-Squared and Adjusted R-Squared and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Usage

RSqMC(object, alpha = c(0.05, 0.01, 0.001))

Arguments

object

Object of class mc, that is, the output of the MC() function.

alpha

Numeric vector. Significance level α\alpha.

Details

R-squared (R2R^{2}) and adjusted R-squared (Rˉ2\bar{R}^{2}) are derived from each randomly generated vector of parameter estimates. Confidence intervals are generated by obtaining percentiles corresponding to 100(1−α)%100(1 - \alpha)\% from the generated sampling distribution of R2R^{2} and Rˉ2\bar{R}^{2}, where α\alpha is the significance level.

Value

Returns an object of class betamc which is a list with the following elements:

call

Function call.

args

Function arguments.

thetahatstar

Sampling distribution of R2R^{2} and Rˉ2\bar{R}^{2}.

vcov

Sampling variance-covariance matrix of R2R^{2} and Rˉ2\bar{R}^{2}.

est

Vector of estimated R2R^{2} and Rˉ2\bar{R}^{2}.

fun

Function used ("RSqMC").

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other Beta Monte Carlo Functions: BetaMC(), DeltaRSqMC(), DiffBetaMC(), FSqMC(), MC(), MCMI(), PCorMC(), SCorMC(), SCorSqMC()

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# RSqMC --------------------------------------------------------------------
out <- RSqMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
print(x = out)
summary(object = out)
coef(object = out)
vcov(object = out)
confint(object = out, level = 0.95)

Estimate Semipartial Correlation Coefficients and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Description

Estimate Semipartial Correlation Coefficients and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method

Usage

SCorMC(object, alpha = c(0.05, 0.01, 0.001))

Arguments

object

Object of class mc, that is, the output of the MC() function.

alpha

Numeric vector. Significance level α\alpha.

Details

The vector of semipartial correlation coefficients (rsr_{s}) is derived from each randomly generated vector of parameter estimates. Confidence intervals are generated by obtaining percentiles corresponding to 100(1−α)%100(1 - \alpha)\% from the generated sampling distribution of rsr_{s}, where α\alpha is the significance level.

Value

Returns an object of class betamc which is a list with the following elements:

call

Function call.

args

Function arguments.

thetahatstar

Sampling distribution of rsr_{s}.

vcov

Sampling variance-covariance matrix of rsr_{s}.

est

Vector of estimated rsr_{s}.

fun

Function used ("SCorMC").

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other Beta Monte Carlo Functions: BetaMC(), DeltaRSqMC(), DiffBetaMC(), FSqMC(), MC(), MCMI(), PCorMC(), RSqMC(), SCorSqMC()

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# SCorMC -------------------------------------------------------------------
out <- SCorMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
print(x = out)
summary(object = out)
coef(object = out)
vcov(object = out)
confint(object = out, level = 0.95)

Estimate Squared Semipartial Correlation Coefficients and the Corresponding Confidence Intervals From the Signed Intervals

Description

Square the signed interval as a set, with lower limit zero if it contains zero. This differs from an interval of squared draws. No draws are generated and no endpoints are clipped to one. Failed signed endpoints remain missing.

Usage

SCorSqMC(object, level = 0.95)

Arguments

object

Context accepted by SCorMC().

level

Single confidence level in (0, 1).

Details

The semipartial correlation srjsr_{j} (see SCorMC()) is signed, and its confidence interval [l,u]\left[ l, u \right] may contain zero. The interval for srj2sr^{2}_{j} is the image of that interval under squaring. The squared interval is [l2,u2]\left[ l^{2}, u^{2} \right] if 0<l0 < l, [u2,l2]\left[ u^{2}, l^{2} \right] if u<0u < 0, and [0,max⁡(l2,u2)]\left[ 0, \max \left( l^{2}, u^{2} \right) \right] if the signed interval contains zero. This is not the interval of squared draws, and it is not an interval for DeltaRSqMC().

Value

Data frame with est, lower and upper columns and predictor row names. The point estimate is the squared signed estimate. No standard error is implied by this interval transformation.

Author(s)

Ivan Jacob Agaloos Pesigan

See Also

Other Beta Monte Carlo Functions: BetaMC(), DeltaRSqMC(), DiffBetaMC(), FSqMC(), MC(), MCMI(), PCorMC(), RSqMC(), SCorMC()

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# SCorSqMC -----------------------------------------------------------------
SCorSqMC(object = mc, level = 0.95)

Summary Method for an Object of Class betamc

Description

Summary Method for an Object of Class betamc

Usage

## S3 method for class 'betamc'
summary(object, alpha = NULL, digits = 4, ...)

Arguments

object

Object of Class betamc, that is, the output of the BetaMC(), RSqMC(), SCorMC(), DeltaRSqMC(), PCorMC(), FSqMC(), or DiffBetaMC() functions.

alpha

Numeric vector. Significance level α\alpha. If alpha = NULL, use the argument alpha used in object.

digits

Digits to print.

...

additional arguments.

Details

The confidence intervals are percentile intervals, [G^−1(α/2),G^−1(1−α/2)]\left[ \hat{G}^{-1} \left( \alpha / 2 \right), \hat{G}^{-1} \left( 1 - \alpha / 2 \right) \right], where G^\hat{G} is the empirical distribution function of the Monte Carlo draws (type 7 quantiles). The standard errors are the standard deviations of the draws.

Value

Returns a matrix of estimates, standard errors, number of Monte Carlo replications, and confidence intervals.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# BetaMC -------------------------------------------------------------------
out <- BetaMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
summary(object = out)

Summary Method for an Object of Class mc

Description

Summary Method for an Object of Class mc

Usage

## S3 method for class 'mc'
summary(object, digits = 4, ...)

Arguments

object

Object of Class mc, that is, the output of the MC() function.

digits

Digits to print.

...

additional arguments.

Value

Returns a list with the following elements:

mean

Mean of the sampling distribution of θ^\boldsymbol{\hat{\theta}}.

var

Variance of the sampling distribution of θ^\boldsymbol{\hat{\theta}}.

bias

Monte Carlo simulation bias.

rmse

Monte Carlo simulation root mean square error.

location

Location parameter used in the Monte Carlo simulation.

scale

Scale parameter used in the Monte Carlo simulation.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(object = object, R = 100)

## Methods -----------------------------------------------------------------
summary(object = mc)

Sampling Variance-Covariance Matrix Method for an Object of Class betamc

Description

Sampling Variance-Covariance Matrix Method for an Object of Class betamc

Usage

## S3 method for class 'betamc'
vcov(object, ...)

Arguments

object

Object of Class betamc, that is, the output of the BetaMC(), RSqMC(), SCorMC(), DeltaRSqMC(), PCorMC(), FSqMC(), or DiffBetaMC() functions.

...

additional arguments.

Value

Returns the variance-covariance matrix of estimates.

Author(s)

Ivan Jacob Agaloos Pesigan

Examples

# Data ---------------------------------------------------------------------
data("nas1982", package = "betaMC")

# Fit Model in lm ----------------------------------------------------------
object <- stats::lm(
  formula = QUALITY ~ NARTIC + PCTGRT + PCTSUPP,
  data = nas1982
)

# MC -----------------------------------------------------------------------
mc <- MC(
  object = object,
  R = 100, # use a large value e.g., 20000L for actual research
  seed = 0508
)

# BetaMC -------------------------------------------------------------------
out <- BetaMC(object = mc, alpha = 0.05)

## Methods -----------------------------------------------------------------
vcov(object = out)