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

supporting multiple effect sizes in effectsize::effectsize for htest objects #214

Closed
IndrajeetPatil opened this issue Nov 29, 2020 · 10 comments
Labels
enhancement 🔥 New feature or request
Milestone

Comments

@IndrajeetPatil
Copy link
Member

As mentioned in easystats/parameters#354 (comment), creating a separate issue to see if it will be possible to support multiple effect sizes in effectsize::effectsize for htest objects

@IndrajeetPatil IndrajeetPatil added the enhancement 🔥 New feature or request label Nov 29, 2020
mattansb added a commit that referenced this issue Dec 2, 2020
@mattansb
Copy link
Member

mattansb commented Dec 2, 2020

Added type argument to

  • htest:
    • chisq.test
    • oneway.test
  • BFBayesfactor
    • contingencyTableBF
  • aov / anova / aovlist

@mattansb

This comment has been minimized.

@mattansb

This comment has been minimized.

@mattansb
Copy link
Member

Closing this in favor of #211 and #224

@IndrajeetPatil
Copy link
Member Author

I am not sure if either of #211 or #224 cover this, but this is yet to be supported:

library(effectsize)
Ts <- t.test(1:10, y = c(7:20))
effectsize(Ts, type = "g")
#>     d |         95% CI
#> ----------------------
#> -2.32 | [-3.38, -1.22]

Created on 2020-12-30 by the reprex package (v0.3.0)

mattansb added a commit that referenced this issue Dec 30, 2020
@mattansb
Copy link
Member

Fixed (:

library(effectsize)
Ts <- t.test(1:10, y = c(7:20))
effectsize(Ts, type = "g")
#> Hedge's g |         95% CI
#> --------------------------
#>     -2.12 | [-3.17, -1.15]
#> 
#> - Estimated using un-pooled SD.
#> - Bias corrected using Hedges and Olkin's method.

Created on 2020-12-30 by the reprex package (v0.3.0)

@IndrajeetPatil
Copy link
Member Author

Did something change with effectsize? I can no longer seem to get Hedge's g:

as.data.frame(effectsize::effectsize(
  t.test(extra ~ group, data = sleep),
  type = "cohens_d"
))
#> Warning in effectsize.htest(t.test(extra ~ group, data = sleep), type =
#> "cohens_d"): Unable to retrieve data from htest object. Using t_to_d()
#> approximation.
#>            d   CI    CI_low   CI_high
#> 1 -0.8826937 0.95 -1.844756 0.1018923

as.data.frame(effectsize::effectsize(
  t.test(extra ~ group, data = sleep),
  type = "hedges_g"
))
#> Warning in effectsize.htest(t.test(extra ~ group, data = sleep), type =
#> "hedges_g"): Unable to retrieve data from htest object. Using t_to_d()
#> approximation.
#>            d   CI    CI_low   CI_high
#> 1 -0.8826937 0.95 -1.844756 0.1018923

Created on 2021-01-03 by the reprex package (v0.3.0.9001)

Discovered this while working on easystats/parameters#386.

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                                             
#>  version  R Under development (unstable) (2020-12-28 r79717)
#>  os       Windows 10 x64                                    
#>  system   x86_64, mingw32                                   
#>  ui       RTerm                                             
#>  language (EN)                                              
#>  collate  English_United States.1252                        
#>  ctype    English_United States.1252                        
#>  tz       Europe/Berlin                                     
#>  date     2021-01-03                                        
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version    date       lib source                               
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.1.0)                       
#>  backports     1.2.1      2020-12-09 [1] CRAN (R 4.1.0)                       
#>  bayestestR    0.8.0.1    2021-01-03 [1] Github (easystats/bayestestR@8b13219)
#>  cli           2.2.0      2020-11-20 [1] CRAN (R 4.1.0)                       
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 4.1.0)                       
#>  digest        0.6.27     2020-10-24 [1] CRAN (R 4.1.0)                       
#>  effectsize    0.4.1.2    2021-01-03 [1] Github (easystats/effectsize@946f9cb)
#>  ellipsis      0.3.1      2020-05-15 [1] CRAN (R 4.1.0)                       
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.1.0)                       
#>  fansi         0.4.1      2020-01-08 [1] CRAN (R 4.1.0)                       
#>  fs            1.5.0      2020-07-31 [1] CRAN (R 4.1.0)                       
#>  glue          1.4.2      2020-08-27 [1] CRAN (R 4.1.0)                       
#>  highr         0.8        2019-03-20 [1] CRAN (R 4.1.0)                       
#>  htmltools     0.5.0      2020-06-16 [1] CRAN (R 4.1.0)                       
#>  insight       0.11.1.1   2021-01-03 [1] Github (easystats/insight@f4749fc)   
#>  knitr         1.30       2020-09-22 [1] CRAN (R 4.1.0)                       
#>  lifecycle     0.2.0      2020-03-06 [1] CRAN (R 4.1.0)                       
#>  magrittr      2.0.1      2020-11-17 [1] CRAN (R 4.1.0)                       
#>  parameters    0.10.1.1   2021-01-03 [1] local                                
#>  pillar        1.4.7      2020-11-20 [1] CRAN (R 4.1.0)                       
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.1.0)                       
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.1.0)                       
#>  reprex        0.3.0.9001 2020-08-15 [1] Github (tidyverse/reprex@23a3462)    
#>  rlang         0.4.10     2020-12-30 [1] CRAN (R 4.1.0)                       
#>  rmarkdown     2.6        2020-12-14 [1] CRAN (R 4.1.0)                       
#>  rstudioapi    0.13       2020-11-12 [1] CRAN (R 4.1.0)                       
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.1.0)                       
#>  stringi       1.5.3      2020-09-09 [1] CRAN (R 4.1.0)                       
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.1.0)                       
#>  styler        1.3.2.9000 2021-01-03 [1] Github (r-lib/styler@e1688f5)        
#>  tibble        3.0.4      2020-10-12 [1] CRAN (R 4.1.0)                       
#>  vctrs         0.3.6      2020-12-17 [1] CRAN (R 4.1.0)                       
#>  withr         2.3.0      2020-09-22 [1] CRAN (R 4.1.0)                       
#>  xfun          0.19       2020-10-30 [1] CRAN (R 4.1.0)                       
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.1.0)                       
#> 
#> [1] C:/Users/inp099/Documents/R/win-library/4.1
#> [2] C:/Program Files/R/R-devel/library

