Loading libraries

# # Uncomment below and run if these packages haven't already been installed in your version of R
# install.packages("psych")
# install.packages("dplyr")
# install.packages("ggplot2")
# install.packages("gridExtra")

# load libraries
library(psych)        
library(dplyr)
library(ggplot2)
library(gridExtra)

Opening cleaned data

path <- "/Users/emurbanw/OneDrive-MichiganMedicine/OneDriveDocuments/EFDC/Consulting/Sagar_Parikh/data/"
data <- read.csv(paste0(path,"/Workplace_MH_Training_Survey.csv"), header = TRUE)

Descriptives

# 34 pre-survey responses, 33 post-survey responses
table(data$time)
## 
##  0  1 
## 34 33
#     Engineering     Kinesiology     Voices
#  pre    13               8            13
#  post   12               6            15
table(data$time, data$group)
##    
##     Engineering Kinesiology Voices
##   0          13           8     13
##   1          12           6     15
# 12 don't manage staff; 21 do manage staff
table(data$manage_staff)
## 
##  No Yes 
##  12  21

Hypothesis testing

# ns difference in familiarity with common mental health conditions
aggregate(fam_mh_conds ~ time, data = data, FUN = function(x) c(mean = mean(x), sd = sd(x), n = length(x))) # more familiarity at post
##   time fam_mh_conds.mean fam_mh_conds.sd fam_mh_conds.n
## 1    0         1.2647059       0.5110194     34.0000000
## 2    1         1.3636364       0.4885042     33.0000000
t.test(fam_mh_conds ~ time, data = data) # ns
## 
##  Welch Two Sample t-test
## 
## data:  fam_mh_conds by time
## t = -0.81014, df = 64.986, p-value = 0.4208
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.3428115  0.1449506
## sample estimates:
## mean in group 0 mean in group 1 
##        1.264706        1.363636
wilcox.test(fam_mh_conds ~ time, data = data) # W = 511.5, p-value = 0.4566
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  fam_mh_conds by time
## W = 511.5, p-value = 0.4566
## alternative hypothesis: true location shift is not equal to 0
# attendees are significantly more confident in their ability to identify someone in distress after the training
aggregate(conf_id_distress ~ time, data = data, FUN = function(x) c(mean = mean(x), sd = sd(x), n = length(x))) # more confident at post
##   time conf_id_distress.mean conf_id_distress.sd conf_id_distress.n
## 1    0             1.2058824           0.4785972         34.0000000
## 2    1             1.4848485           0.5075192         33.0000000
t.test(conf_id_distress ~ time, data = data) # sig
## 
##  Welch Two Sample t-test
## 
## data:  conf_id_distress by time
## t = -2.3133, df = 64.491, p-value = 0.0239
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.51983951 -0.03809275
## sample estimates:
## mean in group 0 mean in group 1 
##        1.205882        1.484848
wilcox.test(conf_id_distress ~ time, data = data) # W = 412.5, p-value = 0.02738
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  conf_id_distress by time
## W = 412.5, p-value = 0.02738
## alternative hypothesis: true location shift is not equal to 0
# attendees are significantly more comfortable in their ability to respond to someone with mental health issues after the training
aggregate(comf_resp_mh_issues ~ time, data = data, FUN = function(x) c(mean = mean(x), sd = sd(x), n = length(x))) # more comfort at post
##   time comf_resp_mh_issues.mean comf_resp_mh_issues.sd comf_resp_mh_issues.n
## 1    0                1.0000000              0.5504819            34.0000000
## 2    1                1.2727273              0.4522670            33.0000000
t.test(comf_resp_mh_issues ~ time, data = data) # sig
## 
##  Welch Two Sample t-test
## 
## data:  comf_resp_mh_issues by time
## t = -2.2186, df = 63.292, p-value = 0.03011
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.51835472 -0.02709982
## sample estimates:
## mean in group 0 mean in group 1 
##        1.000000        1.272727
wilcox.test(comf_resp_mh_issues ~ time, data = data) # W = 430.5, p-value = 0.03885
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  comf_resp_mh_issues by time
## W = 430.5, p-value = 0.03885
## alternative hypothesis: true location shift is not equal to 0
# ns difference in comfort talking about mental health issues with students
aggregate(comf_talk_mh_students ~ time, data = data, FUN = function(x) c(mean = mean(x), sd = sd(x), n = length(x))) # more comfort at post
##   time comf_talk_mh_students.mean comf_talk_mh_students.sd
## 1    0                  1.2000000                0.5773503
## 2    1                  1.4583333                0.5089774
##   comf_talk_mh_students.n
## 1              25.0000000
## 2              24.0000000
t.test(comf_talk_mh_students ~ time, data = data) # ns
## 
##  Welch Two Sample t-test
## 
## data:  comf_talk_mh_students by time
## t = -1.6631, df = 46.671, p-value = 0.103
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.57087522  0.05420856
## sample estimates:
## mean in group 0 mean in group 1 
##        1.200000        1.458333
wilcox.test(comf_talk_mh_students ~ time, data = data) # W = 233.5, p-value = 0.1258
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  comf_talk_mh_students by time
## W = 233.5, p-value = 0.1258
## alternative hypothesis: true location shift is not equal to 0
# ns difference in comfort talking about mental health issues with coworkers
aggregate(comf_talk_mh_coworkers ~ time, data = data, FUN = function(x) c(mean = mean(x), sd = sd(x), n = length(x))) # more comfort at post
##   time comf_talk_mh_coworkers.mean comf_talk_mh_coworkers.sd
## 1    0                   1.3529412                 0.5970814
## 2    1                   1.5757576                 0.5607084
##   comf_talk_mh_coworkers.n
## 1               34.0000000
## 2               33.0000000
t.test(comf_talk_mh_coworkers ~ time, data = data) # ns
## 
##  Welch Two Sample t-test
## 
## data:  comf_talk_mh_coworkers by time
## t = -1.5751, df = 64.931, p-value = 0.1201
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.50534873  0.05971593
## sample estimates:
## mean in group 0 mean in group 1 
##        1.352941        1.575758
wilcox.test(comf_talk_mh_coworkers ~ time, data = data) # W = 449, p-value = 0.1133
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  comf_talk_mh_coworkers by time
## W = 449, p-value = 0.1133
## alternative hypothesis: true location shift is not equal to 0
# attendees were significantly more confident in their ability to help a student access mental health resources after the training
aggregate(conf_student_mh_resource ~ time, data = data, FUN = function(x) c(mean = mean(x), sd = sd(x), n = length(x))) # more confidence at post
##   time conf_student_mh_resource.mean conf_student_mh_resource.sd
## 1    0                     1.0800000                   0.5715476
## 2    1                     1.6250000                   0.4945354
##   conf_student_mh_resource.n
## 1                 25.0000000
## 2                 24.0000000
t.test(conf_student_mh_resource ~ time, data = data) # sig
## 
##  Welch Two Sample t-test
## 
## data:  conf_student_mh_resource by time
## t = -3.5737, df = 46.512, p-value = 0.0008328
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.8518796 -0.2381204
## sample estimates:
## mean in group 0 mean in group 1 
##           1.080           1.625
wilcox.test(conf_student_mh_resource ~ time, data = data) # W = 159, p-value = 0.001492
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  conf_student_mh_resource by time
## W = 159, p-value = 0.001492
## alternative hypothesis: true location shift is not equal to 0
# attendees were significantly more confident in their ability to help a coworker access mental health resources after the training
aggregate(conf_coworker_mh_resource ~ time, data = data, FUN = function(x) c(mean = mean(x), sd = sd(x), n = length(x))) # more confidence at post
##   time conf_coworker_mh_resource.mean conf_coworker_mh_resource.sd
## 1    0                      1.3235294                    0.5888143
## 2    1                      1.7272727                    0.4522670
##   conf_coworker_mh_resource.n
## 1                  34.0000000
## 2                  33.0000000
t.test(conf_coworker_mh_resource ~ time, data = data) # sig
## 
##  Welch Two Sample t-test
## 
## data:  conf_coworker_mh_resource by time
## t = -3.1531, df = 61.774, p-value = 0.002493
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  -0.6597199 -0.1477667
## sample estimates:
## mean in group 0 mean in group 1 
##        1.323529        1.727273
wilcox.test(conf_coworker_mh_resource ~ time, data = data) # W = 358.5, p-value = 0.003634
## Warning in wilcox.test.default(x = DATA[[1L]], y = DATA[[2L]], ...): cannot
## compute exact p-value with ties
## 
##  Wilcoxon rank sum test with continuity correction
## 
## data:  conf_coworker_mh_resource by time
## W = 358.5, p-value = 0.003634
## alternative hypothesis: true location shift is not equal to 0

Visualizing training eval variables

# Function to create a pie chart for a given variable
create_pie_chart <- function(variable_name) {
  # Count the occurrences and calculate rounded percentages of each level excluding NAs
  variable_counts <- data %>% 
    filter(!is.na(!!sym(variable_name))) %>%
    count(!!sym(variable_name)) %>%
    mutate(percentage = round(n / sum(n) * 100, 2))

  # Create a pie chart with percentage labels
  pie_chart <- ggplot(variable_counts, aes(x = "", y = n, fill = !!sym(variable_name))) +
    geom_bar(stat = "identity", width = 1, color = "white") +
    geom_text(aes(label = paste0(percentage, "%")), position = position_stack(vjust = 0.5), size = 4) +
    coord_polar("y") +
    theme_void() +  # Removes unnecessary elements (axis, labels, etc.)
    labs(title = variable_name,
         subtitle = paste("Number of Responses: ", sum(variable_counts$n)),
         fill = variable_name)

  # Display the pie chart
  # print(pie_chart)

}

# List of variables
training_eval <- c("overall_rating", "facilitator_engaging", "material_clear", "relevant", "practical", "training_length")
interact_eval <- c("interact_faculty", "interact_students", "interact_friendsfam")
module_utility <- c("utility_mh_module", "utility_comm_module", "utility_support_module", "utility_resource_module", "utility_disc_module", "utility_breakout_sessions", "rating_breakout_session")

# Create pie charts for each variable
for (variable in training_eval) {
  create_pie_chart(variable)
}
# Create pie charts for each variable
for (variable in interact_eval) {
  create_pie_chart(variable)
}
# Create pie charts for each variable
for (variable in module_utility) {
  create_pie_chart(variable)
}

# Create a grid of pie charts
pie_charts1 <- lapply(training_eval, create_pie_chart)
grid.arrange(grobs = pie_charts1, ncol = 3)  

pie_charts2 <- lapply(interact_eval, create_pie_chart)
grid.arrange(grobs = pie_charts2, ncol = 3) 

pie_charts3 <- lapply(module_utility, create_pie_chart)
grid.arrange(grobs = pie_charts3, ncol = 3)