From 60a4829335575bd64ebea83f4cd0d7e353855461 Mon Sep 17 00:00:00 2001 From: Shu Fai Cheung Date: Sat, 6 Jun 2026 16:34:49 +0800 Subject: [PATCH 1/6] WIP. Not ready. --- README.md | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e7ad6f..d7dab7f 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,20 @@ (Version 0.2.13, updated on 2026-05-04, [release history](https://sfcheung.github.io/stdmod/news/index.html)) +**IMPORTANT NOTICE** + +> This package will no longer be actively updated. It will +still be maintained. However, new features will not be added. +The package [`manymome`](https://sfcheung.github.io/manymome/) +can do all the tasks in `stdmod` related to computing, +testing, and printing conditional effects, and can be used +for any number of moderators. The package +[`betaselectr`](https://sfcheung.github.io/betaselectr/) +can do all the tasks related to forming confidence intervals +for properly standardized coefficients, in both regression +models fitted by `stats::lm()` and `stats::glm()`, as well +as structural equation models fitted by `lavaan::sem()`. + (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()`.) @@ -59,6 +73,32 @@ https://sfcheung.github.io/stdmod/ levels of the moderator, and form nonparametric bootstrap confidence intervals these effects. +## Related Functions in `betaselectr` + +The function `lm_betaselect()` from the package `betaselectr` +can be used in place +of `std_selected()` and `std_selected_boot()`. A demonstration +of `lm_betaselect()` can be found [here](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html). +This package also has `glm_betaselect()` for models, such +as logistic regression models, fitted by `stats::glm()` +(see a demonstration [here](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html)). + +The function `lav_betaselect()` from the package `betaselectr` +is a version of `std_selected()` but for structural equation +models fitted by `lavaan::sem()`. A demonstration +of `lav_betaselect()` can be found [here](https://sfcheung.github.io/betaselectr/articles/betaselectr_lav.html). + +## Related Functions in `manymome` + +Although the package `manymome` is mainly for mediation and +moderated mediation, moderation is a special case and is also +supported. The `plot` method in `manymome` is more powerful +than `plotmod`, supports not only a regression model but also +a structural equation model, and also supports any number of +moderators. The function `manymome::cond_effects()` in `manymome` +is also more powerful than `cond_effect` in `stdmod`, supporting +both regression models and structural equation models. + # Installation The stable CRAN version can be installed by `install.packages()`: @@ -90,4 +130,4 @@ are also taken into account. # Issues If you have any suggestions and found any bugs, please feel -feel to open a GitHub issue. Thanks. +free to open a GitHub issue. Thanks. From ebfa67280c5b640500f8d3f59cd7da9fd6587816 Mon Sep 17 00:00:00 2001 From: Shu Fai Cheung Date: Thu, 23 Jul 2026 20:42:43 +0800 Subject: [PATCH 2/6] Update README on betaselectr and manymome --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index d7dab7f..5af5cc8 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,31 @@ for properly standardized coefficients, in both regression models fitted by `stats::lm()` and `stats::glm()`, as well as structural equation models fitted by `lavaan::sem()`. +> For standardizing only selected variables and for properly +standardizing product terms in regression models fitted by +`stats::lm()`, the function [`lm_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can be used instead of `std_selected()` and `std_selected_boot()`. +The package also has supports models fitted by `stats::glm()`, +such as logistic regression models. See [this article](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html) +for a demonstration. + +> For standardizing only selected variables in models fitted +by `lavaan`, `lavaan` natively supports this since version 0.7-2, +through setting `type` to a character vector of the variables +to be standardized. Alternatively, the function [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lav.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can also be used. [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/reference/lav_betaselect.html) +also supports properly standardizing a product term. In addition +to bootstrap confidence intervals, [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/reference/lav_betaselect.html) +also supports delta-method confidence intervals. + +> For computing conditional effects and plotting conditional +effects in regression models, the package [`manymome`](https://sfcheung.github.io/manymome/) +has more comprehensive support. See [these articles](https://sfcheung.github.io/manymome/articles/#moderated-regression) +for some demonstration. The package also supports moderation +in structural equation models fitted by `lavaan`. + (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()`.) @@ -68,11 +93,21 @@ https://sfcheung.github.io/stdmod/ - [plotmod](https://sfcheung.github.io/stdmod/articles/plotmod.html): How to generate a typical plot of moderation effect using `plotmod()`. + - It is recommended to use [`manymome`](https://sfcheung.github.io/manymome/) + for plotting conditional effects. See [this article](https://sfcheung.github.io/manymome/articles/mo_lm.html) + for a demonstration, and [these articles](https://sfcheung.github.io/manymome/articles/#moderated-regression) + for more complicated models. + - [cond_effect](https://sfcheung.github.io/stdmod/articles/cond_effect.html): How to compute conditional effects of the predictor for selected levels of the moderator, and form nonparametric bootstrap confidence intervals these effects. + - It is recommended to use [`manymome`](https://sfcheung.github.io/manymome/) + for computing conditional effects. See [this article](https://sfcheung.github.io/manymome/articles/mo_lm.html) + for a demonstration, and [these articles](https://sfcheung.github.io/manymome/articles/#moderated-regression) + for more complicated models. + ## Related Functions in `betaselectr` The function `lm_betaselect()` from the package `betaselectr` From add37f03bb2fcfefffac9ca66179837a8e696553 Mon Sep 17 00:00:00 2001 From: Shu Fai Cheung Date: Thu, 23 Jul 2026 20:54:25 +0800 Subject: [PATCH 3/6] Update articles and vignettes --- vignettes/cond_effect.Rmd | 543 ++++++++++++++------------- vignettes/cond_effect.Rmd.original | 21 ++ vignettes/moderation.Rmd | 35 +- vignettes/moderation.Rmd.original | 13 + vignettes/plotmod.Rmd | 8 + vignettes/std_selected.Rmd | 16 +- vignettes/std_selected.Rmd.original | 14 + vignettes/stdmod.Rmd | 16 +- vignettes/stdmod.Rmd.original | 14 + vignettes/stdmod_lavaan.Rmd | 16 +- vignettes/stdmod_lavaan.Rmd.original | 10 + 11 files changed, 428 insertions(+), 278 deletions(-) diff --git a/vignettes/cond_effect.Rmd b/vignettes/cond_effect.Rmd index 6ec15d6..3bd4b23 100644 --- a/vignettes/cond_effect.Rmd +++ b/vignettes/cond_effect.Rmd @@ -1,261 +1,282 @@ ---- -title: "Conditional Effects by cond_effect()" -author: "Shu Fai Cheung" -date: "2023-09-09" -output: rmarkdown::html_vignette -vignette: > - %\VignetteIndexEntry{Conditional Effects by cond_effect()} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - - - -# Introduction - -This vignette illustrates how to use -`cond_effect()` from the `stdmod` package. -More about this package can be found -in `vignette("stdmod", package = "stdmod")` -or at [https://sfcheung.github.io/stdmod/](https://sfcheung.github.io/stdmod/). - -# What `cond_effect()` Can Do - -It can compute the conditional effect of a predictor (the focal variable) -on an outcome variable (dependent variable) -for selected levels of the moderator: - - -``` -#> Level conscientiousness emotional_stability Effect S.E. t p Sig -#> High 3.950 0.012 0.117 0.107 0.915 -#> Medium 3.343 0.214 0.083 2.560 0.011 * -#> Low 2.736 0.415 0.115 3.601 0.000 *** -``` - -It can also compute standardized conditional moderation effect of this predictor: - - -``` -#> Level conscientiousness emotional_stability Effect S.E. t p Sig -#> High 1.000 0.007 0.063 0.107 0.915 -#> Medium 0.000 0.115 0.045 2.560 0.011 * -#> Low -1.000 0.223 0.062 3.601 0.000 *** -``` - -Nonparametric bootstrap percentile confidence interval can also be formed -for standardized conditional effect using `cond_effect_boot()`. - -`cond_effect()` is not designed to be a versatile tool. It is designed to -be a function "good-enough" for common scenarios. Nevertheless, it can -report some useful information along with the conditional effects, -as demonstrated below. - -# Major Arguments - -## Regression Output, Predictor (`x`), and Moderator (`w`) - -- `output`: The output of `lm()`, `std_selected()`, or `std_selected_boot()`, - with at least one interaction term. Bootstrap estimates in - `std_selected_boot()` will be ignored because bootstrapping will be - done for each level again. - -- `x`: The predictor (focal variable). - -- `w`: The moderator. - -These are the only required arguments. Just setting them can generate the -graph: - - - -```r -library(stdmod) -data(sleep_emo_con) -lm_out <- lm(sleep_duration ~ age + gender + - emotional_stability * conscientiousness, - sleep_emo_con) -cond_out <- cond_effect(output = lm_out, - x = "emotional_stability", - w = "conscientiousness") -cond_out -#> The effects of emotional_stability on sleep_duration, conditional on conscientiousness: -#> -#> Level conscientiousness emotional_stability Effect S.E. t p Sig -#> High 3.950 0.012 0.117 0.107 0.915 -#> Medium 3.343 0.214 0.083 2.560 0.011 * -#> Low 2.736 0.415 0.115 3.601 0.000 *** -#> -#> -#> The regression model: -#> -#> sleep_duration ~ age + gender + emotional_stability * conscientiousness -#> -#> Interpreting the levels of conscientiousness: -#> -#> Level conscientiousness % Below From Mean (in SD) -#> High 3.950 83.60 1.00 -#> Medium 3.343 49.60 0.00 -#> Low 2.736 16.60 -1.00 -#> -#> - % Below: The percent of cases equal to or less than a level. -#> - From Mean (in SD): Distance of a level from the mean, in standard -#> deviation (+ve above, -ve below). -``` - -By default, the print method of `cond_effect()` output prints the -conditional effects, OLS standard errors, *t* statistics, *p*-values, -and significant test results, along with other information such -as the value of each level of the moderator, its distance from the mean, -the percentage of cases equal to or less than this level. The regression -model is also printed. If only the table of effects is needed, call `print()` -and set `table_only` to `TRUE`: - - -```r -print(cond_out, table_only = TRUE) -#> Level conscientiousness emotional_stability Effect S.E. t p Sig -#> High 3.950 0.012 0.117 0.107 0.915 -#> Medium 3.343 0.214 0.083 2.560 0.011 * -#> Low 2.736 0.415 0.115 3.601 0.000 *** -``` - -More options in printing the output can be found in the help page of -`print.cond_effect()`. - -# Levels of the Moderator - -## Numeric Moderators - -If the moderator is a numeric variable, then, by default, the conditional effects -for three levels of the moderators will be used: one standard deviation (SD) -to the mean ("Low"), mean ("Medium"), and one SD above mean ("High"). - -Users can also use percentiles to define "Low", "Medium", and "High" by setting -`w_method` to `"percentile"`. The default are 16th percentile, 50th percentile, -and 84th percentile, which corresponds approximately to one SD below mean, -mean, and one SD above mean, respectively, for a normal distribution. - - -```r -data(sleep_emo_con) -lm_out <- lm(sleep_duration ~ age + gender + - emotional_stability * conscientiousness, - sleep_emo_con) -cond_out <- cond_effect(output = lm_out, - x = "emotional_stability", - w = "conscientiousness", - w_method = "percentile") -print(cond_out, title = FALSE, model = FALSE) -#> Level conscientiousness emotional_stability Effect S.E. t p Sig -#> High 4.000 -0.004 0.122 -0.034 0.973 -#> Medium 3.400 0.195 0.084 2.322 0.021 * -#> Low 2.700 0.427 0.119 3.600 0.000 *** -#> -#> Interpreting the levels of conscientiousness: -#> -#> Level conscientiousness % Below From Mean (in SD) -#> High 4.000 87.20 1.08 -#> Medium 3.400 57.00 0.09 -#> Low 2.700 16.60 -1.06 -#> -#> - % Below: The percent of cases equal to or less than a level. -#> - From Mean (in SD): Distance of a level from the mean, in standard -#> deviation (+ve above, -ve below). -``` - -Note that the empirical percentage of cases equal to or less than a level may -not be exactly equal to that for the requested percentile if the number of -cases is small and/or the number of unique values of the moderator is small. - -## Categorical Moderators - -If the moderator is a categorical variable (a string variable or - a factor), then the conditional effect of the moderator for each value of - this categorical moderator will be printed: - - -```r -set.seed(61452) -sleep_emo_con$city <- sample(c("Alpha", "Beta", "Gamma"), - nrow(sleep_emo_con), replace = TRUE) -lm_cat <- lm(sleep_duration ~ age + gender + emotional_stability*city, - sleep_emo_con) -cond_out <- cond_effect(lm_cat, - x = "emotional_stability", - w = "city") -print(cond_out, title = FALSE, model = FALSE) -#> Level city emotional_stability Effect S.E. t p Sig -#> Alpha Alpha 0.408 0.135 3.027 0.003 ** -#> Beta Beta 0.351 0.147 2.388 0.017 * -#> Gamma Gamma 0.020 0.149 0.131 0.896 -``` - -# Nonparametric Bootstrap Confidence Intervals - -If one or more variables are standardized, the OLS confidence intervals are not -appropriate ([Cheung, Cheung, Lau, Hui, & Vong, 2022](https://doi.org/10.1037/hea0001188); -[Yuan & Chan, 2011](https://doi.org/10.1007/s11336-011-9224-6)). -Users can -call `cond_effect_boot()` to use nonparametric bootstrapping to form the -percentile confidence interval for each conditional effect. - -- `conf`: The level of confidence, expressed as a proportion. Default is - .95, requesting a 95% confidence interval. -- `nboot` The number of bootstrap samples to drawn. Should be at least 2000 - but 5000 is preferable. - -To make the results reproducible, call `set.seed()` before -calling `cond_effect_boot()`, as illustrated below. - - -```r -lm_out <- lm(sleep_duration ~ age + gender + - emotional_stability * conscientiousness, - sleep_emo_con) -# Standardize all variables and do the moderated regression again -# Use to_standardize as a shortcut to to_center and to_scale -lm_std <- std_selected(lm_out, - to_standardize = ~ .) -set.seed(897043) -cond_std <- cond_effect_boot(output = lm_std, - x = "emotional_stability", - w = "conscientiousness", - nboot = 2000) -print(cond_std, model = FALSE, title = FALSE, level_info = FALSE) -#> Level conscientiousness emotional_stability Effect CI Lower CI Upper S.E. -#> High 1.000 0.007 -0.107 0.117 0.063 -#> Medium 0.000 0.115 0.029 0.202 0.045 -#> Low -1.000 0.223 0.071 0.364 0.062 -#> t p Sig -#> 0.107 0.915 -#> 2.560 0.011 * -#> 3.601 0.000 *** -#> -#> [CI Lower, CI Upper] shows the 95% nonparametric bootstrap confidence -#> interval(s) (based on 2000 bootstrap samples). -#> -#> Note: -#> -#> - The variable(s) sleep_duration, emotional_stability, -#> conscientiousness is/are standardized. -#> - The conditional effects are the standardized effects of -#> emotional_stability on sleep_duration. -``` - -# Further Information - -Please refer to the help page of `cond_effect()` and `cond_effect_boot()` -for other options available, such as defining the number of SDs from -mean to define "Low" and "High", the percentiles to be used, or -using parallel processing to speed up bootstrapping. - -# Reference - -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. - -Yuan, K.-H., & Chan, W. (2011). Biases and standard errors of standardized -regression coefficients. *Psychometrika, 76*(4), 670-690. -https://doi.org/10.1007/s11336-011-9224-6 +--- +title: "Conditional Effects by cond_effect()" +author: "Shu Fai Cheung" +date: "2026-07-23" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Conditional Effects by cond_effect()} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + + +> For computing conditional effects and plotting conditional +effects in regression models, it is recommended to +use the package [`manymome`](https://sfcheung.github.io/manymome/). +It has more comprehensive support than `stdmod`. See [these articles](https://sfcheung.github.io/manymome/articles/#moderated-regression) +for some demonstration. The package also supports moderation +in structural equation models fitted by `lavaan`, which is not +supported in `stdmod`. + +> For standardizing only selected variables and for properly +standardizing product terms in regression models fitted by +`stats::lm()`, the function [`lm_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can be used instead of `std_selected()` and `std_selected_boot()`. +The package also has supports models fitted by `stats::glm()`, +such as logistic regression models. See [this article](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html) +for a demonstration. + +> However, if only mean-centering is needed, `stdmod` should +be used because `betaselectr` does not support doing only +mean-centering. + +# Introduction + +This vignette illustrates how to use +`cond_effect()` from the `stdmod` package. +More about this package can be found +in `vignette("stdmod", package = "stdmod")` +or at [https://sfcheung.github.io/stdmod/](https://sfcheung.github.io/stdmod/). + +# What `cond_effect()` Can Do + +It can compute the conditional effect of a predictor (the focal variable) +on an outcome variable (dependent variable) +for selected levels of the moderator: + + +``` +#> Level conscientiousness emotional_stability Effect S.E. t p Sig +#> High 3.950 0.012 0.117 0.107 0.915 +#> Medium 3.343 0.214 0.083 2.560 0.011 * +#> Low 2.736 0.415 0.115 3.601 0.000 *** +``` + +It can also compute standardized conditional moderation effect of this predictor: + + +``` +#> Level conscientiousness emotional_stability Effect S.E. t p Sig +#> High 1.000 0.007 0.063 0.107 0.915 +#> Medium 0.000 0.115 0.045 2.560 0.011 * +#> Low -1.000 0.223 0.062 3.601 0.000 *** +``` + +Nonparametric bootstrap percentile confidence interval can also be formed +for standardized conditional effect using `cond_effect_boot()`. + +`cond_effect()` is not designed to be a versatile tool. It is designed to +be a function "good-enough" for common scenarios. Nevertheless, it can +report some useful information along with the conditional effects, +as demonstrated below. + +# Major Arguments + +## Regression Output, Predictor (`x`), and Moderator (`w`) + +- `output`: The output of `lm()`, `std_selected()`, or `std_selected_boot()`, + with at least one interaction term. Bootstrap estimates in + `std_selected_boot()` will be ignored because bootstrapping will be + done for each level again. + +- `x`: The predictor (focal variable). + +- `w`: The moderator. + +These are the only required arguments. Just setting them can generate the +graph: + + + +``` r +library(stdmod) +data(sleep_emo_con) +lm_out <- lm(sleep_duration ~ age + gender + + emotional_stability * conscientiousness, + sleep_emo_con) +cond_out <- cond_effect(output = lm_out, + x = "emotional_stability", + w = "conscientiousness") +cond_out +#> The effects of emotional_stability on sleep_duration, conditional on conscientiousness: +#> +#> Level conscientiousness emotional_stability Effect S.E. t p Sig +#> High 3.950 0.012 0.117 0.107 0.915 +#> Medium 3.343 0.214 0.083 2.560 0.011 * +#> Low 2.736 0.415 0.115 3.601 0.000 *** +#> +#> +#> The regression model: +#> +#> sleep_duration ~ age + gender + emotional_stability * conscientiousness +#> +#> Interpreting the levels of conscientiousness: +#> +#> Level conscientiousness % Below From Mean (in SD) +#> High 3.950 83.60 1.00 +#> Medium 3.343 49.60 0.00 +#> Low 2.736 16.60 -1.00 +#> +#> - % Below: The percent of cases equal to or less than a level. +#> - From Mean (in SD): Distance of a level from the mean, in standard +#> deviation (+ve above, -ve below). +``` + +By default, the print method of `cond_effect()` output prints the +conditional effects, OLS standard errors, *t* statistics, *p*-values, +and significant test results, along with other information such +as the value of each level of the moderator, its distance from the mean, +the percentage of cases equal to or less than this level. The regression +model is also printed. If only the table of effects is needed, call `print()` +and set `table_only` to `TRUE`: + + +``` r +print(cond_out, table_only = TRUE) +#> Level conscientiousness emotional_stability Effect S.E. t p Sig +#> High 3.950 0.012 0.117 0.107 0.915 +#> Medium 3.343 0.214 0.083 2.560 0.011 * +#> Low 2.736 0.415 0.115 3.601 0.000 *** +``` + +More options in printing the output can be found in the help page of +`print.cond_effect()`. + +# Levels of the Moderator + +## Numeric Moderators + +If the moderator is a numeric variable, then, by default, the conditional effects +for three levels of the moderators will be used: one standard deviation (SD) +to the mean ("Low"), mean ("Medium"), and one SD above mean ("High"). + +Users can also use percentiles to define "Low", "Medium", and "High" by setting +`w_method` to `"percentile"`. The default are 16th percentile, 50th percentile, +and 84th percentile, which corresponds approximately to one SD below mean, +mean, and one SD above mean, respectively, for a normal distribution. + + +``` r +data(sleep_emo_con) +lm_out <- lm(sleep_duration ~ age + gender + + emotional_stability * conscientiousness, + sleep_emo_con) +cond_out <- cond_effect(output = lm_out, + x = "emotional_stability", + w = "conscientiousness", + w_method = "percentile") +print(cond_out, title = FALSE, model = FALSE) +#> Level conscientiousness emotional_stability Effect S.E. t p Sig +#> High 4.000 -0.004 0.122 -0.034 0.973 +#> Medium 3.400 0.195 0.084 2.322 0.021 * +#> Low 2.700 0.427 0.119 3.600 0.000 *** +#> +#> Interpreting the levels of conscientiousness: +#> +#> Level conscientiousness % Below From Mean (in SD) +#> High 4.000 87.20 1.08 +#> Medium 3.400 57.00 0.09 +#> Low 2.700 16.60 -1.06 +#> +#> - % Below: The percent of cases equal to or less than a level. +#> - From Mean (in SD): Distance of a level from the mean, in standard +#> deviation (+ve above, -ve below). +``` + +Note that the empirical percentage of cases equal to or less than a level may +not be exactly equal to that for the requested percentile if the number of +cases is small and/or the number of unique values of the moderator is small. + +## Categorical Moderators + +If the moderator is a categorical variable (a string variable or + a factor), then the conditional effect of the moderator for each value of + this categorical moderator will be printed: + + +``` r +set.seed(61452) +sleep_emo_con$city <- sample(c("Alpha", "Beta", "Gamma"), + nrow(sleep_emo_con), replace = TRUE) +lm_cat <- lm(sleep_duration ~ age + gender + emotional_stability*city, + sleep_emo_con) +cond_out <- cond_effect(lm_cat, + x = "emotional_stability", + w = "city") +print(cond_out, title = FALSE, model = FALSE) +#> Level city emotional_stability Effect S.E. t p Sig +#> Alpha Alpha 0.408 0.135 3.027 0.003 ** +#> Beta Beta 0.351 0.147 2.388 0.017 * +#> Gamma Gamma 0.020 0.149 0.131 0.896 +``` + +# Nonparametric Bootstrap Confidence Intervals + +If one or more variables are standardized, the OLS confidence intervals are not +appropriate ([Cheung, Cheung, Lau, Hui, & Vong, 2022](https://doi.org/10.1037/hea0001188); +[Yuan & Chan, 2011](https://doi.org/10.1007/s11336-011-9224-6)). +Users can +call `cond_effect_boot()` to use nonparametric bootstrapping to form the +percentile confidence interval for each conditional effect. + +- `conf`: The level of confidence, expressed as a proportion. Default is + .95, requesting a 95% confidence interval. +- `nboot` The number of bootstrap samples to drawn. Should be at least 2000 + but 5000 is preferable. + +To make the results reproducible, call `set.seed()` before +calling `cond_effect_boot()`, as illustrated below. + + +``` r +lm_out <- lm(sleep_duration ~ age + gender + + emotional_stability * conscientiousness, + sleep_emo_con) +# Standardize all variables and do the moderated regression again +# Use to_standardize as a shortcut to to_center and to_scale +lm_std <- std_selected(lm_out, + to_standardize = ~ .) +set.seed(897043) +cond_std <- cond_effect_boot(output = lm_std, + x = "emotional_stability", + w = "conscientiousness", + nboot = 2000) +print(cond_std, model = FALSE, title = FALSE, level_info = FALSE) +#> Level conscientiousness emotional_stability Effect CI Lower CI Upper S.E. +#> High 1.000 0.007 -0.107 0.117 0.063 +#> Medium 0.000 0.115 0.029 0.202 0.045 +#> Low -1.000 0.223 0.071 0.364 0.062 +#> t p Sig +#> 0.107 0.915 +#> 2.560 0.011 * +#> 3.601 0.000 *** +#> +#> [CI Lower, CI Upper] shows the 95% nonparametric bootstrap confidence +#> interval(s) (based on 2000 bootstrap samples). +#> +#> Note: +#> +#> - The variable(s) sleep_duration, emotional_stability, +#> conscientiousness is/are standardized. +#> - The conditional effects are the standardized effects of +#> emotional_stability on sleep_duration. +``` + +# Further Information + +Please refer to the help page of `cond_effect()` and `cond_effect_boot()` +for other options available, such as defining the number of SDs from +mean to define "Low" and "High", the percentiles to be used, or +using parallel processing to speed up bootstrapping. + +# Reference + +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. + +Yuan, K.-H., & Chan, W. (2011). Biases and standard errors of standardized +regression coefficients. *Psychometrika, 76*(4), 670-690. +https://doi.org/10.1007/s11336-011-9224-6 diff --git a/vignettes/cond_effect.Rmd.original b/vignettes/cond_effect.Rmd.original index 3ac53f9..ee853c6 100644 --- a/vignettes/cond_effect.Rmd.original +++ b/vignettes/cond_effect.Rmd.original @@ -20,6 +20,27 @@ knitr::opts_chunk$set( ) ``` +> For computing conditional effects and plotting conditional +effects in regression models, it is recommended to +use the package [`manymome`](https://sfcheung.github.io/manymome/). +It has more comprehensive support than `stdmod`. See [these articles](https://sfcheung.github.io/manymome/articles/#moderated-regression) +for some demonstration. The package also supports moderation +in structural equation models fitted by `lavaan`, which is not +supported in `stdmod`. + +> For standardizing only selected variables and for properly +standardizing product terms in regression models fitted by +`stats::lm()`, the function [`lm_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can be used instead of `std_selected()` and `std_selected_boot()`. +The package also has supports models fitted by `stats::glm()`, +such as logistic regression models. See [this article](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html) +for a demonstration. + +> However, if only mean-centering is needed, `stdmod` should +be used because `betaselectr` does not support doing only +mean-centering. + # Introduction This vignette illustrates how to use diff --git a/vignettes/moderation.Rmd b/vignettes/moderation.Rmd index c5f7c62..76d6ac5 100644 --- a/vignettes/moderation.Rmd +++ b/vignettes/moderation.Rmd @@ -1,7 +1,7 @@ --- title: "Standardized Moderation Effect by std_selected()" author: "Shu Fai Cheung and David Weng Ngai Vong" -date: "2026-01-04" +date: "2026-07-23" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Standardized Moderation Effect by std_selected()} @@ -11,6 +11,19 @@ vignette: > +> For standardizing only selected variables and for properly +standardizing product terms in regression models fitted by +`stats::lm()`, the function [`lm_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can be used instead of `std_selected()` and `std_selected_boot()`. +The package also has supports models fitted by `stats::glm()`, +such as logistic regression models. See [this article](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html) +for a demonstration. + +> However, if only mean-centering is needed, `stdmod` should +be used because `betaselectr` does not support doing only +mean-centering. + # Purpose This document demonstrates how to use `std_selected()` from @@ -33,12 +46,10 @@ library(stdmod) # For computing the standardized moderation effect conveniently ``` r data(sleep_emo_con) head(sleep_emo_con, 3) -#> # A tibble: 3 × 6 -#> case_id sleep_duration conscientiousness emotional_stability age gender -#> -#> 1 1 6 3.6 3.6 20 female -#> 2 2 4 3.8 2.4 20 female -#> 3 3 7 4.3 2.7 20 female +#> case_id sleep_duration conscientiousness emotional_stability age gender +#> 1 1 6 3.6 3.6 20 female +#> 2 2 4 3.8 2.4 20 female +#> 3 3 7 4.3 2.7 20 female ``` This data set has 500 cases of data. The variables are sleep duration, age, gender, @@ -52,12 +63,10 @@ The names of some variables are shortened for readability: ``` r colnames(sleep_emo_con)[3:4] <- c("cons", "emot") head(sleep_emo_con, 3) -#> # A tibble: 3 × 6 -#> case_id sleep_duration cons emot age gender -#> -#> 1 1 6 3.6 3.6 20 female -#> 2 2 4 3.8 2.4 20 female -#> 3 3 7 4.3 2.7 20 female +#> case_id sleep_duration cons emot age gender +#> 1 1 6 3.6 3.6 20 female +#> 2 2 4 3.8 2.4 20 female +#> 3 3 7 4.3 2.7 20 female ``` diff --git a/vignettes/moderation.Rmd.original b/vignettes/moderation.Rmd.original index 168f603..4318d5a 100644 --- a/vignettes/moderation.Rmd.original +++ b/vignettes/moderation.Rmd.original @@ -20,6 +20,19 @@ knitr::opts_chunk$set( ) ``` +> For standardizing only selected variables and for properly +standardizing product terms in regression models fitted by +`stats::lm()`, the function [`lm_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can be used instead of `std_selected()` and `std_selected_boot()`. +The package also has supports models fitted by `stats::glm()`, +such as logistic regression models. See [this article](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html) +for a demonstration. + +> However, if only mean-centering is needed, `stdmod` should +be used because `betaselectr` does not support doing only +mean-centering. + # Purpose This document demonstrates how to use `std_selected()` from diff --git a/vignettes/plotmod.Rmd b/vignettes/plotmod.Rmd index f520ffb..ae36346 100644 --- a/vignettes/plotmod.Rmd +++ b/vignettes/plotmod.Rmd @@ -19,6 +19,14 @@ knitr::opts_chunk$set( ) ``` +> For computing conditional effects and plotting conditional +effects in regression models, it is recommended to +use the package [`manymome`](https://sfcheung.github.io/manymome/). +It has more comprehensive support than `stdmod`. See [these articles](https://sfcheung.github.io/manymome/articles/#moderated-regression) +for some demonstration. The package also supports moderation +in structural equation models fitted by `lavaan`, which is not +supported in `stdmod`. + # Introduction This vignette illustrates how to use diff --git a/vignettes/std_selected.Rmd b/vignettes/std_selected.Rmd index b402167..5de27b8 100644 --- a/vignettes/std_selected.Rmd +++ b/vignettes/std_selected.Rmd @@ -1,7 +1,7 @@ --- title: "Mean Center and Standardize Selected Variable by std_selected()" author: "Shu Fai Cheung and David Weng Ngai Vong" -date: "2026-01-04" +date: "2026-07-23" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Mean Center and Standardize Selected Variable by std_selected()} @@ -11,6 +11,20 @@ vignette: > + +> For standardizing only selected variables and for properly +standardizing product terms in regression models fitted by +`stats::lm()`, the function [`lm_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can be used instead of `std_selected()` and `std_selected_boot()`. +The package also has supports models fitted by `stats::glm()`, +such as logistic regression models. See [this article](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html) +for a demonstration. + +> However, if only mean-centering is needed, `stdmod` should +be used because `betaselectr` does not support doing only +mean-centering. + # Purpose Instead of standardizing all variables, even variables that (a) are categorical diff --git a/vignettes/std_selected.Rmd.original b/vignettes/std_selected.Rmd.original index 6d11eac..283355e 100644 --- a/vignettes/std_selected.Rmd.original +++ b/vignettes/std_selected.Rmd.original @@ -20,6 +20,20 @@ knitr::opts_chunk$set( ) ``` + +> For standardizing only selected variables and for properly +standardizing product terms in regression models fitted by +`stats::lm()`, the function [`lm_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can be used instead of `std_selected()` and `std_selected_boot()`. +The package also has supports models fitted by `stats::glm()`, +such as logistic regression models. See [this article](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html) +for a demonstration. + +> However, if only mean-centering is needed, `stdmod` should +be used because `betaselectr` does not support doing only +mean-centering. + # Purpose Instead of standardizing all variables, even variables that (a) are categorical diff --git a/vignettes/stdmod.Rmd b/vignettes/stdmod.Rmd index 25095ae..aaeb2ca 100644 --- a/vignettes/stdmod.Rmd +++ b/vignettes/stdmod.Rmd @@ -1,7 +1,7 @@ --- title: "A Quick Start Guide on Using std_selected()" author: "Shu Fai Cheung" -date: "2026-01-04" +date: "2026-07-23" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{A Quick Start Guide on Using std_selected()} @@ -11,6 +11,20 @@ vignette: > +> For standardizing only selected variables and for properly +standardizing product terms in regression models fitted by +`stats::lm()`, the function [`lm_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can be used instead of `std_selected()` and `std_selected_boot()`. +The package also has supports models fitted by `stats::glm()`, +such as logistic regression models. See [this article](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html) +for a demonstration. + +> However, if only mean-centering is needed, `stdmod` should +be used because `betaselectr` does not support doing only +mean-centering. + + # Introduction This vignette illustrates how to use diff --git a/vignettes/stdmod.Rmd.original b/vignettes/stdmod.Rmd.original index 0fbf805..15e892d 100644 --- a/vignettes/stdmod.Rmd.original +++ b/vignettes/stdmod.Rmd.original @@ -20,6 +20,20 @@ knitr::opts_chunk$set( ) ``` +> For standardizing only selected variables and for properly +standardizing product terms in regression models fitted by +`stats::lm()`, the function [`lm_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can be used instead of `std_selected()` and `std_selected_boot()`. +The package also has supports models fitted by `stats::glm()`, +such as logistic regression models. See [this article](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html) +for a demonstration. + +> However, if only mean-centering is needed, `stdmod` should +be used because `betaselectr` does not support doing only +mean-centering. + + # Introduction This vignette illustrates how to use diff --git a/vignettes/stdmod_lavaan.Rmd b/vignettes/stdmod_lavaan.Rmd index cff2183..7582666 100644 --- a/vignettes/stdmod_lavaan.Rmd +++ b/vignettes/stdmod_lavaan.Rmd @@ -1,7 +1,7 @@ --- title: "Standardized Moderation Effect in a Path Model by stdmod_lavaan()" author: "Shu Fai Cheung and David Weng Ngai Vong" -date: "2026-01-04" +date: "2026-07-23" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Standardized Moderation Effect in a Path Model by stdmod_lavaan()} @@ -11,6 +11,16 @@ vignette: > +> For standardizing only selected variables in models fitted +by `lavaan`, `lavaan` natively supports this since version 0.7-2, +through setting `type` to a character vector of the variables +to be standardized. Alternatively, the function [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lav.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can also be used. [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/reference/lav_betaselect.html) +also supports properly standardizing a product term. In addition +to bootstrap confidence intervals, [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/reference/lav_betaselect.html) +also supports delta-method confidence intervals. + # Purpose This document demonstrates how to use `stdmod_lavaan()` from @@ -27,6 +37,8 @@ or at [https://sfcheung.github.io/stdmod/](https://sfcheung.github.io/stdmod/). ``` r library(stdmod) # For computing the standardized moderation effect conveniently library(lavaan) # For doing path analysis in lavaan. +#> This is lavaan 0.7-2.3110 +#> lavaan is FREE software! Please report any bugs. ``` # Load the Dataset @@ -60,7 +72,7 @@ dv ~ med + cov2 " fit <- sem(mod, test_mod1, fixed.x = FALSE) summary(fit) -#> lavaan 0.6-21.2434 ended normally after 1 iteration +#> lavaan 0.7-2.3110 ended normally after 1 iteration #> #> Estimator ML #> Optimization method NLMINB diff --git a/vignettes/stdmod_lavaan.Rmd.original b/vignettes/stdmod_lavaan.Rmd.original index e0bf1a2..6d90a2a 100644 --- a/vignettes/stdmod_lavaan.Rmd.original +++ b/vignettes/stdmod_lavaan.Rmd.original @@ -20,6 +20,16 @@ knitr::opts_chunk$set( ) ``` +> For standardizing only selected variables in models fitted +by `lavaan`, `lavaan` natively supports this since version 0.7-2, +through setting `type` to a character vector of the variables +to be standardized. Alternatively, the function [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lav.html) +from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +can also be used. [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/reference/lav_betaselect.html) +also supports properly standardizing a product term. In addition +to bootstrap confidence intervals, [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/reference/lav_betaselect.html) +also supports delta-method confidence intervals. + # Purpose This document demonstrates how to use `stdmod_lavaan()` from From 80a573d74d9857f07981cc5db166eb10771d129e Mon Sep 17 00:00:00 2001 From: Shu Fai Cheung Date: Thu, 23 Jul 2026 21:08:30 +0800 Subject: [PATCH 4/6] Update help pages for betaselectr and manymome checks and build_site() passed. --- DESCRIPTION | 2 +- R/condeff.R | 18 +++++++++++++++++- R/plotmod.R | 19 ++++++++++++++++++- R/std_selected.R | 14 ++++++++++++++ R/stdmod_lavaan.R | 13 +++++++++++++ man/cond_effect.Rd | 16 ++++++++++++++++ man/plotmod.Rd | 18 +++++++++++++++++- man/std_selected.Rd | 15 +++++++++++++++ man/stdmod-package.Rd | 5 +++++ man/stdmod_lavaan.Rd | 13 +++++++++++++ 10 files changed, 129 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index da54e5c..002be16 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,6 @@ License: GPL-3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.3 Suggests: testthat, knitr, @@ -43,3 +42,4 @@ Imports: manymome, rlang VignetteBuilder: knitr +Config/roxygen2/version: 8.0.0 diff --git a/R/condeff.R b/R/condeff.R index 066b432..2fadc47 100644 --- a/R/condeff.R +++ b/R/condeff.R @@ -2,7 +2,23 @@ #' #' @description Compute the conditional effects in a moderated regression model. #' -#' @details [cond_effect()] uses the centering approach to find the conditional +#' @details +#' +#' ## NOTE +#' +#' For computing conditional effects and plotting conditional +#' effects in regression models, it is recommended to +#' use the package [`manymome`](https://sfcheung.github.io/manymome/). +#' It has more comprehensive support than `stdmod`. See +#' See [this demo](https://sfcheung.github.io/manymome/articles/mo_lm.html) for +#' a one-moderator model, and [these articles](https://sfcheung.github.io/manymome/articles/#moderated-regression) +#' for other demonstrations. The package also supports moderation +#' in structural equation models fitted by `lavaan`, which is not +#' supported in `stdmod`. +#' +#' ## Details +#' +#' [cond_effect()] uses the centering approach to find the conditional #' effect of the focal variable. For each level of the moderator, the value for #' this level is subtracted from the moderator scores, and the model is #' fitted to the modified data. diff --git a/R/plotmod.R b/R/plotmod.R index 3ed4701..c386f98 100644 --- a/R/plotmod.R +++ b/R/plotmod.R @@ -2,7 +2,24 @@ #' #' @description Plot the moderation effect in a regression model #' -#' @details This function generate a basic `ggplot2` graph +#' @details +#' +#' +#' ## NOTE +#' +#' For computing conditional effects and plotting conditional +#' effects in regression models, it is recommended to +#' use the package [`manymome`](https://sfcheung.github.io/manymome/). +#' It has more comprehensive support than `stdmod`. See +#' See [this demo](https://sfcheung.github.io/manymome/articles/mo_lm.html) for +#' a one-moderator model, and [these articles](https://sfcheung.github.io/manymome/articles/#moderated-regression) +#' for other demonstrations. The package also supports moderation +#' in structural equation models fitted by `lavaan`, which is not +#' supported in `stdmod`. +#' +#' ## Details +#' +#' This function generates a basic `ggplot2` graph #' typically found in psychology manuscripts. It tries to #' check whether one or more variables are standardized, and #' report this in the plot if required. diff --git a/R/std_selected.R b/R/std_selected.R index d88d478..f682b74 100644 --- a/R/std_selected.R +++ b/R/std_selected.R @@ -4,6 +4,20 @@ #' selected variables in a regression model and refit the model #' #' @details +#' +#' ## NOTE +#' +#' For standardizing only selected variables and for properly +#' standardizing product terms in regression models fitted by +#' `stats::lm()`, the function [`lm_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html) +#' from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +#' can be used instead of `std_selected()` and `std_selected_boot()`. +#' The package also has supports models fitted by `stats::glm()`, +#' such as logistic regression models. See [this article](https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html) +#' for a demonstration. +#' +#' ## Details +#' #' [std_selected()] was originally developed to compute the standardized #' moderation effect and the standardized coefficients for other predictors #' given an [lm()] output (Cheung, Cheung, Lau, Hui, & Vong, 2022). diff --git a/R/stdmod_lavaan.R b/R/stdmod_lavaan.R index 01c6b79..fe4091b 100644 --- a/R/stdmod_lavaan.R +++ b/R/stdmod_lavaan.R @@ -5,6 +5,19 @@ #' form the nonparametric bootstrap confidence interval. #' #' @details +#' +#' ## NOTE +#' +#' For standardizing only selected variables in models fitted +#' by `lavaan`, `lavaan` natively supports this since version 0.7-2, +#' through setting `type` to a character vector of the variables +#' to be standardized. Alternatively, the function [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/articles/betaselectr_lav.html) +#' from [`betaselectr`](https://sfcheung.github.io/betaselectr/) +#' can also be used. [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/reference/lav_betaselect.html) +#' also supports properly standardizing a product term. In addition +#' to bootstrap confidence intervals, [`lav_betaselect()`](https://sfcheung.github.io/betaselectr/reference/lav_betaselect.html) +#' also supports delta-method confidence intervals. +#' #' ## Important Notes #' #' Starting from Version 0.2.7.5, of [stdmod_lavaan()] adopts an approach diff --git a/man/cond_effect.Rd b/man/cond_effect.Rd index 3840544..c1a02b6 100644 --- a/man/cond_effect.Rd +++ b/man/cond_effect.Rd @@ -182,12 +182,28 @@ equal to the number of levels of the moderator. Compute the conditional effects in a moderated regression model. } \details{ +\subsection{NOTE}{ + +For computing conditional effects and plotting conditional +effects in regression models, it is recommended to +use the package \href{https://sfcheung.github.io/manymome/}{\code{manymome}}. +It has more comprehensive support than \code{stdmod}. See +See \href{https://sfcheung.github.io/manymome/articles/mo_lm.html}{this demo} for +a one-moderator model, and \href{https://sfcheung.github.io/manymome/articles/#moderated-regression}{these articles} +for other demonstrations. The package also supports moderation +in structural equation models fitted by \code{lavaan}, which is not +supported in \code{stdmod}. +} + +\subsection{Details}{ + \code{\link[=cond_effect]{cond_effect()}} uses the centering approach to find the conditional effect of the focal variable. For each level of the moderator, the value for this level is subtracted from the moderator scores, and the model is fitted to the modified data. The coefficient of the focal variable is then the conditional effect of the focal variable when the moderator's score is equal this value. +} \code{\link[=cond_effect_boot]{cond_effect_boot()}} function is a wrapper of \code{\link[=cond_effect]{cond_effect()}}. It calls \code{\link[=cond_effect]{cond_effect()}} diff --git a/man/plotmod.Rd b/man/plotmod.Rd index 6c8b5a3..6c91fed 100644 --- a/man/plotmod.Rd +++ b/man/plotmod.Rd @@ -188,7 +188,22 @@ be further modified like a usual \code{ggplot2} graph. Plot the moderation effect in a regression model } \details{ -This function generate a basic \code{ggplot2} graph +\subsection{NOTE}{ + +For computing conditional effects and plotting conditional +effects in regression models, it is recommended to +use the package \href{https://sfcheung.github.io/manymome/}{\code{manymome}}. +It has more comprehensive support than \code{stdmod}. See +See \href{https://sfcheung.github.io/manymome/articles/mo_lm.html}{this demo} for +a one-moderator model, and \href{https://sfcheung.github.io/manymome/articles/#moderated-regression}{these articles} +for other demonstrations. The package also supports moderation +in structural equation models fitted by \code{lavaan}, which is not +supported in \code{stdmod}. +} + +\subsection{Details}{ + +This function generates a basic \code{ggplot2} graph typically found in psychology manuscripts. It tries to check whether one or more variables are standardized, and report this in the plot if required. @@ -196,6 +211,7 @@ report this in the plot if required. This function only has features for typical plots of moderation effects. It is not intended to be a flexible tool for a fine control on the plots. } +} \examples{ # Do a moderated regression by lm diff --git a/man/std_selected.Rd b/man/std_selected.Rd index 232d58e..7bb144f 100644 --- a/man/std_selected.Rd +++ b/man/std_selected.Rd @@ -111,6 +111,20 @@ Standardize, mean center, or scale by standard deviation selected variables in a regression model and refit the model } \details{ +\subsection{NOTE}{ + +For standardizing only selected variables and for properly +standardizing product terms in regression models fitted by +\code{stats::lm()}, the function \href{https://sfcheung.github.io/betaselectr/articles/betaselectr_lm.html}{\code{lm_betaselect()}} +from \href{https://sfcheung.github.io/betaselectr/}{\code{betaselectr}} +can be used instead of \code{std_selected()} and \code{std_selected_boot()}. +The package also has supports models fitted by \code{stats::glm()}, +such as logistic regression models. See \href{https://sfcheung.github.io/betaselectr/articles/betaselectr_glm.html}{this article} +for a demonstration. +} + +\subsection{Details}{ + \code{\link[=std_selected]{std_selected()}} was originally developed to compute the standardized moderation effect and the standardized coefficients for other predictors given an \code{\link[=lm]{lm()}} output (Cheung, Cheung, Lau, Hui, & Vong, 2022). @@ -128,6 +142,7 @@ rescaled by its standard deviation. Therefore, if the goal is to get the standardized solution of a moderated regression, users just instruct the function to standardize all non-categorical variables in the regression model. +} \code{\link[=std_selected_boot]{std_selected_boot()}} is a wrapper of \code{\link[=std_selected]{std_selected()}}. It calls \code{\link[=std_selected]{std_selected()}} diff --git a/man/stdmod-package.Rd b/man/stdmod-package.Rd index 259c286..75ab845 100644 --- a/man/stdmod-package.Rd +++ b/man/stdmod-package.Rd @@ -20,6 +20,11 @@ Useful links: \author{ \strong{Maintainer}: Shu Fai Cheung \email{shufai.cheung@gmail.com} (\href{https://orcid.org/0000-0002-9871-9448}{ORCID}) +Authors: +\itemize{ + \item Shu Fai Cheung \email{shufai.cheung@gmail.com} (\href{https://orcid.org/0000-0002-9871-9448}{ORCID}) +} + Other contributors: \itemize{ \item David Weng Ngai Vong [contributor] diff --git a/man/stdmod_lavaan.Rd b/man/stdmod_lavaan.Rd index a007772..ebb6483 100644 --- a/man/stdmod_lavaan.Rd +++ b/man/stdmod_lavaan.Rd @@ -85,6 +85,19 @@ equation model fitted by \code{\link[lavaan:lavaan]{lavaan::lavaan()}} or its wr form the nonparametric bootstrap confidence interval. } \details{ +\subsection{NOTE}{ + +For standardizing only selected variables in models fitted +by \code{lavaan}, \code{lavaan} natively supports this since version 0.7-2, +through setting \code{type} to a character vector of the variables +to be standardized. Alternatively, the function \href{https://sfcheung.github.io/betaselectr/articles/betaselectr_lav.html}{\code{lav_betaselect()}} +from \href{https://sfcheung.github.io/betaselectr/}{\code{betaselectr}} +can also be used. \href{https://sfcheung.github.io/betaselectr/reference/lav_betaselect.html}{\code{lav_betaselect()}} +also supports properly standardizing a product term. In addition +to bootstrap confidence intervals, \href{https://sfcheung.github.io/betaselectr/reference/lav_betaselect.html}{\code{lav_betaselect()}} +also supports delta-method confidence intervals. +} + \subsection{Important Notes}{ Starting from Version 0.2.7.5, of \code{\link[=stdmod_lavaan]{stdmod_lavaan()}} adopts an approach From 82cb4b99e2d0cf7bd9c06443a5f718d603428ee0 Mon Sep 17 00:00:00 2001 From: Shu Fai Cheung Date: Thu, 23 Jul 2026 21:10:16 +0800 Subject: [PATCH 5/6] Bump the version to 0.2.14 --- DESCRIPTION | 2 +- NEWS.md | 11 ++++++++++- README.md | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 002be16..4182634 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: stdmod Title: Standardized Moderation Effect and Its Confidence Interval -Version: 0.2.13 +Version: 0.2.14 Authors@R: c(person(given = "Shu Fai", family = "Cheung", diff --git a/NEWS.md b/NEWS.md index 1b6772f..2e36a8a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,13 @@ -# stdmod 0.2.13 +# stdmod 0.2.14 + +## Miscellaneous + +- Updated README and other files to + refer users to `manymome` and `betaselectr` + for more advanced functions. + (0.2.14) + +# stdmod 0.2.14 ## Miscellaneous diff --git a/README.md b/README.md index 5af5cc8..696b16e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ # stdmod: Standardized Moderation -(Version 0.2.13, updated on 2026-05-04, [release history](https://sfcheung.github.io/stdmod/news/index.html)) +(Version 0.2.14, updated on 2026-07-23, [release history](https://sfcheung.github.io/stdmod/news/index.html)) **IMPORTANT NOTICE** From 61df945294ae4748747ea86cd944b17598363169 Mon Sep 17 00:00:00 2001 From: Shu Fai Cheung Date: Thu, 23 Jul 2026 21:10:38 +0800 Subject: [PATCH 6/6] Add devel to R-CMD-check --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 531ebcb..dc5e904 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -4,7 +4,7 @@ on: push: branches: [main, master] pull_request: - branches: [main, master] + branches: [main, master, devel] name: R-CMD-check