Change Over Time
Change in Illness Mindsets
se <- function(x) sqrt(var(x)/length(x))
illmset_time <- t2 %>%
select(external_id, ill_catastrophe_t1, ill_catastrophe_t2, ill_manageable_t1, ill_manageable_t2, ill_opportunity_t1, ill_opportunity_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(ill_catastrophe_t1, ill_catastrophe_t2, ill_manageable_t1, ill_manageable_t2, ill_opportunity_t1, ill_opportunity_t2))%>%
mutate(Timepoint=
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2",
)) %>%
mutate(Mindset= as.factor(
case_when(grepl("ill_catastrophe_t", name) ~ "Catastrophe",
grepl("ill_manageable_t", name) ~ "Manageable",
grepl("ill_opportunity_t", name) ~ "Opportunity"))) %>%
group_by(Mindset, Timepoint) %>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
ill_mset_time_graph <- illmset_time %>%
ggplot(aes(x=Timepoint, y=Agreement, group=Mindset, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkred", "deepskyblue4", "darkolivegreen"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(1, 6), breaks=c(1,2,3,4,5,6)) +
theme_minimal() +
theme(legend.position="bottom") +
theme(legend.text = element_text(color="grey21", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(ill_mset_time_graph)

#Catastrophe Mindset
imi_cat_time <- t2 %>%
select(external_id, ill_catastrophe_t1, ill_catastrophe_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(ill_catastrophe_t1, ill_catastrophe_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("ill_catastrophe_t", name) ~ "Catastrophe Mindset"))) %>%
group_by(Mindset, Timepoint)
mindset_comparisons <- list(c("Baseline", "T2"))
imi_cat_time_plot <- imi_cat_time %>%
ggplot(aes(x=Timepoint, y=value, fill=Timepoint)) +
geom_boxplot(outlier.shape = NA) +
expand_limits(y = 1) +
scale_y_continuous(breaks=c(1,2,3,4,5,6)) +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=2.5, show.legend = FALSE,
vjust=2.2, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=value), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Catastrophe Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(imi_cat_time_plot)

#Manageable Mindset
imi_man_time <- t2 %>%
select(external_id, ill_manageable_t1, ill_manageable_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(ill_manageable_t1, ill_manageable_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("ill_manageable_t", name) ~ "Manageable Mindset"))) %>%
group_by(Mindset, Timepoint)
imi_man_time_plot <- imi_man_time %>%
ggplot(aes(x=Timepoint, y=value, fill=Timepoint)) +
geom_boxplot(outlier.shape = NA) +
expand_limits(y = 1) +
scale_y_continuous(breaks=c(1,2,3,4,5,6)) +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=2.5, show.legend = FALSE,
vjust=2.2, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=value), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Manageable Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(imi_man_time_plot)

#Opportunity Mindset
imi_opp_time <- t2 %>%
select(external_id, ill_opportunity_t1, ill_opportunity_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(ill_opportunity_t1, ill_opportunity_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("ill_opportunity_t", name) ~ "Opportunity Mindset"))) %>%
group_by(Mindset, Timepoint)
imi_opp_time_plot <- imi_opp_time %>%
ggplot(aes(x=Timepoint, y=value, fill=Timepoint)) +
geom_boxplot(outlier.shape = NA) +
expand_limits(y = 1) +
scale_y_continuous(breaks=c(1,2,3,4,5,6)) +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=2.5, show.legend = FALSE,
vjust=2.2, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=value), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Opportunity Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(imi_opp_time_plot)

