IndrajeetPatil / statsExpressions

Tidy data frames and expressions with statistical summaries 📜
https://indrajeetpatil.github.io/statsExpressions/
Other
312 stars 20 forks source link

Revep check failure for {insight} #234

Closed strengejacke closed 1 year ago

strengejacke commented 1 year ago

Not sure which change in insight caused this issue, maybe we can even avoid breaking code?

══ Failed tests ════════════════════════════════════════════════════════════════  
── Error ('test-meta_random_robust.R:10:5'): meta_analysis works - robust ──────
Error in `formula.default(x, type = "yi")`: invalid formula
Backtrace:
     ▆
  1. ├─statsExpressions::meta_analysis(...) at test-meta_random_robust.R:10:4     
  2. │ └─... %>% ...
  3. ├─statsExpressions::tidy_model_parameters(...)
  4. │ ├─... %>% ...
  5. │ ├─parameters::model_parameters(model, verbose = FALSE, ...)
  6. │ └─parameters:::model_parameters.metaplus(...)
  7. │   ├─base::suppressWarnings(...)
  8. │   │ └─base::withCallingHandlers(...)
  9. │   └─parameters:::.model_parameters_generic(...)
 10. │     ├─base::do.call(".extract_parameters_generic", args)
 11. │     └─parameters:::.extract_parameters_generic(...)
 12. │       └─parameters:::.dof_method_ok(model, ci_method, type = "ci_method")  
 13. │         ├─insight::model_info(model, verbose = FALSE)
 14. │         └─insight:::model_info.metaplus(model, verbose = FALSE)
 15. │           └─insight:::.make_family(x, verbose = verbose, ...)
 16. │             ├─insight::is_mixed_model(x)
 17. │             └─insight:::is_mixed_model.default(x)
 18. │               ├─insight::find_random(x)
 19. │               └─insight:::find_random.default(x)
 20. │                 ├─insight::find_formula(x, verbose = FALSE)
 21. │                 └─insight:::find_formula.metaplus(x, verbose = FALSE)
 22. │                   ├─stats::formula(x, type = "yi")
 23. │                   └─stats:::formula.default(x, type = "yi")
 24. ├─dplyr::mutate(., across(matches("bf10"), ~log(.x), .names = "log_e_{.col}"))
 25. ├─tidyr::fill(., matches("^prior|^bf"), .direction = "updown")
 26. ├─dplyr::rename_all(., .funs = recode, bayes.factor = "bf10")
 27. │ └─dplyr::tbl_vars(.tbl)
 28. │   ├─dplyr:::new_sel_vars(tbl_vars_dispatch(x), group_vars(x))
 29. │   │ └─base::structure(...)
 30. │   └─dplyr:::tbl_vars_dispatch(x)
 31. ├─dplyr::rename_all(., ~gsub("cramers.", "", .x))
 32. │ └─dplyr::tbl_vars(.tbl)
 33. │   ├─dplyr:::new_sel_vars(tbl_vars_dispatch(x), group_vars(x))
 34. │   │ └─base::structure(...)
 35. │   └─dplyr:::tbl_vars_dispatch(x)
 36. ├─insight::standardize_names(., style = "broom")
 37. ├─dplyr::select(., -matches("Difference"))
 38. └─dplyr::mutate(., conf.method = . %@% "ci_method")

[ FAIL 1 | WARN 0 | SKIP 51 | PASS 25 ]
Error: Test failures
Execution halted
strengejacke commented 1 year ago

I think this is due to https://github.com/easystats/insight/pull/514, where find_formula() for rma was implemented, and methods for other meta-analysis packages redirected to find_formula.rma(). I reverted this change for meta-plus package.

strengejacke commented 1 year ago

The new issue I see now is:

library(metaplus)
#> 
#> Note: The second parameter is the study standard error not the standard error squared as in the metafor package.
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
data(mag, package = "metaplus")
dat <- mag %>% rename(estimate = yi, std.error = sei)

set.seed(123)
df <- statsExpressions::meta_analysis(
  data = dat,
  type = "robust",
  random = "normal"
)
#> Error in seq_len(nrow(mf)): argument must be coercible to non-negative integer

Created on 2023-03-15 with reprex v2.0.2

strengejacke commented 1 year ago

ok, also related to that PR. Works now, no revdep-issue here.

library(metaplus)
#> 
#> Note: The second parameter is the study standard error not the standard error squared as in the metafor package.
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
data(mag, package = "metaplus")
dat <- mag %>% rename(estimate = yi, std.error = sei)

set.seed(123)
statsExpressions::meta_analysis(
  data = dat,
  type = "robust",
  random = "normal"
)
#> # A tibble: 1 × 14
#>   term    effectsize                     estimate std.error conf.low conf.high
#>   <chr>   <chr>                             <dbl>     <dbl>    <dbl>     <dbl>
#> 1 Overall meta-analytic summary estimate   -0.746     0.234    -1.26    -0.343
#>   statistic  p.value weight conf.level method                               
#>       <dbl>    <dbl>  <dbl>      <dbl> <chr>                                
#> 1     -3.20 0.000501     NA       0.95 Robust meta-analysis using 'metaplus'
#>   conf.method n.obs expression
#>   <chr>       <int> <list>    
#> 1 Wald           16 <language>

Created on 2023-03-15 with reprex v2.0.2

IndrajeetPatil commented 1 year ago

Thanks, @strengejacke! Glad it turned out to be a non-issue.