Closed stefanleach closed 4 years ago
Doing a few more tests on this, I can't seem to replicate this issue. The following code produces the same Cohens d estimates for seed 1-10.
library(tidyverse)
library(apa)
set.seed(6)
test <-
data.frame(x = rnorm(50),
y = rnorm(50))
test %>%
summarize(result = t_test(x, y, paired = FALSE, var.equal = TRUE) %>% apa(es = "cohens_d"))
test %>%
summarize(result = t.test(x, y, paired = FALSE, var.equal = TRUE) %>% apa(es = "cohens_d"))
If you pass the result of t_test
to cohens_d
(via apa
), Cohen's d is calculated from the raw data via the following formula:
If you pass the result of t.test
, cohens_d
can't calculate Cohens'd from the raw data, because the data is not included in the list returned by t.test
. For this reason, cohens_d
uses the following formula:
(both formulas from Lakens, 2013)
If your sample sizes are not equal, then the two formulas might not produce the same results.
Ah, that makes sense. Good to know! 👍
Thanks for the speedy response!
Hi there,
Just a quick query/comment. I seem to be getting different effect size estimates when piping the results of a t.test vs. t_test to the apa() function. This is happening with an independent samples test and when requesting Cohens d.
For example, I receive one estimate for Cohens d when running a script equivalent to the following, with the "t_test" function:
...but a different estimate for Cohens d when running a script equivalent to the following, , with the "t.test" function:
Any input would be helpful.
Cheers,
Stefan