Change in Body Mindsets
se <- function(x) sqrt(var(x)/length(x))
bodmset_time <- t2 %>%
select(external_id, body_adversary_t1, body_adversary_t2, body_capable_t1, body_capable_t2, body_responsive_t1, body_responsive_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(body_adversary_t1, body_adversary_t2, body_capable_t1, body_capable_t2, body_responsive_t1, body_responsive_t2))%>%
mutate(Timepoint=
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2",
)) %>%
mutate(Mindset= as.factor(
case_when(grepl("body_adversary_t", name) ~ "Adversary",
grepl("body_capable_t", name) ~ "Capable",
grepl("body_responsive_t", name) ~ "Responsive"))) %>%
group_by(Mindset, Timepoint) %>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
bodmset_time_graph <- bodmset_time %>%
ggplot(aes(x=Timepoint, y=Agreement, group=Mindset, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkred", "deepskyblue4", "darkolivegreen"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(1, 6), breaks=c(1,2,3,4,5,6)) +
theme_minimal() +
theme(legend.position="bottom") +
theme(legend.text = element_text(color="grey21", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(bodmset_time_graph)

#Body Adversary Mindset
bmi_adv_time <- t2 %>%
select(external_id, body_adversary_t1, body_adversary_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(body_adversary_t1, body_adversary_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("body_adversary_t", name) ~ "Body Adversary Mindset"))) %>%
group_by(Mindset, Timepoint)
bmi_adv_time_plot <- bmi_adv_time %>%
ggplot(aes(x=Timepoint, y=value, fill=Timepoint)) +
geom_boxplot(outlier.shape = NA) +
expand_limits(y = 1) +
scale_y_continuous(breaks=c(1,2,3,4,5,6)) +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=2.5, show.legend = FALSE,
vjust=2.2, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=value), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Body Adversary Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(bmi_adv_time_plot)

#Body Capable Mindset
bmi_cap_time <- t2 %>%
select(external_id, body_capable_t1, body_capable_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(body_capable_t1, body_capable_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("body_capable_t", name) ~ "Body Capable Mindset"))) %>%
group_by(Mindset, Timepoint)
bmi_cap_time_plot <- bmi_cap_time %>%
ggplot(aes(x=Timepoint, y=value, fill=Timepoint)) +
geom_boxplot(outlier.shape = NA) +
expand_limits(y = 1) +
scale_y_continuous(breaks=c(1,2,3,4,5,6)) +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=2.5, show.legend = FALSE,
vjust=2.2, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=value), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Body Capable Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(bmi_cap_time_plot)

#Body Responsive Mindset
bmi_resp_time <- t2 %>%
select(external_id, body_responsive_t1, body_responsive_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(body_responsive_t1, body_responsive_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("body_responsive_t", name) ~ "Body Responsive Mindset"))) %>%
group_by(Mindset, Timepoint)
bmi_resp_time_plot <- bmi_resp_time %>%
ggplot(aes(x=Timepoint, y=value, fill=Timepoint)) +
geom_boxplot(outlier.shape = NA) +
expand_limits(y = 1) +
scale_y_continuous(breaks=c(1,2,3,4,5,6)) +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=2.5, show.legend = FALSE,
vjust=2.2, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=value), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Body Responsive Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(bmi_resp_time_plot)

