Skip to content

Commit f7a48f8

Browse files
authored
Merge pull request #216 from sfcheung/devel
Finalize to 0.2.8
2 parents 0484a46 + 99d7b14 commit f7a48f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+303
-230
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: manymome
22
Title: Mediation, Moderation and Moderated-Mediation After Model Fitting
3-
Version: 0.2.7.1
3+
Version: 0.2.8
44
Authors@R:
55
c(person(given = "Shu Fai",
66
family = "Cheung",
@@ -34,7 +34,7 @@ Suggests:
3434
rmarkdown,
3535
semPlot,
3636
semptools,
37-
semTools,
37+
lavaan.mi,
3838
Amelia,
3939
mice,
4040
testthat (>= 3.0.0)

NEWS.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
# manymome 0.2.7.1
1+
# manymome 0.2.8
22

33
## New Features
44

5+
- Updated to use `lavaan.mi` instead of
6+
`semTools`. (0.2.7.2, 0.2.7.3)
7+
8+
## Miscellaneous
9+
510
- Added the option to disable the
611
computation of implied statistics
712
in `do_boot()` and `do_mc()`. This
@@ -12,6 +17,15 @@
1217
only by developers and advanced users.
1318
(0.2.7.1)
1419

20+
- Moved `compute_implied_stats` to the
21+
end of the argument list to avoid
22+
conflicting with calls that do not
23+
name the arguments. (0.2.7.4)
24+
25+
- Revised `mod_levels()` to prepare
26+
for latent variable moderation.
27+
(0.2.7.5)
28+
1529
# manymome 0.2.7
1630

1731
## New Features

R/boot2est_lavaan.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ fit2boot_out <- function(fit,
182182
fit2boot_out_do_boot <- function(fit,
183183
R = 100,
184184
seed = NULL,
185-
compute_implied_stats = TRUE,
186185
parallel = FALSE,
187186
ncores = max(parallel::detectCores(logical = FALSE) - 1, 1),
188187
make_cluster_args = list(),
189188
progress = TRUE,
189+
compute_implied_stats = TRUE,
190190
internal = list()) {
191191
if (identical(internal$gen_boot, "update")) {
192192
environment(gen_boot_i_update) <- parent.frame()

R/boot2est_lm.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@
107107
#'
108108

109109
lm2boot_out <- function(outputs, R = 100,
110-
compute_implied_stats = TRUE,
111110
seed = NULL,
112-
progress = TRUE) {
111+
progress = TRUE,
112+
compute_implied_stats = TRUE) {
113113
if (!missing(outputs)) {
114114
outputs <- auto_lm2list(outputs)
115115
}
@@ -193,11 +193,11 @@ lm_boot2est_i <- function(d, i = NULL, outputs,
193193
lm2boot_out_parallel <- function(outputs,
194194
R = 100,
195195
seed = NULL,
196-
compute_implied_stats = TRUE,
197196
parallel = FALSE,
198197
ncores = max(parallel::detectCores(logical = FALSE) - 1, 1),
199198
make_cluster_args = list(),
200-
progress = TRUE) {
199+
progress = TRUE,
200+
compute_implied_stats = TRUE) {
201201
if (!missing(outputs)) {
202202
outputs <- auto_lm2list(outputs)
203203
}

R/check_path.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#' It also support
1515
#' `lavaan.mi` objects
1616
#' returned by
17-
#' [semTools::runMI()] or
18-
#' its wrapper, such as [semTools::sem.mi()].
17+
#' [lavaan.mi::lavaan.mi()] or
18+
#' its wrapper, such as [lavaan.mi::sem.mi()].
1919
#'
2020
#' For example, in the following model
2121
#' in `lavaan` syntax
@@ -44,8 +44,8 @@
4444
#' It can also be
4545
#' a `lavaan.mi` object
4646
#' returned by
47-
#' [semTools::runMI()] or
48-
#' its wrapper, such as [semTools::sem.mi()].
47+
#' [lavaan.mi::lavaan.mi()] or
48+
#' its wrapper, such as [lavaan.mi::sem.mi()].
4949
#' If it is a single model fitted by
5050
#' [lm()], it will be automatically converted
5151
#' to a list by [lm2list()].

R/cond_indirect.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' effects, indirect effects, or
66
#' conditional indirect effects in a
77
#' structural model fitted by [lm()],
8-
#' [lavaan::sem()], or [semTools::sem.mi()].
8+
#' [lavaan::sem()], or [lavaan.mi::sem.mi()].
99
#'
1010
#' @details
1111
#'
@@ -199,8 +199,8 @@
199199
#' It can also be
200200
#' a `lavaan.mi` object
201201
#' returned by
202-
#' [semTools::runMI()] or
203-
#' its wrapper, such as [semTools::sem.mi()].
202+
#' [lavaan.mi::lavaan.mi()] or
203+
#' its wrapper, such as [lavaan.mi::sem.mi()].
204204
#' If it is a single model fitted by
205205
#' [lm()], it will be automatically converted
206206
#' to a list by [lm2list()].

R/do_boot.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@
142142

143143
do_boot <- function(fit,
144144
R = 100,
145-
compute_implied_stats = TRUE,
146145
seed = NULL,
147146
parallel = TRUE,
148147
ncores = max(parallel::detectCores(logical = FALSE) - 1, 1),
149148
make_cluster_args = list(),
150-
progress = TRUE) {
149+
progress = TRUE,
150+
compute_implied_stats = TRUE) {
151151
if (!missing(fit)) {
152152
fit <- auto_lm2list(fit)
153153
}

R/do_mc.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#'
2323
#' It also supports a model estimated
2424
#' by multiple imputation using
25-
#' [semTools::runMI()] or its wrapper,
26-
#' such as [semTools::sem.mi()].
25+
#' [lavaan.mi::lavaan.mi()] or its wrapper,
26+
#' such as [lavaan.mi::sem.mi()].
2727
#' The pooled estimates and their
2828
#' variance-covariance matrix will be used
2929
#' to generate the Monte Carlo estimates.
@@ -65,8 +65,8 @@
6565
#' It can also be
6666
#' a `lavaan.mi` object
6767
#' returned by
68-
#' [semTools::runMI()] or
69-
#' its wrapper, such as [semTools::sem.mi()].
68+
#' [lavaan.mi::lavaan.mi()] or
69+
#' its wrapper, such as [lavaan.mi::sem.mi()].
7070
#' The output of
7171
#' [stats::lm()] is not supported.
7272
#'
@@ -136,12 +136,12 @@
136136

137137
do_mc <- function(fit,
138138
R = 100,
139-
compute_implied_stats = TRUE,
140139
seed = NULL,
141140
parallel = TRUE,
142141
ncores = max(parallel::detectCores(logical = FALSE) - 1, 1),
143142
make_cluster_args = list(),
144-
progress = TRUE) {
143+
progress = TRUE,
144+
compute_implied_stats = TRUE) {
145145
if (!missing(fit)) {
146146
fit <- auto_lm2list(fit)
147147
}

R/get_b.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#' It can also be
1212
#' a `lavaan.mi` object
1313
#' returned by
14-
#' [semTools::runMI()] or
15-
#' its wrapper, such as [semTools::sem.mi()].
14+
#' [lavaan.mi::lavaan.mi()] or
15+
#' its wrapper, such as [lavaan.mi::sem.mi()].
1616
#'
1717
#' @param est The output of
1818
#' [lavaan::parameterEstimates()]. If

R/get_intercept.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#' It can also be
1212
#' a `lavaan.mi` object
1313
#' returned by
14-
#' [semTools::runMI()] or
15-
#' its wrapper, such as [semTools::sem.mi()].
14+
#' [lavaan.mi::lavaan.mi()] or
15+
#' its wrapper, such as [lavaan.mi::sem.mi()].
1616
#'
1717
#' @param est The output of
1818
#' [lavaan::parameterEstimates()]. If

R/get_prod.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
#' It can also be
4747
#' a `lavaan.mi` object
4848
#' returned by
49-
#' [semTools::runMI()] or
50-
#' its wrapper, such as [semTools::sem.mi()].
49+
#' [lavaan.mi::lavaan.mi()] or
50+
#' its wrapper, such as [lavaan.mi::sem.mi()].
5151
#'
5252
#' @param est The output of
5353
#' [lavaan::parameterEstimates()]. If

R/index_mome.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
#' It can also be
7474
#' a `lavaan.mi` object
7575
#' returned by
76-
#' [semTools::runMI()] or
77-
#' its wrapper, such as [semTools::sem.mi()].
76+
#' [lavaan.mi::lavaan.mi()] or
77+
#' its wrapper, such as [lavaan.mi::sem.mi()].
7878
#'
7979
#' @param boot_ci Logical. Whether
8080
#' bootstrap confidence interval will be

R/indirect.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
#' It can also be
5050
#' a `lavaan.mi` object
5151
#' returned by
52-
#' [semTools::runMI()] or
53-
#' its wrapper, such as [semTools::sem.mi()].
52+
#' [lavaan.mi::lavaan.mi()] or
53+
#' its wrapper, such as [lavaan.mi::sem.mi()].
5454
#'
5555
#' @param est The output of
5656
#' [lavaan::parameterEstimates()]. If

R/indirect_proportion.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
#' It can also be
6262
#' a `lavaan.mi` object
6363
#' returned by
64-
#' [semTools::runMI()] or
65-
#' its wrapper, such as [semTools::sem.mi()].
64+
#' [lavaan.mi::lavaan.mi()] or
65+
#' its wrapper, such as [lavaan.mi::sem.mi()].
6666
#'
6767
#'
6868
#' @references

R/lav_data_used.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#' It can also be
88
#' a `lavaan.mi` object
99
#' returned by
10-
#' [semTools::runMI()] or
11-
#' its wrapper, such as [semTools::sem.mi()].
10+
#' [lavaan.mi::lavaan.mi()] or
11+
#' its wrapper, such as [lavaan.mi::sem.mi()].
1212
#'
1313
#' @param drop_colon Logical. Whether
1414
#' product terms (of the form "x:y")

R/lavaan_helpers.R

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ lav_implied_all_lavaan_mi <- function(fit,
5050
group_number = NULL) {
5151
est0 <- methods::getMethod("coef",
5252
signature = "lavaan.mi",
53-
where = asNamespace("semTools"))(fit)
53+
where = asNamespace("lavaan.mi"))(fit)
5454
out <- get_implied_i_lavaan_mi(est0 = est0,
5555
fit = fit)
5656
out
@@ -90,7 +90,7 @@ get_vcov_lavaan <- function(object) {
9090
get_vcov_lavaan_mi <- function(object) {
9191
methods::getMethod("vcov",
9292
signature = "lavaan.mi",
93-
where = asNamespace("semTools"))(object,
93+
where = asNamespace("lavaan.mi"))(object,
9494
type = "pooled",
9595
scale.W = TRUE,
9696
omit.imps = c("no.conv", "no.se"))
@@ -139,11 +139,7 @@ lav_est_lavaan_mi <- function(fit,
139139
...,
140140
est_df = NULL) {
141141
if (is.null(est_df)) {
142-
est_df <- methods::getMethod("summary",
143-
signature = "lavaan.mi",
144-
where = asNamespace("semTools"))(fit,
145-
output = "data.frame",
146-
...)
142+
est_df <- lavaan.mi::parameterEstimates.mi(fit)
147143
}
148144
ptable <- as.data.frame(fit@ParTable)
149145
if (!is.null(ptable$est)) {
@@ -187,7 +183,7 @@ lav_ptable_lavaan_mi <- function(fit, ...) {
187183
out <- lavaan::parameterTable(fit)
188184
coef_mi <- methods::getMethod("coef",
189185
signature = "lavaan.mi",
190-
where = asNamespace("semTools"))(fit)
186+
where = asNamespace("lavaan.mi"))(fit)
191187
se_mi <- sqrt(diag(get_vcov(fit)))
192188
id_free <- out$free > 0
193189
out$est <- NA

R/mc2est_lavaan.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
#' It can also be
5555
#' a `lavaan.mi` object
5656
#' returned by
57-
#' [semTools::runMI()] or
58-
#' its wrapper, such as [semTools::sem.mi()].
57+
#' [lavaan.mi::lavaan.mi()] or
58+
#' its wrapper, such as [lavaan.mi::sem.mi()].
5959
#'
6060
#' @param compute_implied_stats If
6161
#' `TRUE`, default, implied statistics
@@ -101,8 +101,8 @@
101101
#' @export
102102

103103
fit2mc_out <- function(fit,
104-
compute_implied_stats = TRUE,
105-
progress = TRUE) {
104+
progress = TRUE,
105+
compute_implied_stats = TRUE) {
106106
if (progress) {
107107
cat("Stage 1: Simulate estimates\n")
108108
}

R/mod_levels.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
#' It can also be
5555
#' a `lavaan.mi` object
5656
#' returned by
57-
#' [semTools::runMI()] or
58-
#' its wrapper, such as [semTools::sem.mi()].
57+
#' [lavaan.mi::lavaan.mi()] or
58+
#' its wrapper, such as [lavaan.mi::sem.mi()].
5959
#' If it is a single model fitted by
6060
#' [lm()], it will be automatically converted
6161
#' to a list by [lm2list()].
@@ -394,7 +394,9 @@ mod_levels_i_lavaan_numerical <- mod_levels_i_lm_numerical <- function(fit,
394394
rownames(out) <- vnames
395395
colnames(out) <- w
396396
}
397-
w_dat <- mm[, w]
397+
if (w_method %in% c("sd", "percentile")) {
398+
w_dat <- mm[, w]
399+
}
398400
if (w_method == "sd") {
399401
w_mean <- mean(w_dat, na.rm = TRUE)
400402
w_sd <- stats::sd(w_dat, na.rm = TRUE)

R/pseudo_jn.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#'
5353
#' This function supports models fitted
5454
#' by [lm()], [lavaan::sem()],
55-
#' and [semTools::sem.mi()]. This function
55+
#' and [lavaan.mi::sem.mi()]. This function
5656
#' also supports both bootstrapping
5757
#' and Monte Carlo confidence intervals.
5858
#' It also supports conditional

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![R-CMD-check](https://github.com/sfcheung/manymome/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/sfcheung/manymome/actions/workflows/R-CMD-check.yaml)
1010
<!-- badges: end -->
1111

12-
(Version 0.2.7.1, updated on 2025-02-22, [release history](https://sfcheung.github.io/manymome/news/index.html))
12+
(Version 0.2.8, updated on 2025-05-03, [release history](https://sfcheung.github.io/manymome/news/index.html))
1313

1414
# manymome <img src="man/figures/logo.png" align="right" height="150" />
1515

@@ -97,9 +97,12 @@ by multiple regression. The package was introduced in:
9797
Supports datasets with missing data
9898
through `lavaan::sem()` with full information maximum likelihood (`fiml`).
9999

100-
In version 0.1.9.8 or later, it also supports missing data handled
101-
by multiple imputation if the models are fitted by `semTools::sem.mi()`
102-
or `semTools::runMI()` (see `vignette("do_mc_lavaan_mi")`).
100+
In version 0.2.7.3 or later, it also supports missing data handled
101+
by multiple imputation if the models are fitted by `lavaan.mi::sem.mi()`
102+
or `lavaan.mi::lavaan.mi()` (see `vignette("do_mc_lavaan_mi")`).
103+
(Support for `semTools::runMI()` and its wrappers was removed in
104+
version 0.2.7.3 because this and related functions were deprecated
105+
in `semTools`.)
103106

104107
- **Supports Numeric and Categorical Moderators**
105108

data-raw/test_mi_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#' #Create MI datasets for testing
22

33
suppressMessages(library(lavaan))
4-
suppressMessages(library(semTools))
4+
suppressMessages(library(lavaan.mi))
55
suppressMessages(library(Amelia))
66

77
# Categorical IVs in lavaan

inst/extdata/mi_test_data.RData

-12.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)