Closed einGlasRotwein closed 5 months ago
I didn't know anyone was looking at the attributes 😅
The basic idea here was the since $d_z$ for paired samples is just a one-sample $d$ on the pairwise differences, so in the underlying code both cases get pushed into the same internal functionality.
I have fixed the attribute to only reflect paired inputs (even though the outputs are the same).
library(effectsize)
is.paired <- \(x) isTRUE(attr(x, "paired"))
(d1 <- cohens_d(Pair(extra[group == 1], extra[group == 2]) ~ 1,
data = sleep))
#> For paired samples, 'repeated_measures_d()' provides more options.
#> Cohen's d | 95% CI
#> --------------------------
#> -1.28 | [-2.12, -0.41]
is.paired(d1)
#> [1] TRUE
(d2 <- cohens_d(extra[group == 1] - extra[group == 2] ~ 1,
data = sleep))
#> Cohen's d | 95% CI
#> --------------------------
#> -1.28 | [-2.12, -0.41]
is.paired(d2)
#> [1] FALSE
Created on 2024-06-13 with reprex v2.1.0
Dear
effectsize
team,I noticed that in the one sample case,
cohens_d()
has the attributepaired == TRUE
, see:I was wondering whether that is intentional and if so, why it makes sense to treat one sample tests as paired. I understand that a paired test is essentially a one sample test, but did not think of a one sample test as paired (i.e., the reverse). Maybe I'm missing something, but in
effectsize
, there is no equivalent ofttest_obj$method
, which explicitly names the test as e.g.,"One Sample t-test"
,"Welch Two Sample t-test"
, or"Paired t-test
?To give a little bit of context, the reason why I stumbled across this is that I have a function that formats
t.test()
andcohens_d()
results in my Quarto document. To prevent errors, it is also supposed to check whethert.test()
andcohens_d()
are both (not) paired, and I was wondering how to best handle the one sample case.Thank you in advance for any clarification! Juli