Change in Process Mindsets
se <- function(x) sqrt(var(x)/length(x))
process_time <- t2 %>%
select(external_id, process_difficult_t1, process_difficult_t2, process_unpleasant_t1, process_unpleasant_t2, process_stressful_t1, process_stressful_t2, process_inconvenient_t1, process_inconvenient_t2, process_boring_t1, process_boring_t2, process_lonely_t1, process_lonely_t2, process_depriving_t1, process_depriving_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(process_difficult_t1, process_difficult_t2, process_unpleasant_t1, process_unpleasant_t2, process_stressful_t1, process_stressful_t2, process_inconvenient_t1, process_inconvenient_t2, process_boring_t1, process_boring_t2, process_lonely_t1, process_lonely_t2, process_depriving_t1, process_depriving_t2))%>%
mutate(Timepoint=
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2",
)) %>%
mutate(Mindset=as.factor(
case_when(grepl("process_difficult_t", name) ~ "Difficult",
grepl("process_unpleasant_t", name) ~ "Unpleasant",
grepl("process_stressful_t", name) ~ "Stressful",
grepl("process_inconvenient_t", name) ~ "Inconvenient",
grepl("process_boring_t", name) ~ "Boring",
grepl("process_lonely_t", name) ~ "Lonely",
grepl("process_depriving_t", name) ~ "Depriving"))) %>%
group_by(Mindset, Timepoint) %>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
process_time_graph <- process_time %>%
ggplot(aes(x=Timepoint, y=Agreement, group=Mindset, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkred", "deepskyblue4", "darkolivegreen", "darkorchid4", "deeppink2", "firebrick1", "orange2"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(1.5, 3), breaks=c(1.5,1.75,2,2.25,2.5,2.75,3)) +
theme_minimal() +
theme(legend.position="bottom") +
theme(legend.text = element_text(color="grey21", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(process_time_graph)

#Process Difficult Mindset
process_difficult_time <- t2 %>%
select(external_id, process_difficult_t1, process_difficult_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(process_difficult_t1, process_difficult_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("process_difficult_t", name) ~ "Process Difficult"))) %>%
group_by(Mindset, Timepoint)%>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
process_difficult_time_plot <- process_difficult_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkolivegreen"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(1.5, 3), breaks=c(1.5,1.75,2,2.25,2.5,2.75,3)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Process Difficult Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(process_difficult_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

#Process Unpleasant Mindset
process_unpleasant_time <- t2 %>%
select(external_id, process_unpleasant_t1, process_unpleasant_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(process_unpleasant_t1, process_unpleasant_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("process_unpleasant_t", name) ~ "Process Unpleasant"))) %>%
group_by(Mindset, Timepoint)%>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
process_unpleasant_time_plot <- process_unpleasant_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("orange2"))+
geom_point(shape=21, color="orange2", fill="orange2", size=2.5) +
scale_y_continuous(limits=c(1.5, 3), breaks=c(1.5,1.75,2,2.25,2.5,2.75,3)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="orange2", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Process Unpleasant Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(process_unpleasant_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

#Process Stressful Mindset
process_stressful_time <- t2 %>%
select(external_id, process_stressful_t1, process_stressful_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(process_stressful_t1, process_stressful_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("process_stressful_t", name) ~ "Process Stressful"))) %>%
group_by(Mindset, Timepoint)%>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
process_stressful_time_plot <- process_stressful_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("firebrick1"))+
geom_point(shape=21, color="firebrick1", fill="firebrick1", size=2.5) +
scale_y_continuous(limits=c(1.5, 3), breaks=c(1.5,1.75,2,2.25,2.5,2.75,3)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="firebrick1", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Process Stressful Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(process_stressful_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

#Process Inconvenient Mindset
process_inconvenient_time <- t2 %>%
select(external_id, process_inconvenient_t1, process_inconvenient_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(process_inconvenient_t1, process_inconvenient_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("process_inconvenient_t", name) ~ "Process Inconvenient"))) %>%
group_by(Mindset, Timepoint)%>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
process_inconvenient_time_plot <- process_inconvenient_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkorchid4"))+
geom_point(shape=21, color="darkorchid4", fill="darkorchid4", size=2.5) +
scale_y_continuous(limits=c(1.5, 3), breaks=c(1.5,1.75,2,2.25,2.5,2.75,3)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="darkorchid4", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Process Inconvenient Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(process_inconvenient_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

#Process boring Mindset
process_boring_time <- t2 %>%
select(external_id, process_boring_t1, process_boring_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(process_boring_t1, process_boring_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("process_boring_t", name) ~ "Process Boring"))) %>%
group_by(Mindset, Timepoint)%>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
process_boring_time_plot <- process_boring_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkred"))+
geom_point(shape=21, color="darkred", fill="darkred", size=2.5) +
scale_y_continuous(limits=c(1.5, 3), breaks=c(1.5,1.75,2,2.25,2.5,2.75,3)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="darkred", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Process Boring Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(process_boring_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

#Process Lonely Mindset
process_lonely_time <- t2 %>%
select(external_id, process_lonely_t1, process_lonely_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(process_lonely_t1, process_lonely_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("process_lonely_t", name) ~ "Process Lonely"))) %>%
group_by(Mindset, Timepoint)%>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
process_lonely_time_plot <- process_lonely_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("deeppink2"))+
geom_point(shape=21, color="deeppink2", fill="deeppink2", size=2.5) +
scale_y_continuous(limits=c(1.5, 3), breaks=c(1.5,1.75,2,2.25,2.5,2.75,3)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="deeppink2", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Process Lonely Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(process_lonely_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

#Process Depriving Mindset
process_depriving_time <- t2 %>%
select(external_id, process_depriving_t1, process_depriving_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(process_depriving_t1, process_depriving_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("process_depriving_t", name) ~ "Process Depriving"))) %>%
group_by(Mindset, Timepoint)%>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
process_depriving_time_plot <- process_depriving_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("deepskyblue4"))+
geom_point(shape=21, color="deepskyblue4", fill="deepskyblue4", size=2.5) +
scale_y_continuous(limits=c(1.5, 3), breaks=c(1.5,1.75,2,2.25,2.5,2.75,3)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="deepskyblue4", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Process Depriving Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(process_depriving_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

Change in Activity Mindsets
se <- function(x) sqrt(var(x)/length(x))
activity_time <- t2 %>%
select(external_id, activity_adequacy_mindset_t1, activity_adequacy_mindset_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(activity_adequacy_mindset_t1, activity_adequacy_mindset_t2))%>%
mutate(Timepoint=
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2",
)) %>%
mutate(Mindset=as.factor(
case_when(grepl("activity_adequacy_mindset_t", name) ~ "Adequacy of Activity"))) %>%
group_by(Mindset, Timepoint) %>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
activity_time_plot <- activity_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkorchid4"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(1,6), breaks=c(1,2,3,4,5,6)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Activity Adequacy Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(activity_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

Change in Health Growth Mindsets
se <- function(x) sqrt(var(x)/length(x))
growth_time <- t2 %>%
select(external_id, health_growth_mindset_t1, health_growth_mindset_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(health_growth_mindset_t1, health_growth_mindset_t2))%>%
mutate(Timepoint=
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2",
)) %>%
mutate(Mindset=as.factor(
case_when(grepl("health_growth_mindset_t", name) ~ "Health Growth Mindset"))) %>%
group_by(Mindset, Timepoint) %>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
growth_time_plot <- growth_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkslateblue"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(1,6), breaks=c(1,2,3,4,5,6)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="darkslateblue", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Health Growth Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(growth_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

Change in Stress Mindsets
se <- function(x) sqrt(var(x)/length(x))
stress_time <- t2 %>%
select(external_id, stress_enhancing_t1, stress_enhancing_t2, stress_debilitating_t1, stress_debilitating_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(stress_enhancing_t1, stress_enhancing_t2, stress_debilitating_t1, stress_debilitating_t2))%>%
mutate(Timepoint=
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2",
)) %>%
mutate(Mindset=as.factor(
case_when(grepl("stress_enhancing_t", name) ~ "Enhancing",
grepl("stress_debilitating_t", name) ~ "Debilitating"))) %>%
group_by(Mindset, Timepoint) %>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
stress_time_graph <- stress_time %>%
ggplot(aes(x=Timepoint, y=Agreement, group=Mindset, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkred", "deepskyblue4"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(1, 6), breaks=c(1,2,3,4,5,6)) +
theme_minimal() +
theme(legend.position="bottom") +
theme(legend.text = element_text(color="grey21", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(stress_time_graph)

#Stress Enhancing Mindset
stress_enhancing_time <- t2 %>%
select(external_id, stress_enhancing_t1, stress_enhancing_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(stress_enhancing_t1, stress_enhancing_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("stress_enhancing_t", name) ~ "Enhancing"))) %>%
group_by(Mindset, Timepoint)%>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
stress_enhancing_time_plot <- stress_enhancing_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("deepskyblue4"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(1, 6), breaks=c(1,2,3,4,5,6)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="deepskyblue4", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Stress Enhancing Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(stress_enhancing_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

#Stress Debilitating Mindset
stress_debilitating_time <- t2 %>%
select(external_id, stress_debilitating_t1, stress_debilitating_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(stress_debilitating_t1, stress_debilitating_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Mindset= as.factor(
case_when(grepl("stress_debilitating_t", name) ~ "Debilitating"))) %>%
group_by(Mindset, Timepoint)%>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Mindset' (override with `.groups` argument)
stress_debilitating_time_plot <- stress_debilitating_time %>%
ggplot(aes(x=Timepoint, y=Agreement, color=Mindset)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkred"))+
geom_point(shape=21, color="darkred", fill="darkred", size=2.5) +
scale_y_continuous(limits=c(1, 6), breaks=c(1,2,3,4,5,6)) +
theme_minimal() +
stat_summary(fun=mean, geom="point", colour="darkred", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=4, show.legend = FALSE,
vjust=-4, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=Agreement), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Stress Debilitating Mindset",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(stress_debilitating_time_plot)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

Change in SF8
se <- function(x) sqrt(var(x)/length(x))
sf8_time <- t2 %>%
select(external_id, sf8_health_t1, sf8_health_t2, sf8_pain_t1, sf8_pain_t2, sf8_vitality_t1, sf8_vitality_t2, sf8_mental_t1, sf8_mental_t2, sf8_physical_t1, sf8_physical_t2, sf8_role_physical_t1, sf8_role_physical_t2, sf8_social_t1, sf8_social_t2, sf8_role_emotional_t1, sf8_role_emotional_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(sf8_health_t1, sf8_health_t2, sf8_pain_t1, sf8_pain_t2, sf8_vitality_t1, sf8_vitality_t2, sf8_mental_t1, sf8_mental_t2, sf8_physical_t1, sf8_physical_t2, sf8_role_physical_t1, sf8_role_physical_t2, sf8_social_t1, sf8_social_t2, sf8_role_emotional_t1, sf8_role_emotional_t2))%>%
mutate(Timepoint=
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2",
)) %>%
mutate(Variable=as.factor(
case_when(grepl("sf8_health_t", name) ~ "Gen. Health",
grepl("sf8_pain_t", name) ~ "Pain",
grepl("sf8_vitality_t", name) ~ "Vitality",
grepl("sf8_mental_t", name) ~ "Mental Health",
grepl("sf8_physical_t", name) ~ "Physical Health",
grepl("sf8_role_physical_t", name) ~ "Role Physical",
grepl("sf8_social_t", name) ~ "Social",
grepl("sf8_role_emotional_t", name) ~ "Role Emotional"))) %>%
group_by(Variable, Timepoint) %>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Variable' (override with `.groups` argument)
sf8_time_graph <- sf8_time %>%
ggplot(aes(x=Timepoint, y=Agreement, group=Variable, color=Variable)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkred", "deepskyblue4", "darkolivegreen", "darkorchid4", "deeppink2", "firebrick1", "orange2", "goldenrod"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(2.5,5), breaks=c(2.5,3,3.5,4,4.5,5)) +
theme_minimal() +
theme(legend.position="bottom") +
theme(legend.text = element_text(color="grey21", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(sf8_time_graph)

#SF8-Physical Health Composite
sf8_phys_time <- t2 %>%
select(external_id, sf8_physical_health_t1, sf8_physical_health_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(sf8_physical_health_t1, sf8_physical_health_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Variable= as.factor(
case_when(grepl("sf8_physical_health_t", name) ~ "Physical Health Composite"))) %>%
group_by(Variable, Timepoint)
sf8_phys_time_plot <- sf8_phys_time %>%
ggplot(aes(x=Timepoint, y=value, fill=Timepoint)) +
geom_boxplot(outlier.shape = NA) +
expand_limits(y = 1) +
scale_y_continuous(breaks=c(1,2,3,4,5,6)) +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=2.5, show.legend = FALSE,
vjust=2.2, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=value), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="SF8 Physical Health Composite",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(sf8_phys_time_plot)

#SF8-Mental Health Composite
sf8_mental_time <- t2 %>%
select(external_id, sf8_mental_health_t1, sf8_mental_health_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(sf8_mental_health_t1, sf8_mental_health_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Variable= as.factor(
case_when(grepl("sf8_mental_health_t", name) ~ "Mental Health Composite"))) %>%
group_by(Variable, Timepoint)
sf8_mental_time_plot <- sf8_mental_time %>%
ggplot(aes(x=Timepoint, y=value, fill=Timepoint)) +
geom_boxplot(outlier.shape = NA) +
expand_limits(y = 1) +
scale_y_continuous(breaks=c(1,2,3,4,5,6)) +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=2.5, show.legend = FALSE,
vjust=2.2, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=value), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="SF8 Mental Health Composite",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(sf8_mental_time_plot)

Change in Motivation
se <- function(x) sqrt(var(x)/length(x))
motivation_time <- t2 %>%
select(external_id, motivation_1_t1, motivation_1_t2, motivation_2_t1, motivation_2_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(motivation_1_t1, motivation_1_t2, motivation_2_t1, motivation_2_t2))%>%
mutate(Timepoint=
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2",
)) %>%
mutate(Variable=as.factor(
case_when(grepl("motivation_1_t", name) ~ "Motivation - Improve Health",
grepl("motivation_2_t", name) ~ "Motivation - Avoid Sickness"))) %>%
group_by(Variable, Timepoint) %>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Variable' (override with `.groups` argument)
motivation_time_graph <- motivation_time %>%
ggplot(aes(x=Timepoint, y=Agreement, group=Variable, color=Variable)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkred", "deepskyblue4"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(1,6), breaks=c(1,2,3,4,5,6)) +
theme_minimal() +
theme(legend.position="bottom") +
theme(legend.text = element_text(color="grey21", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(motivation_time_graph)

#Motivation - Improve Health
motivation_1_time <- t2 %>%
select(external_id, motivation_1_t1, motivation_1_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(motivation_1_t1, motivation_1_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Variable= as.factor(
case_when(grepl("motivation_1_t", name) ~ "Motivation - Improve Health"))) %>%
group_by(Variable, Timepoint)
motivation_1_time_plot <- motivation_1_time %>%
ggplot(aes(x=Timepoint, y=value, fill=Timepoint)) +
geom_boxplot(outlier.shape = NA) +
expand_limits(y = 1) +
scale_y_continuous(breaks=c(1,2,3,4,5,6)) +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=2.5, show.legend = FALSE,
vjust=2.2, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=value), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Motivation - Improve Health",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(motivation_1_time_plot)

#Motivation - Avoid Illness
motivation_2_time <- t2 %>%
select(external_id, motivation_2_t1, motivation_2_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(motivation_2_t1, motivation_2_t2))%>%
mutate(Timepoint=as.factor(
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2"
))) %>%
mutate(Variable= as.factor(
case_when(grepl("motivation_2_t", name) ~ "Motivation - Avoid Sickness"))) %>%
group_by(Variable, Timepoint)
motivation_2_time_plot <- motivation_2_time %>%
ggplot(aes(x=Timepoint, y=value, fill=Timepoint)) +
geom_boxplot(outlier.shape = NA) +
expand_limits(y = 1) +
scale_y_continuous(breaks=c(1,2,3,4,5,6)) +
stat_summary(fun=mean, geom="point", colour="black", shape=18, size=3, show.legend = FALSE) +
stat_summary(fun=mean, colour="black", geom="text", size=2.5, show.legend = FALSE,
vjust=2.2, aes(label=round(..y.., digits=2))) +
stat_compare_means(aes(x=Timepoint, y=value), label = "p.signif", comparisons=mindset_comparisons, bracket.size = 0.3, symnum.args = list(cutpoints = c(0, 0.001, 0.01, 0.05, 1), symbols = c( "***", "**", "*", "ns"))) +
labs(title="Motivation - Avoid Sickness",x="Timepoint", y = "Agreement") +
scale_fill_manual(breaks = c("Baseline", "T2"), values=c("azure2", "azure4")) +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position="none") +
theme(legend.text = element_text(color="black", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(motivation_2_time_plot)

Change in Social Support
Change in Motivation
se <- function(x) sqrt(var(x)/length(x))
soc_time <- t2 %>%
select(external_id, support_inst_t1, support_inst_t2, support_emotional_t1, support_emotional_t2, support_health_t1, support_health_t2) %>%
na.omit() %>%
pivot_longer(
cols = c(support_inst_t1, support_inst_t2, support_emotional_t1, support_emotional_t2, support_health_t1, support_health_t2))%>%
mutate(Timepoint=
case_when(grepl("_t1", name) ~ "Baseline",
grepl("_t2", name)~ "T2",
)) %>%
mutate(Variable=as.factor(
case_when(grepl("motivation_1_t", name) ~ "Motivation - Improve Health",
grepl("motivation_2_t", name) ~ "Motivation - Avoid Sickness"))) %>%
group_by(Variable, Timepoint) %>%
summarise(Agreement = mean(value),
sd = sd(value),
n = n()) %>%
mutate(std_err = se(sd),
lower.ci = Agreement - (qnorm(0.975)*(sd/sqrt(n))),
upper.ci = Agreement + (qnorm(0.975)*(sd/sqrt(n))))
## `summarise()` regrouping output by 'Variable' (override with `.groups` argument)
motivation_time_graph <- motivation_time %>%
ggplot(aes(x=Timepoint, y=Agreement, group=Variable, color=Variable)) +
geom_errorbar(aes(ymin=lower.ci, ymax=upper.ci), width=0.07, color="black") +
geom_line(size=1) +
scale_color_manual(values=c("darkred", "deepskyblue4"))+
geom_point(shape=21, color="grey21", fill="grey21", size=2.5) +
scale_y_continuous(limits=c(1,6), breaks=c(1,2,3,4,5,6)) +
theme_minimal() +
theme(legend.position="bottom") +
theme(legend.text = element_text(color="grey21", size=12)) +
theme(legend.title = element_blank()) +
theme(axis.text.x = element_text(color="black", size=10, hjust=0.5))
print(motivation_time_graph)

Social Support