function `cohen.d`: Hedge's g uses wrong DFs for one-sample case
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
Research direction
Start by running the provided iris minimal reproducible example and inspect the implementation of effsize::cohen.d, especially its Hedges' g degrees-of-freedom calculation. Compare the one-sample and paired cases with the independent-samples case; the issue is done when the correction uses N-1 for the former cases and N-2 only for independent samples.
Written by the indexing model from the issue text.
Description
There is a small mistake in the function cohen.d:
According to Cumming (2011) p. 294, the degrees of freedom are N-1 for a one-sample design (i.e., if f=NA) and also for a within-subjects design (i.e., if paired=T). Only for the case with two independent samples, the degrees of freedom are N-2. The function, however, also calculates N-2 for the one-sample case (and possibly also for paired=T I have not checked this.
Minimal Reproducible Example:
library(tidyverse);
iris %>% group_by(Species) %>% summarise(
cohen_d = effsize::cohen.d(Sepal.Length, f=NA)$estimate,
n = Sepal.Length %>% na.omit() %>% length(), #should not use n() because it doesn't handle NAs correctly
hedges_g = effsize::cohen.d(Sepal.Length, NA, hedges.correction=T)$estimate,
hedges_g_df1 = cohen_d * (1 - (3 / (4 * (n-1) - 1))), #for one-sample & within: df = N - 1
hedges_g_df2 = cohen_d * (1 - (3 / (4 * (n-2) - 1))), #for two independent samples
check_df1 = hedges_g == hedges_g_df1,
check_df2 = hedges_g == hedges_g_df2
)
- Dominant language
- TypeScript
- Stars
- 301
- Forks
- 54
- Avg merge
- 16h 19m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from datacamp/rdocumentation-2.0
-
parsing
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
datacamp/rdocumentation-2.0#171 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
datacamp/rdocumentation-2.0#168 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
datacamp/rdocumentation-2.0#160 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 32/100
datacamp/rdocumentation-2.0#157 · 2 comments ·
All issues in datacamp/rdocumentation-2.0
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·