@IndrajeetPatil IndrajeetPatil reopened this Jan 3, 2021
@mattansb
Copy link
Member

mattansb commented Jan 3, 2021

insight::get_data.htest cannot retrieve data from objects with a formula and data = <something>.

# yup
insight::get_data(
  t.test(sleep$extra[sleep$group==1], sleep$extra[sleep$group==2])
)
#>       x    y
#> 1   0.7  1.9
#> 2  -1.6  0.8
#> 3  -0.2  1.1
#> 4  -1.2  0.1
#> 5  -0.1 -0.1
#> 6   3.4  4.4
#> 7   3.7  5.5
#> 8   0.8  1.6
#> 9   0.0  4.6
#> 10  2.0  3.4

# yup
insight::get_data(
  t.test(sleep$extra ~ sleep$group)
)
#>       x y
#> 1   0.7 1
#> 2  -1.6 1
#> 3  -0.2 1
#> 4  -1.2 1
#> 5  -0.1 1
#> 6   3.4 1
#> 7   3.7 1
#> 8   0.8 1
#> 9   0.0 1
#> 10  2.0 1
#> 11  1.9 2
#> 12  0.8 2
#> 13  1.1 2
#> 14  0.1 2
#> 15 -0.1 2
#> 16  4.4 2
#> 17  5.5 2
#> 18  1.6 2
#> 19  4.6 2
#> 20  3.4 2

# nope
insight::get_data(
  t.test(extra ~ group, data = sleep)
)
#> NULL

Created on 2021-01-03 by the reprex package (v0.3.0)

@mattansb mattansb closed this as completed Jan 3, 2021
@IndrajeetPatil
Copy link
Member Author

Thanks!

So when data is not found, effectsize::effectsize uses an approximation here:

#> Warning in effectsize.htest(t.test(extra ~ group, data = sleep), type =
#> "hedges_g"): Unable to retrieve data from htest object. Using t_to_d()
#> approximation.

I am wondering if effectsize::effectsize can use a similar trick for computing Cohen's g for McNemar' test when data is not found (easystats/insight#276)?

I see effectsize::chisq_to_cramers_v, but no effectsize::chisq_to_cohens_g, so I am guessing not?

@mattansb
Copy link
Member

mattansb commented Jan 3, 2021

I see effectsize::chisq_to_cramers_v, but no effectsize::chisq_to_cohens_g, so I am guessing not?

Correct - need the raw data for Cohen's g 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🔥 New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants