performance icon indicating copy to clipboard operation
performance copied to clipboard

htest checks

Open mattansb opened this issue 2 years ago • 3 comments

Closes #401

  • [x] check_normality.htest
  • [x] check_homogeneity.htest
  • [x] check_symmetry.htest ?
  • [x] ~check_N.htest~ use
  • [ ] check_model.htest ?
  • [ ] plotting in {see} ?
  • [ ] Vignette
  • [ ] Tests

check_normality

library(performance)

t.test(mtcars$mpg, mtcars$hp, var.equal = TRUE) |> check_normality()
#> Warning: Non-normality of residuals detected (p < .001).

t.test(mtcars$mpg, mtcars$hp, var.equal = FALSE) |> check_normality()
#> OK: Group1 appear as normally distributed (p = 0.123).
#> Warning: Non-normality of Group2 detected (p = 0.049).

t.test(mtcars$mpg) |> check_normality()
#> OK: residuals appear as normally distributed (p = 0.123).

t.test(mtcars$mpg, mtcars$hp, paired = TRUE) |> check_normality()
#> OK: residuals appear as normally distributed (p = 0.102).

oneway.test(mtcars$mpg ~ mtcars$cyl, var.equal = FALSE) |> check_normality()
#> OK: Group1 appear as normally distributed (p = 0.261).
#> OK: Group2 appear as normally distributed (p = 0.325).
#> OK: Group3 appear as normally distributed (p = 0.323).

oneway.test(mtcars$mpg ~ mtcars$cyl, var.equal = TRUE) |> check_normality()
#> OK: residuals appear as normally distributed (p = 0.538).

cor.test(mtcars$mpg, mtcars$hp) |> check_normality()
#> Warning: Non-normality of residuals detected (p = 0.005).

var.test(mtcars$mpg, mtcars$hp) |> check_normality()
#> OK: Group1 appear as normally distributed (p = 0.123).
#> Warning: Non-normality of Group2 detected (p = 0.049).

Created on 2022-07-07 by the reprex package (v2.0.1)

For Chisq:

chisq.test(mtcars$cyl, mtcars$gear) |> check_normality()
#> Warning: Some cells in the expected table have less than 5 observations

chisq.test(table(mtcars$cyl)) |> check_normality()
#> OK: All cells in the expected table have more than 10 observations

chisq.test(table(mtcars$cyl), p = c(0.2, 0.2, 0.6)) |> check_normality()
#> Warning: All cells in the expected table have more than 5 observations,
#>   but some have less than 10.

check_homogeneity

library(performance)

t.test(mtcars$mpg, mtcars$hp, var.equal = TRUE) |> check_homogeneity()
#> Warning: Variances differ between groups (Bartlett Test, p = 0.000).

oneway.test(mtcars$mpg ~ mtcars$cyl, var.equal = TRUE) |> check_homogeneity()
#> Warning: Variances differ between groups (Bartlett Test, p = 0.015).

Created on 2022-07-07 by the reprex package (v2.0.1)

check_symmetry

library(performance)

wilcox.test(mtcars$mpg) |> check_symmetry()
#> OK: Data appears symmetrical (p = 0.119).

wilcox.test(mtcars$mpg, mtcars$hp, paired = TRUE) |> check_symmetry()
#> Warning: Non-symmetry detected (p = 0.008).

Created on 2022-07-07 by the reprex package (v2.0.1)

mattansb avatar Jul 07 '22 08:07 mattansb

Next thing - fix the plotting functions in see... This will take some work...

mattansb avatar Jul 07 '22 11:07 mattansb

Codecov Report

Merging #447 (3043b9d) into main (23d81d0) will decrease coverage by 0.93%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #447      +/-   ##
==========================================
- Coverage   32.67%   31.74%   -0.94%     
==========================================
  Files          80       82       +2     
  Lines        4682     4820     +138     
==========================================
  Hits         1530     1530              
- Misses       3152     3290     +138     
Impacted Files Coverage Δ
R/check_htest.R 0.00% <0.00%> (ø)
R/check_normality.R 51.19% <0.00%> (-1.25%) :arrow_down:
R/check_symmetry.R 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Jul 15 '22 06:07 codecov-commenter

This is def on the back burner - unless someone wants to take over, I will get to this in like 8 weeks.

mattansb avatar Aug 10 '22 14:08 mattansb

@mattansb Can we merge the current PR as is? I mean, we don't need the plotting functions right now, already having the general check-functions is great!

strengejacke avatar Sep 19 '22 10:09 strengejacke

Sure (:

mattansb avatar Sep 19 '22 12:09 mattansb