| 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 |
Estimate Standardized Regression Coefficients and Generate the Corresponding Sampling Distribution Using the Monte Carlo Method
BetaMC(object, alpha = c(0.05, 0.01, 0.001), std_y = TRUE, std_x = NULL)BetaMC(object, alpha = c(0.05, 0.01, 0.001), std_y = TRUE, std_x = NULL)
object |
Object of class |
alpha |
Numeric vector.
Significance level |
std_y |
Logical.
Standardize |
std_x |
Character vector or |
By default, both and the regressors are standardized.
With std_y = FALSE, is left in its original units
();
with std_x, only the named regressors are standardized
(for example, std_x = character(0) gives ,
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
()
is derived from each randomly generated vector of parameter estimates.
Confidence intervals are generated by obtaining
percentiles corresponding to
from the generated sampling
distribution of ,
where is the significance level.
From the regression parameters
of each draw (see MC()),
the variance of the outcome and the standardized regression slopes are
where is the square root of the th diagonal
element of .
The estimates are computed from the fitted model,
the draws from each Monte Carlo
draw, and vcov is the sample covariance matrix of the draws.
The percentile interval is
,
where is the empirical distribution function of the draws.
Returns an object
of class betamc which is a list with the following elements:
Function call.
Function arguments.
Sampling distribution of
.
Sampling variance-covariance matrix of
.
Vector of estimated
.
Function used ("BetaMC").
Ivan Jacob Agaloos Pesigan
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
Other Beta Monte Carlo Functions:
DeltaRSqMC(),
DiffBetaMC(),
FSqMC(),
MC(),
MCMI(),
PCorMC(),
RSqMC(),
SCorMC(),
SCorSqMC()
# 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)# 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)
betamc
Estimated Parameter Method for an Object of Class betamc
## S3 method for class 'betamc' coef(object, ...)## S3 method for class 'betamc' coef(object, ...)
object |
Object of Class |
... |
additional arguments. |
Returns a vector of estimated parameters.
Ivan Jacob Agaloos Pesigan
# 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)# 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)
betamc
Confidence Intervals Method for an Object of Class betamc
## S3 method for class 'betamc' confint(object, parm = NULL, level = 0.95, ...)## S3 method for class 'betamc' confint(object, parm = NULL, level = 0.95, ...)
object |
Object of Class |
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. |
The confidence intervals are percentile intervals,
,
where is the empirical distribution function of the Monte
Carlo draws (type 7 quantiles).
The standard errors are the standard deviations of the draws.
Returns a matrix of confidence intervals.
Ivan Jacob Agaloos Pesigan
# 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)# 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
DeltaRSqMC(object, alpha = c(0.05, 0.01, 0.001))DeltaRSqMC(object, alpha = c(0.05, 0.01, 0.001))
object |
Object of class |
alpha |
Numeric vector.
Significance level |
The vector of improvement in R-squared
()
is derived from each randomly generated vector of parameter estimates.
Confidence intervals are generated by obtaining
percentiles corresponding to
from the generated sampling
distribution of ,
where is the significance level.
Returns an object
of class betamc which is a list with the following elements:
Function call.
Function arguments.
Sampling distribution of
.
Sampling variance-covariance matrix of
.
Vector of estimated
.
Function used ("DeltaRSqMC").
Ivan Jacob Agaloos Pesigan
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
Other Beta Monte Carlo Functions:
BetaMC(),
DiffBetaMC(),
FSqMC(),
MC(),
MCMI(),
PCorMC(),
RSqMC(),
SCorMC(),
SCorSqMC()
# 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)# 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
DiffBetaMC(object, alpha = c(0.05, 0.01, 0.001))DiffBetaMC(object, alpha = c(0.05, 0.01, 0.001))
object |
Object of class |
alpha |
Numeric vector.
Significance level |
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
from the generated sampling
distribution of differences of standardized regression slopes,
where is the significance level.
For every pair of regressors ,
the difference of the standardized regression slopes (see BetaMC()) is
computed from the fitted model for the estimate
and from each Monte Carlo draw (see MC()) for the draws.
Returns an object
of class betamc which is a list with the following elements:
Function call.
Function arguments.
Sampling distribution of differences of standardized regression slopes.
Sampling variance-covariance matrix of differences of standardized regression slopes.
Vector of estimated differences of standardized regression slopes.
Function used ("DiffBetaMC").
Ivan Jacob Agaloos Pesigan
Other Beta Monte Carlo Functions:
BetaMC(),
DeltaRSqMC(),
FSqMC(),
MC(),
MCMI(),
PCorMC(),
RSqMC(),
SCorMC(),
SCorSqMC()
# 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)# 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
FSqMC(object, alpha = c(0.05, 0.01, 0.001))FSqMC(object, alpha = c(0.05, 0.01, 0.001))
object |
Object of class |
alpha |
Numeric vector.
Significance level |
Cohen's for the whole model,
,
and the local of each regressor,
,
where is the semipartial correlation,
are derived from each randomly generated vector of parameter estimates.
Confidence intervals are generated by obtaining
percentiles corresponding to
from the generated sampling distribution,
where is the significance level.
Returns an object
of class betamc which is a list with the following elements:
Function call.
Function arguments.
Sampling distribution of
(column fsq) and the local
(one column per regressor).
Vector of estimates.
Function used ("FSqMC").
Ivan Jacob Agaloos Pesigan
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
Other Beta Monte Carlo Functions:
BetaMC(),
DeltaRSqMC(),
DiffBetaMC(),
MC(),
MCMI(),
PCorMC(),
RSqMC(),
SCorMC(),
SCorSqMC()
# 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)# 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
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 )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 )
object |
Object of class |
R |
Positive integer. Number of Monte Carlo replications. |
type |
Character string.
Sampling covariance matrix type.
Possible values are
|
g1 |
Numeric.
|
g2 |
Numeric.
|
k |
Numeric.
Constant for |
decomposition |
Character string.
Matrix decomposition of the sampling variance-covariance matrix
for the data generation.
If |
pd |
Logical.
If |
tol |
Numeric.
Tolerance used for |
fixed_x |
Logical.
If |
seed |
Integer. Seed number for reproducibility. |
Let the parameter vector of the unstandardized regression model be given by
where is the vector of regression slopes,
is the error variance,
and
is the vector of unique elements
of the covariance matrix of the regressor variables.
The empirical sampling distribution
of
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.
Returns an object
of class mc which is a list with the following elements:
Function call.
Function arguments.
Processed lm object.
Sampling variance-covariance matrix of parameter estimates.
Parameter estimates.
Sampling distribution of parameter estimates (a matrix, one draw per row).
Sampling distribution of the half-vectorization of the model-implied covariance matrix (a matrix, one draw per row).
Sampling distribution of the effect sizes (a list of matrices).
Function used ("MC").
Ivan Jacob Agaloos Pesigan
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
Other Beta Monte Carlo Functions:
BetaMC(),
DeltaRSqMC(),
DiffBetaMC(),
FSqMC(),
MCMI(),
PCorMC(),
RSqMC(),
SCorMC(),
SCorSqMC()
# 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# 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
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 )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 )
object |
Object of class |
mi |
Object of class |
R |
Positive integer. Number of Monte Carlo replications. |
type |
Character string.
Sampling covariance matrix type.
Possible values are
|
g1 |
Numeric.
|
g2 |
Numeric.
|
k |
Numeric.
Constant for |
decomposition |
Character string.
Matrix decomposition of the sampling variance-covariance matrix
for the data generation.
If |
pd |
Logical.
If |
tol |
Numeric.
Tolerance used for |
fixed_x |
Logical.
If |
seed |
Integer. Seed number for reproducibility. |
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 and
be the parameter estimates and their
sampling covariance matrix in imputed data set .
The pooled estimates and covariance matrices (Rubin's rules) are
The draws are generated from
, with the replacement sampling of MC() for a positive definite
model-implied covariance matrix.
Returns an object
of class mc which is a list with the following elements:
Function call.
Function arguments.
Processed lm object.
Sampling variance-covariance matrix of parameter estimates.
Parameter estimates.
Sampling distribution of parameter estimates (a matrix, one draw per row).
Sampling distribution of the half-vectorization of the model-implied covariance matrix (a matrix, one draw per row).
Sampling distribution of the effect sizes (a list of matrices).
Function used ("MCMI").
Ivan Jacob Agaloos Pesigan
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
Other Beta Monte Carlo Functions:
BetaMC(),
DeltaRSqMC(),
DiffBetaMC(),
FSqMC(),
MC(),
PCorMC(),
RSqMC(),
SCorMC(),
SCorSqMC()
# 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# 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
nas1982nas1982
Ratings of 46 doctoral programs in psychology in the USA with the following variables:
Program quality ratings.
Number of faculty members in the program.
Number of program graduates.
Percentage of program graduates who received support.
Percent of faculty members holding research grants.
Number of published articles attributed to program faculty member.
Percent of faculty with one or more published article.
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
PCorMC(object, alpha = c(0.05, 0.01, 0.001))PCorMC(object, alpha = c(0.05, 0.01, 0.001))
object |
Object of class |
alpha |
Numeric vector.
Significance level |
The vector of squared partial correlation coefficients
()
is derived from each randomly generated vector of parameter estimates.
Confidence intervals are generated by obtaining
percentiles corresponding to
from the generated sampling
distribution of ,
where is the significance level.
Returns an object
of class betamc which is a list with the following elements:
Function call.
Function arguments.
Sampling distribution of
.
Sampling variance-covariance matrix of
.
Vector of estimated
.
Function used ("PCorMC").
Ivan Jacob Agaloos Pesigan
Other Beta Monte Carlo Functions:
BetaMC(),
DeltaRSqMC(),
DiffBetaMC(),
FSqMC(),
MC(),
MCMI(),
RSqMC(),
SCorMC(),
SCorSqMC()
# 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)# 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)
betamc
Print Method for an Object of Class betamc
## S3 method for class 'betamc' print(x, alpha = NULL, digits = 4, ...)## S3 method for class 'betamc' print(x, alpha = NULL, digits = 4, ...)
x |
Object of Class |
alpha |
Numeric vector.
Significance level |
digits |
Digits to print. |
... |
additional arguments. |
Prints a matrix of estimates, standard errors, number of Monte Carlo replications, and confidence intervals.
Ivan Jacob Agaloos Pesigan
# 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)# 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)
mc
Print Method for an Object of Class mc
## S3 method for class 'mc' print(x, ...)## S3 method for class 'mc' print(x, ...)
x |
Object of Class |
... |
additional arguments. |
Prints the first set of simulated parameter estimates and model-implied covariance matrix.
Ivan Jacob Agaloos Pesigan
# 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)# 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
RSqMC(object, alpha = c(0.05, 0.01, 0.001))RSqMC(object, alpha = c(0.05, 0.01, 0.001))
object |
Object of class |
alpha |
Numeric vector.
Significance level |
R-squared () and
adjusted R-squared ()
are derived from each randomly generated vector of parameter estimates.
Confidence intervals are generated by obtaining
percentiles corresponding to
from the generated sampling
distribution of and ,
where is the significance level.
Returns an object
of class betamc which is a list with the following elements:
Function call.
Function arguments.
Sampling distribution of
and .
Sampling variance-covariance matrix of
and .
Vector of estimated
and .
Function used ("RSqMC").
Ivan Jacob Agaloos Pesigan
Other Beta Monte Carlo Functions:
BetaMC(),
DeltaRSqMC(),
DiffBetaMC(),
FSqMC(),
MC(),
MCMI(),
PCorMC(),
SCorMC(),
SCorSqMC()
# 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)# 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
SCorMC(object, alpha = c(0.05, 0.01, 0.001))SCorMC(object, alpha = c(0.05, 0.01, 0.001))
object |
Object of class |
alpha |
Numeric vector.
Significance level |
The vector of semipartial correlation coefficients
()
is derived from each randomly generated vector of parameter estimates.
Confidence intervals are generated by obtaining
percentiles corresponding to
from the generated sampling
distribution of ,
where is the significance level.
Returns an object
of class betamc which is a list with the following elements:
Function call.
Function arguments.
Sampling distribution of
.
Sampling variance-covariance matrix of
.
Vector of estimated
.
Function used ("SCorMC").
Ivan Jacob Agaloos Pesigan
Other Beta Monte Carlo Functions:
BetaMC(),
DeltaRSqMC(),
DiffBetaMC(),
FSqMC(),
MC(),
MCMI(),
PCorMC(),
RSqMC(),
SCorSqMC()
# 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)# 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)
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.
SCorSqMC(object, level = 0.95)SCorSqMC(object, level = 0.95)
object |
Context accepted by |
level |
Single confidence level in (0, 1). |
The semipartial correlation (see SCorMC()) is signed,
and its confidence interval may contain zero.
The interval for is the image of that interval under
squaring.
The squared interval is
if ,
if ,
and
if the signed interval contains zero.
This is not the interval of squared draws, and it is not an interval for
DeltaRSqMC().
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.
Ivan Jacob Agaloos Pesigan
Other Beta Monte Carlo Functions:
BetaMC(),
DeltaRSqMC(),
DiffBetaMC(),
FSqMC(),
MC(),
MCMI(),
PCorMC(),
RSqMC(),
SCorMC()
# 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)# 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)
betamc
Summary Method for an Object of Class betamc
## S3 method for class 'betamc' summary(object, alpha = NULL, digits = 4, ...)## S3 method for class 'betamc' summary(object, alpha = NULL, digits = 4, ...)
object |
Object of Class |
alpha |
Numeric vector.
Significance level |
digits |
Digits to print. |
... |
additional arguments. |
The confidence intervals are percentile intervals,
,
where is the empirical distribution function of the Monte
Carlo draws (type 7 quantiles).
The standard errors are the standard deviations of the draws.
Returns a matrix of estimates, standard errors, number of Monte Carlo replications, and confidence intervals.
Ivan Jacob Agaloos Pesigan
# 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)# 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)
mc
Summary Method for an Object of Class mc
## S3 method for class 'mc' summary(object, digits = 4, ...)## S3 method for class 'mc' summary(object, digits = 4, ...)
object |
Object of Class |
digits |
Digits to print. |
... |
additional arguments. |
Returns a list with the following elements:
Mean of the sampling distribution of
.
Variance of the sampling distribution of
.
Monte Carlo simulation bias.
Monte Carlo simulation root mean square error.
Location parameter used in the Monte Carlo simulation.
Scale parameter used in the Monte Carlo simulation.
Ivan Jacob Agaloos Pesigan
# 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)# 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)
betamc
Sampling Variance-Covariance Matrix Method for an Object of Class betamc
## S3 method for class 'betamc' vcov(object, ...)## S3 method for class 'betamc' vcov(object, ...)
object |
Object of Class |
... |
additional arguments. |
Returns the variance-covariance matrix of estimates.
Ivan Jacob Agaloos Pesigan
# 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)# 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)