Created
November 10, 2025 23:36
-
-
Save LukasWallrich/2dbe7931dba1260b74512330c300d0e1 to your computer and use it in GitHub Desktop.
Effect size calculation for Dijkstra et al
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ``` r | |
| # Study parameters | |
| n1 <- 150 # Popular fiction | |
| n2 <- 150 # Literary fiction | |
| # Means and 95% CIs | |
| m1 <- 27.233 | |
| ci1_lower <- 26.581 | |
| ci1_upper <- 27.885 | |
| m2 <- 27.808 | |
| ci2_lower <- 27.156 | |
| ci2_upper <- 28.460 | |
| # Calculate standard deviations from confidence intervals | |
| # Formula: SD = (CI_margin * sqrt(n)) / t_critical | |
| # Degrees of freedom | |
| df <- n1 - 1 | |
| # Critical t-value for 95% CI | |
| t_crit <- qt(0.975, df) | |
| # Margin of error (from mean to CI boundary) | |
| margin1 <- ci1_upper - m1 | |
| margin2 <- ci2_upper - m2 | |
| # Calculate standard deviations | |
| sd1 <- (margin1 * sqrt(n1)) / t_crit | |
| sd2 <- (margin2 * sqrt(n2)) / t_crit | |
| # Calculate pooled standard deviation | |
| sd_pooled <- sqrt((sd1^2 + sd2^2) / 2) | |
| # Calculate Cohen's d | |
| cohens_d <- (m2 - m1) / sd_pooled | |
| # Display results | |
| cat("=== Results ===\n\n") | |
| #> === Results === | |
| cat("Popular Fiction:\n") | |
| #> Popular Fiction: | |
| cat(" Mean:", m1, "\n") | |
| #> Mean: 27.233 | |
| cat(" SD:", round(sd1, 3), "\n\n") | |
| #> SD: 4.041 | |
| cat("Literary Fiction:\n") | |
| #> Literary Fiction: | |
| cat(" Mean:", m2, "\n") | |
| #> Mean: 27.808 | |
| cat(" SD:", round(sd2, 3), "\n\n") | |
| #> SD: 4.041 | |
| cat("Pooled SD:", round(sd_pooled, 3), "\n") | |
| #> Pooled SD: 4.041 | |
| cat("Cohen's d:", round(cohens_d, 3), "\n\n") | |
| #> Cohen's d: 0.142 | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment