easystats / effectsize

:dragon: Compute and work with indices of effect size and standardized parameters
https://easystats.github.io/effectsize/
Other
337 stars 23 forks source link

Partial matching #639

Closed chainsawriot closed 4 months ago

chainsawriot commented 4 months ago

Describe the bug

Partial matching is used in .anova_es.anova() (and probably many other places).

To Reproduce

options(
  warnPartialMatchArgs = TRUE,
  warnPartialMatchAttr = TRUE,
  warnPartialMatchDollar = TRUE
)

data(mtcars)
mtcars$am_f <- factor(mtcars$am)
mtcars$cyl_f <- factor(mtcars$cyl)

model <- aov(mpg ~ am_f * cyl_f, data = mtcars)

library(effectsize)
eta2 <- effectsize::eta_squared(model)
#> Warning in model_parameters.aov(model, verbose = verbose, effects = "fixed"):
#> partial argument match of 'effects' to 'effectsize_type'

sessionInfo()
#> R version 4.4.0 (2024-04-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 22.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Europe/Berlin
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] effectsize_0.8.8
#> 
#> loaded via a namespace (and not attached):
#>  [1] vctrs_0.6.5       cli_3.6.2         knitr_1.46        rlang_1.1.3      
#>  [5] xfun_0.43         estimability_1.5  purrr_1.0.2       styler_1.10.3    
#>  [9] xtable_1.8-4      glue_1.7.0        htmltools_0.5.8.1 parameters_0.21.6
#> [13] datawizard_0.10.0 rmarkdown_2.26    grid_4.4.0        R.cache_0.16.0   
#> [17] evaluate_0.23     fastmap_1.1.1     mvtnorm_1.2-4     yaml_2.3.8       
#> [21] lifecycle_1.0.4   insight_0.19.10   compiler_4.4.0    coda_0.19-4.1    
#> [25] fs_1.6.3          emmeans_1.10.1    R.oo_1.26.0       lattice_0.22-5   
#> [29] R.utils_2.12.3    digest_0.6.35     reprex_2.1.0      magrittr_2.0.3   
#> [33] R.methodsS3_1.8.2 tools_4.4.0       withr_3.0.0       bayestestR_0.13.2

Created on 2024-05-24 with reprex v2.1.0

And exactly this line:

https://github.com/easystats/effectsize/blob/43c6d0c163a56e35bbe32ed00b18491f6b864260/R/eta_squared-main.R#L836

strengejacke commented 4 months ago

Yes, there's no effects argument for the anova-method of model_parameters(), only effectsize_type.

mattansb commented 4 months ago

Sorry, why is this a bug report?

chainsawriot commented 4 months ago

It can generate a lot of warning messages for some methods (e.g. eta_squared_posterior() of a brms model, which is where I found this) when the above options are set. I know it is not default, but some R developers set them to default to prevent partial matching.

mattansb commented 4 months ago

I see.

The effect = argument actually shouldn't be partially matched, it is referring to cases where there are multiple effect types, but we only want the fixed effects (not relevant for aov or aovList models, where I thought it was just "absorbed" into ...). So although your PR fixes this issue, it causes another issue.

I will try to think of a solution.

strengejacke commented 4 months ago

Easiest is probably to rename in parameters.

mattansb commented 4 months ago

I have a solution - will post tomorrow.

mattansb commented 4 months ago

Fixed in #641

@chainsawriot if you come across any more of these, let us know.