easystats / parameters

:bar_chart: Computation and processing of models' parameters
https://easystats.github.io/parameters/
GNU General Public License v3.0
438 stars 36 forks source link

Return at least one effect size measure for `htest` and `BFBayesFactor` objects #802

Open IndrajeetPatil opened 2 years ago

IndrajeetPatil commented 2 years ago

Given that most users will stick to the defaults most of the time, they might not even realize that we support this functionality, which would be a shame. It'd be nice if we return at least one effect size by default. The default can be whatever effectsize::effectsize() defaults to.

This is especially relevant for objects that don't have estimates in their tidied data frames:

suppressPackageStartupMessages({
  library(parameters)
  library(BayesFactor)
})
data("raceDolls")

m <- contingencyTableBF(
  raceDolls,
  sampleType = "indepMulti",
  fixedMargin = "cols"
)

parameters(m)
#> Warning: Could not estimate a good default ROPE range. Using 'c(-0.1, 0.1)'.
#> Bayesian contingency table analysis
#> 
#> Parameter |                            Prior |   BF
#> ---------------------------------------------------
#> Ratio     | Independent multinomial (0 +- 1) | 1.81
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.

parameters(m, effectsize_type = "cramers_v")
#> Warning: Could not estimate a good default ROPE range. Using 'c(-0.1, 0.1)'.
#> Bayesian contingency table analysis
#> 
#> Parameter | Cramer's V (adj.) | Cramers 95% CI |                            Prior |   BF
#> ----------------------------------------------------------------------------------------
#> Ratio     |              0.15 |   [0.00, 0.29] | Independent multinomial (0 +- 1) | 1.81
#> 
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed) computed
#>   using a MCMC distribution approximation.

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

strengejacke commented 2 years ago

Can you take care of this? I think it's just setting a reasonable default for the different effectsizes (like model_parameters for aov, BFBayesFactor etc.)

mattansb commented 2 years ago

If you pass type = NULL to effectsize () it will return a default effect size - so you can just always pass that argument as is!

strengejacke commented 2 years ago

It's indeed a bit more difficult to provide an explicit value. We have model_parameters.htest(), but different default effect sizes. Maybe it's indeed better to just pass NULL by default, but this requires some larger code revisions than just changing an argument value.

strengejacke commented 2 years ago

I think the tricky stuff will be to find out the effectsize-type when this argument is NULL, because this is required: https://github.com/easystats/parameters/blob/51adc1ca52325833e5cb1e4bd87e3bac42397c5a/R/methods_htest.R#L626-L638

DominiqueMakowski commented 2 years ago

I would use "default" in parameters instead of NULL (which should be to not return anything)

strengejacke commented 2 years ago

Yeah, but this still doesn't solve the problem how to detect which effect size was computed (https://github.com/easystats/parameters/issues/802#issuecomment-1294619609)... :-(

mattansb commented 2 years ago

I think the tricky stuff will be to find out the effectsize-type when this argument is NULL, because this is required:

Why do you need that code? What are you trying do do that isn't covered by effectsize::is_effectsize_name() or effectsize::get_effectsize_name()?

strengejacke commented 2 years ago

So this works on the column names of the returned data frame from effectsize()? I think the returned effect size names differ from those values in the mentioned switch() statement, I need to check whether this breaks any code, maybe in conjunction with format_table().