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

Add method for Chi2 #393

Merged
merged 6 commits into from
Sep 30, 2023
Merged

Add method for Chi2 #393

merged 6 commits into from
Sep 30, 2023

Conversation

rempsyc
Copy link
Member

@rempsyc rempsyc commented Sep 24, 2023

Add full support for Chi2: closes #258 and closes #309

For independence

library(report)
htest <- chisq.test(mtcars$cyl, mtcars$am)
report(htest)
#> Effect sizes were labelled following Funder's (2019) recommendations.
#> 
#> The Pearson's Chi-squared test of independence between mtcars$cyl and mtcars$am
#> suggests that the effect is statistically significant, and very large (chi2 =
#> 8.74, p = 0.013; Adjusted Cramer's v = 0.46, 95% CI [0.00, 1.00])

For goodness of fit

htest <- chisq.test(table(mtcars$cyl), p = c(0.1, 0.3, 0.6))

report(htest)
#> 
#> 
#> The Chi-squared test for given probabilities / goodness of fit of
#> table(mtcars$cyl) to a distribution of [4: n=3.2, 6: n=9.6, 8: n=19.2] suggests
#> that the effect is statistically significant, and (chi2 = 21.12, p < .001; Fei
#> = 0.27, 95% CI [0.17, 1.00])

htest <- chisq.test(table(c(mtcars$cyl, 2)), p = c(0.25, 0.25, 0.25, 0.25))

report(htest)
#> 
#> 
#> The Chi-squared test for given probabilities / goodness of fit of
#> table(c(mtcars$cyl, 2)) to a uniform distribution suggests that the effect is
#> statistically significant, and (chi2 = 11.48, p = 0.009; Fei = 0.34, 95% CI
#> [0.13, 1.00])

Created on 2023-09-23 with reprex v2.0.2

Note: Fei is missing interpretation at this time but should be fixed following easystats/effectsize#608

@codecov
Copy link

codecov bot commented Sep 24, 2023

Codecov Report

Merging #393 (e519a00) into main (661459b) will increase coverage by 0.29%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

❗ Current head e519a00 differs from pull request most recent head 0c74694. Consider uploading reports for the commit 0c74694 to get more accurate results

@@            Coverage Diff             @@
##             main     #393      +/-   ##
==========================================
+ Coverage   73.51%   73.81%   +0.29%     
==========================================
  Files          48       48              
  Lines        3391     3425      +34     
==========================================
+ Hits         2493     2528      +35     
+ Misses        898      897       -1     
Files Coverage Δ
R/report.htest.R 91.66% <100.00%> (+0.14%) ⬆️
R/report_htest_chi2.R 93.90% <100.00%> (+5.66%) ⬆️

@rempsyc rempsyc merged commit da67740 into main Sep 30, 2023
26 checks passed
@rempsyc rempsyc deleted the chi2_method branch September 30, 2023 19:35
@IndrajeetPatil
Copy link
Member

Thanks, @rempsyc!

@rempsyc
Copy link
Member Author

rempsyc commented Oct 22, 2023

@IndrajeetPatil you're welcome :) I merged this without review before, but now that you are back, feel free to review those changes (or perhaps the thanks was the symbolic approval already hehe)

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