Learn R Programming

stdmod: Standardized Moderation

(Version 0.2.11, updated on 2024-09-22, release history)

(Important changes since 0.2.0.0: Bootstrap confidence intervals and variance-covariance matrix of estimates are the defaults of confint() and vcov() for the output of std_selected_boot().)

This package includes functions for computing a standardized moderation effect and forming its confidence interval by nonparametric bootstrapping correctly. It was described briefly in the following publication (OSF project page). It supports moderated regression conducted by stats::lm() and path analysis with product term conducted by lavaan::lavaan().

  • Cheung, S. F., Cheung, S.-H., Lau, E. Y. Y., Hui, C. H., & Vong, W. N. (2022) Improving an old way to measure moderation effect in standardized units. Health Psychology, 41(7), 502-505. https://doi.org/10.1037/hea0001188.

More information on this package:

https://sfcheung.github.io/stdmod/

Quick Links:

  • stdmod: A quick start on how to use std_selected() and std_selected_boot(), the two main functions, to standardize selected variables in a regression model and refit the model.

  • moderation: How to use std_selected() and std_selected_boot() to compute standardized moderation effect and form its nonparametric bootstrap confidence interval.

  • std_selected: How to use std_selected() to mean center or standardize selected variables in any regression models, and use std_selected_boot() to form nonparametric bootstrap confidence intervals for standardized regression coefficients (betas in psychology literature).

  • plotmod: How to generate a typical plot of moderation effect using plotmod().

  • cond_effect: How to compute conditional effects of the predictor for selected levels of the moderator, and form nonparametric bootstrap confidence intervals these effects.

Installation

The stable CRAN version can be installed by install.packages():

install.packages("stdmod")

The latest version of this package at GitHub can be installed by remotes::install_github():

remotes::install_github("sfcheung/stdmod")

Implementation

The main function, std_selected(), accepts an lm() output, standardizes variables by users, and update the results. If interaction terms are present, they will be formed after the standardization. If bootstrap confidence intervals are requested using std_selected_boot(), both standardization and regression will be repeated in each bootstrap sample, ensuring that the sampling variability of the standardizers (e.g., the standard deviations of the selected variables), are also taken into account.

Issues

If you have any suggestions and found any bugs, please feel feel to open a GitHub issue. Thanks.

Copy Link

Version

Install

install.packages('stdmod')

Monthly Downloads

539

Version

0.2.11

License

GPL-3

Maintainer

Shu Fai Cheung

Last Published

September 22nd, 2024

Functions in stdmod (0.2.11)

stdmod-package

stdmod: Standardized Moderation Effect and Its Confidence Interval
stdmod_lavaan

Standardized Moderation Effect and Its Bootstrap CI in 'lavaan'
summary.std_selected

Summary Method for a 'std_selected' Class Object
print.summary.std_selected

Print the Summary of a 'std_selected' Class Object
print.stdmod_lavaan

Print a 'stdmod_lavaan' Class Object
std_selected

Standardize Variables in a Regression Model
sleep_emo_con

Sample Dataset: Predicting Sleep Duration
test_mod2

Sample Dataset: A Path Model With A Moderator
test_mod1

Sample Dataset: A Path Model With A Moderator
stdmod

Standardized Moderation Effect Given an 'lm' Output
update.std_selected

The 'update' Method for a 'std_selected' Class Object
test_x_1_w_1_v_1_cat1_xw_cov_n_500

Sample Dataset: One IV, One Moderator, Two Covariates
test_x_1_w_1_v_1_cat1_xw_cov_wcat3_n_500

Sample Dataset: One IV, One 3-Category Moderator, Two Covariates
test_x_1_w_1_v_2_n_500

Sample Dataset: One IV, One Moderator, Two Covariates
test_mod3_miss

Sample Dataset: A Path Model With A Moderator
vcov.std_selected

The 'vcov' Method for a 'std_selected' Class Object
test_x_1_w_1_v_1_cat1_n_500

Sample Dataset: One IV, One Moderator, Two Covariates
coef.stdmod_lavaan

Standardized Moderation Effect in a 'stdmod_lavaan' Class Object
cond_effect

Conditional Effects
add1.std_selected

The 'add1' Method for a 'std_selected' Class Object
confint.stdmod_lavaan

Confidence Intervals for a 'stdmod_lavaan' Class Object
coef.cond_effect

Conditional Effect in a 'cond_effect'-Class Object
plotmod

Moderation Effect Plot
print.cond_effect

Print a 'cond_effect' Class Object
confint.cond_effect

Confidence Intervals for a 'cond_effect' Class Object
confint.std_selected

Confidence Intervals for a 'std_selected' Class Object
print.std_selected

Print Basic Information of a 'std_selected' Class Object