Lecture 14
Farmingdale State College
A psychologist measures stress levels of a group before and after a mindfulness program.
Steps:
id | T1 | T2 | Dfi | |
---|---|---|---|---|
1 | 1 | 10 | 4 | (-6) |
2 | 2 | 7 | 6 | (-1) |
3 | 3 | 12 | 6 | (-6) |
4 | 4 | 5 | 5 | 0 |
5 | 5 | 7 | 3 | (-4) |
6..29 | ||||
30 | 30 | 7 | 4 | (-3) |
\[\large{t = \frac{D}{\frac{\sigma}{\sqrt{n}}} = \frac{-3.26}{\frac{2.083}{\sqrt{30}}} = (-8.57)}\]
D | t | df | p | CI[ll,uu] |
---|---|---|---|---|
3.266667 | 7.58112 | 41.65179 | 2.3e-09 | [2.4, 4.14] |
library(ggplot2)
library(viridis)
data |>
ggplot(aes(grp, score, fill = grp)) +
stat_summary(
fun = "mean",
geom = "bar"
) +
stat_summary(
fun.data = "mean_se",
geom = "errorbar",
width=.2
) +
theme_minimal() +
labs(
x = "\nTreatment Group",
y = "Stress Score\n",
fill = "Time",
title = "Mindfulness Intervention decreases stress levels\n"
) +
theme(
plot.title.position = "plot",
plot.title = element_text(face = "bold")
) +
scale_fill_viridis(discrete = TRUE, option = "E")
library(ggplot2)
library(viridis)
data |>
ggplot(aes(grp, score, color = grp)) +
geom_jitter(aes(alpha = .2)) +
stat_summary(
fun.data = "mean_se",
geom = "line",
group = 1,
color = "black"
) +
stat_summary(
fun.data = "mean_se",
geom = "pointrange"
) +
theme_minimal() +
labs(
x = "\nTreatment Group",
y = "Stress Score\n",
fill = "Time",
title = "Mindfulness Intervention decreases stress levels\n"
) +
theme(
plot.title.position = "plot",
plot.title = element_text(face = "bold"),
legend.position = "none"
) +
scale_color_manual(values = c("darkgreen","darkred"))
⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡⬢⬡