Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fisher.test() not compatible with D2() #508

Open
stefvanbuuren opened this issue Oct 25, 2022 · 0 comments
Open

fisher.test() not compatible with D2() #508

stefvanbuuren opened this issue Oct 25, 2022 · 0 comments

Comments

@stefvanbuuren
Copy link
Member

Function fisher.test() does not produce estimate and std.error components in the return value. D2() relies on pool(), and hence fails. Would be useful to have a work-around.

require(mice)
#> Loading required package: mice
#> 
#> Attaching package: 'mice'
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following objects are masked from 'package:base':
#> 
#>     cbind, rbind
data <- nhanes2
data$chl <- cut(data$chl, breaks = 2)
imp <- mice(data, print = FALSE)
fit <- with(imp, fisher.test(xtabs(~ hyp + chl)))
names(fit$analyses[[1]])
#> [1] "p.value"     "conf.int"    "estimate"    "null.value"  "alternative"
#> [6] "method"      "data.name"
D2(fit, fit0 = NULL, use = "wald")
#> Error in `summarize()`:
#> ! Problem while computing `ubar = mean(.data$std.error^2)`.
#> Caused by error in `.data$std.error`:
#> ! Column `std.error` not found in `.data`.

#> Backtrace:
#>      ▆
#>   1. ├─mice::D2(fit, fit0 = NULL, use = "wald")
#>   2. │ └─mice::pool(fit1)
#>   3. │   └─mice:::pool.fitlist(getfit(object), dfcom = dfcom, rule = rule)
#>   4. │     └─w %>% group_by(!!!syms(grp)) %>% ...
#>   5. ├─dplyr::summarize(...)
#>   6. ├─dplyr:::summarise.data.frame(...)
#>   7. │ └─dplyr:::summarise_cols(.data, dplyr_quosures(...), caller_env = caller_env())
#>   8. │   ├─base::withCallingHandlers(...)
#>   9. │   └─dplyr:::map(quosures, summarise_eval_one, mask = mask)
#>  10. │     └─base::lapply(.x, .f, ...)
#>  11. │       └─dplyr (local) FUN(X[[i]], ...)
#>  12. │         └─mask$eval_all_summarise(quo)
#>  13. ├─base::mean(.data$std.error^2)
#>  14. ├─std.error
#>  15. ├─rlang:::`$.rlang_data_pronoun`(.data, std.error)
#>  16. │ └─rlang:::data_pronoun_get(...)
#>  17. └─rlang:::abort_data_pronoun(x, call = y)
#>  18.   └─rlang::abort(msg, "rlang_error_data_pronoun_not_found", call = call)

Created on 2022-10-25 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant