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

Error with report.htest() #563 #564

Closed strengejacke closed 1 year ago

strengejacke commented 1 year ago

Fixed #563

strengejacke commented 1 year ago
library(effectsize)
library(datawizard)

data(iris)
x <- data_filter(iris, Species != "versicolor")
x$Species <- as.character(x$Species)
x$Species[97:100] <- NA

# works, but very large difference to other approach?
t.test(x$Sepal.Length ~ x$Species, var.equal = TRUE) |> effectsize()
#> Cohen's d |         95% CI
#> --------------------------
#> -3.12     | [-3.72, -2.52]
#> 
#> - Estimated using pooled SD.

t.test(Sepal.Length ~ Species, data = x, var.equal = TRUE) |> effectsize()
#> Warning: Unable to retrieve data from htest object.
#>   Returning an approximate effect size using t_to_d().
#> d     |         95% CI
#> ----------------------
#> -3.15 | [-3.75, -2.54]

Created on 2023-02-15 with reprex v2.0.2

codecov-commenter commented 1 year ago

Codecov Report

Merging #564 (18c66b8) into main (22f7192) will increase coverage by 0.05%. The diff coverage is 97.50%.

:exclamation: Current head 18c66b8 differs from pull request most recent head 6c428af. Consider uploading reports for the commit 6c428af to get more accurate results

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main     #564      +/-   ##
==========================================
+ Coverage   91.12%   91.18%   +0.05%     
==========================================
  Files          55       55              
  Lines        3336     3335       -1     
==========================================
+ Hits         3040     3041       +1     
+ Misses        296      294       -2     
Impacted Files Coverage Δ
R/cohens_d.R 96.80% <ø> (ø)
R/cohens_g.R 87.80% <ø> (ø)
R/convert_between_common_language.R 95.34% <ø> (ø)
R/convert_between_odds_to_probs.R 78.57% <ø> (ø)
R/convert_stat_to_d.R 95.45% <ø> (ø)
R/convert_stat_to_r.R 95.12% <ø> (ø)
R/effectsize.BFBayesFactor.R 91.30% <ø> (ø)
R/eta_squared_posterior.R 63.41% <ø> (ø)
R/plot.R 100.00% <ø> (ø)
R/utils.R 82.75% <ø> (ø)
... and 17 more

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

strengejacke commented 1 year ago

@mattansb This PR contains some lintr-related changes and I removed all @import tags, thus many changes are actually not related to the issue itself. The relevant change is only here:

image

I added tests, too. Maybe we should generally only keep complete cases, there are 1-2 further instances, where you simply omit missings per vector, which may result in unequal length of data.

mattansb commented 1 year ago

Okay, missing data is better dealt with in .get_data_2_samples(), so I completely removed the na.omits from the htest functions (which are older bits of code).

Once all GHA pass, this can be merged (:

mattansb commented 1 year ago

Shit... I know what's happening.

Is this urgent for something? If not, I'll fix this on Sunday...

strengejacke commented 1 year ago

No, not urgent. :-)

mattansb commented 1 year ago

I've pushed a temp fix (until https://github.com/easystats/insight/issues/722 is resolved).

strengejacke commented 1 year ago

Do you have examples for all the combinations in your temp-fix?

mattansb commented 1 year ago

I think these are all the methods for fitting t.tests that can recover data

# One sample
tt1 <- t.test(mtcars$mpg)
tt2 <- t.test(mtcars$mpg ~ 1)

# Two sample
tt3 <- t.test(mtcars$mpg ~ mtcars$am)
tt4 <- t.test(mtcars$mpg[mtcars$am==0], mtcars$mpg[mtcars$am==1])

# Paired
tt5 <- t.test(sleep$extra ~ sleep$group, paired = TRUE)
tt6 <- t.test(sleep$extra[sleep$group == "1"], sleep$extra[sleep$group == "2"], paired = TRUE)
tt7 <- t.test(Pair(sleep$extra[sleep$group == "1"], sleep$extra[sleep$group == "2"]) ~ 1)
mattansb commented 1 year ago

Should I merge this for now?

strengejacke commented 1 year ago

Yes, maybe also include a test for the insight version, so the code won't break once https://github.com/easystats/insight/pull/723 is implemented?

mattansb commented 1 year ago

Errors seem to be unrelated to this PR.