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

Running effectsize functions in long format #622

Closed JulianGaviriaL closed 10 months ago

JulianGaviriaL commented 10 months ago

Describe the bug How can I run the effectsize functions on data with long format? r_001.csv For instance, I get the following error message in: aae<-cohens_d(Observations ~ Group | Participant, data = r_001) Error in Group | Participant : operations are possible only for numeric, logical or complex types

I prefer not transforming the data to wide format, since I have multiple (>300) datasets.

Specifiations (please complete the following information):

mattansb commented 10 months ago

Your installed version of {effectsize} should have the new repeated_measures_d() that does just that:

library(effectsize)

r_001 <- read.csv("r_001.csv")

repeated_measures_d(Observations ~ Group | Participant, data = r_001)
#> d (rm) |        95% CI
#> ----------------------
#> 0.05   | [-0.48, 0.57]
#> 
#> - Adjusted for small sample bias.

Read the documents for the available types:

repeated_measures_d(Observations ~ Group | Participant, data = r_001, method = "z")
#> d (z) |        95% CI
#> ---------------------
#> 0.03  | [-0.36, 0.43]
#> 
#> - Adjusted for small sample bias.

repeated_measures_d(Observations ~ Group | Participant, data = r_001, method = "b")
#> Becker's d |        95% CI
#> --------------------------
#> 0.04       | [-0.49, 0.57]
#> 
#> - Adjusted for small sample bias.

And more...

Created on 2023-12-05 with reprex v2.0.2

JulianGaviriaL commented 10 months ago

Thanks @mattansb

Just to report an issue with the syntax for handling NA values: the function runs fine without misisng values: r_001b.csv repeated_measures_d(Observations ~ Group | Participant, data = r_001b)

But yields the following error when there are missing values: r_001.csv repeated_measures_d(Observations ~ Group | Participant, data = r_001)

Error in if (verbose && any(tapply(mf[[1]], mf[3:2], length) > 1L)) { : missing value where TRUE/FALSE needed

mattansb commented 10 months ago

Thanks. Should be fixed now.