library(tidyverse)library(effectsize)employees<-read_csv("data/employee_survey.csv", show_col_types =FALSE)experiment<-read_csv("data/training_experiment.csv", show_col_types =FALSE)cor.test(employees$workload, employees$burnout, use ="complete.obs")
Pearson's product-moment correlation
data: employees$workload and employees$burnout
t = 19.429, df = 478, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
0.6111010 0.7114717
sample estimates:
cor
0.66427
experiment|>group_by(group)|>summarise( n =n(), mean_post =mean(post_score), sd_post =sd(post_score), .groups ="drop")
# A tibble: 2 × 4
group n mean_post sd_post
<chr> <int> <dbl> <dbl>
1 Control 115 65.1 11.3
2 Training 105 68.5 10.1
two_sided<-t.test(post_score~group, data =experiment, alternative ="two.sided")two_sided
Welch Two Sample t-test
data: post_score by group
t = -2.3536, df = 217.85, p-value = 0.01948
alternative hypothesis: true difference in means between group Control and group Training is not equal to 0
95 percent confidence interval:
-6.2358887 -0.5517717
sample estimates:
mean in group Control mean in group Training
65.10522 68.49905
training_post<-experiment|>filter(group=="Training")|>pull(post_score)control_post<-experiment|>filter(group=="Control")|>pull(post_score)one_sided<-t.test(training_post,control_post, alternative ="greater")one_sided
Welch Two Sample t-test
data: training_post and control_post
t = 2.3536, df = 217.85, p-value = 0.009742
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
1.01182 Inf
sample estimates:
mean of x mean of y
68.49905 65.10522
Cohen's d | 95% CI
--------------------------
-0.32 | [-0.58, -0.05]
- Estimated using pooled SD.
training_only<-experiment|>filter(group=="Training")t.test(training_only$post_score,training_only$pre_score, paired =TRUE, alternative ="two.sided")
Paired t-test
data: training_only$post_score and training_only$pre_score
t = 19.965, df = 104, p-value < 2.2e-16
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
6.501155 7.935035
sample estimates:
mean difference
7.218095
The directional alternative must be justified before inspecting the relevant outcome. The one-sided p-value is not a legitimate “upgrade” chosen because the two-sided result is inconvenient.