amices / mice

Multivariate Imputation by Chained Equations
https://amices.org/mice/
GNU General Public License v2.0
441 stars 107 forks source link

pool() on lavaan objects gives error: illegal arguments passed to lavaan::parameterEstimates #614

Closed Gootjes closed 5 months ago

Gootjes commented 8 months ago

Before submitting the issue

Describe the bug Invalid arguments passed to lavaan::parameterEstimates via broom::tidy.lavaan raise an error. Invalid arguments are passed here: https://github.com/amices/mice/blob/c924a7473ea2a95a551ca54479557877defb6423/R/summary.R#L23

To Reproduce

library(lavaan)
#> This is lavaan 0.6-15
#> lavaan is FREE software! Please report any bugs.
library(mice)
#> 
#> Attaching package: 'mice'
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following objects are masked from 'package:base':
#> 
#>     cbind, rbind
pool(list(sem("mpg ~ cyl", data = mtcars[1:10,]), sem("mpg ~ cyl", data = mtcars[1:20,])), dfcom = 18)
#> Warning: The `exponentiate` argument is not supported in the `tidy()` method
#> for `lavaan` objects and will be ignored.
#> Error in `purrr::keep()`:
#> ℹ In index: 1.
#> ℹ With name: estimate.
#> Caused by error in `lavaan::parameterEstimates()`:
#> ! unused arguments (effects = "fixed", parametric = TRUE, exponentiate = FALSE)
#> Backtrace:
#>      ▆
#>   1. ├─mice::pool(...)
#>   2. │ └─mice:::pool.fitlist(...)
#>   3. │   ├─base::summary(fitlist, type = "tidy", exponentiate = FALSE)
#>   4. │   └─mice:::summary.mira(fitlist, type = "tidy", exponentiate = FALSE)
#>   5. │     ├─... %>% bind_rows()
#>   6. │     └─base::lapply(...)
#>   7. │       ├─generics (local) FUN(X[[i]], ...)
#>   8. │       └─broom:::tidy.lavaan(X[[i]], ...)
#>   9. │         └─... %>% as_tibble()
#>  10. ├─dplyr::bind_rows(.)
#>  11. │ └─rlang::list2(...)
#>  12. ├─tibble::as_tibble(.)
#>  13. ├─dplyr::select(...)
#>  14. ├─broom:::rename2(...)
#>  15. │ └─purrr::keep(dots, ~quo_name(.x) %in% colnames(.data))
#>  16. │   └─purrr:::where_if(.x, .p, ...)
#>  17. │     └─purrr:::map_(.x, .p, ..., .type = "logical", .purrr_error_call = .purrr_error_call)
#>  18. │       ├─purrr:::with_indexed_errors(...)
#>  19. │       │ └─base::withCallingHandlers(...)
#>  20. │       ├─purrr:::call_with_cleanup(...)
#>  21. │       └─purrr (local) .f(.x[[i]], ...)
#>  22. │         └─broom (local) .fn(...)
#>  23. │           ├─quo_name(.x) %in% colnames(.data)
#>  24. │           └─base::colnames(.data)
#>  25. │             └─base::is.data.frame(x)
#>  26. ├─dplyr::mutate(., term = paste(lhs, op, rhs))
#>  27. ├─tibble::rownames_to_column(.)
#>  28. ├─tibble::as_tibble(.)
#>  29. └─base::.handleSimpleError(...)
#>  30.   └─purrr (local) h(simpleError(msg, call))
#>  31.     └─cli::cli_abort(...)
#>  32.       └─rlang::abort(...)

Created on 2024-01-14 with reprex v2.0.2

Expected behavior Pooled results for lavaan fit objects.

Screenshots ~If applicable, add screenshots to help explain your problem.~

Additional context ~Add any other context about the problem here.~

stefvanbuuren commented 5 months ago

Fixed in mice 3.16.9