forked from drganghe/energy-climate-policy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.Rhistory
More file actions
512 lines (512 loc) · 23.6 KB
/
Copy path.Rhistory
File metadata and controls
512 lines (512 loc) · 23.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# Engagement profiles — change scores by activity and dimension
# Computed directly from matched_survey
# ------------------------------------------------------------
# Cohen's d helper (already defined in analysis script)
# d = mean(change) / sd(change)
compute_d <- function(data, chg_var) {
x <- data[[chg_var]]
x <- x[!is.na(x)]
round(mean(x) / sd(x), 3)
}
# Wilcoxon p-value helper for significance flagging
compute_p <- function(data, pre_var, post_var) {
x <- data[[pre_var]]
y <- data[[post_var]]
valid <- complete.cases(x, y)
d <- y[valid] - x[valid]
wilcox.test(d, mu = 0, exact = FALSE)$p.value
}
profile_data <- bind_rows(
# Podcasting
tibble(activity = "Podcasting", dimension = "Behavioral",
d = compute_d(matched_survey, "chg_beh_podcast"),
p = compute_p(matched_survey, "beh_podcast_pre", "beh_podcast_post")),
tibble(activity = "Podcasting", dimension = "Emotional",
d = compute_d(matched_survey, "chg_emo_podcast"),
p = compute_p(matched_survey, "emo_podcast_pre", "emo_podcast_post")),
tibble(activity = "Podcasting", dimension = "Cognitive",
d = compute_d(matched_survey, "chg_cog_podcast"),
p = compute_p(matched_survey, "cog_podcast_pre", "cog_podcast_post")),
# Case study
tibble(activity = "Case study", dimension = "Behavioral",
d = compute_d(matched_survey, "chg_beh_casestudy"),
p = compute_p(matched_survey, "beh_casestudy_pre", "beh_casestudy_post")),
tibble(activity = "Case study", dimension = "Emotional",
d = compute_d(matched_survey, "chg_emo_casestudy"),
p = compute_p(matched_survey, "emo_casestudy_pre", "emo_casestudy_post")),
tibble(activity = "Case study", dimension = "Cognitive",
d = compute_d(matched_survey, "chg_cog_casestudy"),
p = compute_p(matched_survey, "cog_casestudy_pre", "cog_casestudy_post")),
# Business case — emotional pre unavailable
tibble(activity = "Business case", dimension = "Behavioral",
d = compute_d(matched_survey, "chg_beh_bizcase"),
p = compute_p(matched_survey, "beh_bizcase_pre", "beh_bizcase_post")),
tibble(activity = "Business case", dimension = "Cognitive",
d = compute_d(matched_survey, "chg_cog_bizcase"),
p = compute_p(matched_survey, "cog_bizcase_pre", "cog_bizcase_post")),
# Mentorship — emotional pre unavailable
tibble(activity = "Mentorship", dimension = "Behavioral",
d = compute_d(matched_survey, "chg_beh_mentor"),
p = compute_p(matched_survey, "beh_mentor_pre", "beh_mentor_post")),
tibble(activity = "Mentorship", dimension = "Cognitive",
d = compute_d(matched_survey, "chg_cog_mentor"),
p = compute_p(matched_survey, "cog_mentor_pre", "cog_mentor_post"))
) %>%
mutate(
sig = ifelse(p < .05, "*", ""),
activity = factor(activity,
levels = c("Podcasting", "Case study",
"Business case", "Mentorship")),
dimension = factor(dimension,
levels = c("Behavioral", "Emotional", "Cognitive")),
color = case_when(
d > 0.1 ~ "Positive",
d < -0.1 ~ "Negative",
TRUE ~ "Negligible"
)
)
# Verify values
print(profile_data %>% select(activity, dimension, d, p, sig))
profile_caption <- str_wrap(
"Figure 3. Cohen's d effect sizes for pre-to-post engagement change by activity and dimension. Positive values indicate improvement; negative values indicate decline relative to pre-semester expectations. Emotional engagement not available for business case or mentorship at pre-semester due to reliability constraints; omitted from those panels. * p < .05, Wilcoxon signed-rank test, two-sided.",
width = 120
)
ggplot(profile_data, aes(x = d, y = dimension, fill = color)) +
geom_col(width = 0.55) +
geom_vline(xintercept = 0, color = "gray30", linewidth = 0.8) +
geom_text(aes(label = paste0(ifelse(d > 0, "+", ""), round(d, 2), sig),
hjust = ifelse(d >= 0, -0.15, 1.15)),
fontface = "bold", size = 4) +
scale_fill_manual(values = c(
"Positive" = "#1F3864",
"Negative" = "#C8960C",
"Negligible" = "#BBBBBB"
)) +
scale_x_continuous(limits = c(-0.65, 0.55),
breaks = c(-0.4, -0.2, 0, 0.2, 0.4),
labels = c("-0.4", "-0.2", "0", "+0.2", "+0.4")) +
facet_wrap(~ activity, ncol = 4) +
labs(title = "Engagement Change by Activity and Dimension",
subtitle = "Cohen's d (post minus pre) · * p < .05",
caption = profile_caption,
x = "Effect size (Cohen's d)", y = NULL) +
theme_minimal(base_size = 13) +
theme(legend.position = "none",
plot.title = element_text(face = "bold", hjust = 0.5, size = 14),
plot.subtitle = element_text(hjust = 0.5, color = "gray40", size = 11),
plot.caption = element_text(hjust = 0, size = 9,
color = "gray40", face = "italic"),
plot.caption.position = "plot",
strip.text = element_text(face = "bold", size = 12),
axis.text = element_text(face = "bold"),
panel.grid.major.y = element_blank())
ggsave("tilt/finding2_engagement_profiles.png",
width = 10, height = 4.5, dpi = 300)
# ------------------------------------------------------------
# RQX. Finding 3
# Knowledge Assessment — Pre/Post Score Distribution
# Computed directly from matched_survey
# ------------------------------------------------------------
# Compute score distributions from matched_survey
ka_data <- bind_rows(
matched_survey %>%
count(score = ka_score_pre) %>%
mutate(time = "Pre"),
matched_survey %>%
count(score = ka_score_post) %>%
mutate(time = "Post")
) %>%
# Ensure all score levels appear for both time points
# (e.g. if no one scored 0 or 1 at post, still show as 0)
complete(score, time, fill = list(n = 0)) %>%
filter(score >= 2) %>% # drop scores below 2 if none present
mutate(
time = factor(time, levels = c("Pre", "Post")),
score = factor(score,
levels = sort(unique(score)),
labels = paste0(sort(unique(score)), " of 5"))
)
# Verify distributions match Step 13 output
cat("Pre distribution:\n")
print(matched_survey %>% count(ka_score_pre))
cat("\nPost distribution:\n")
print(matched_survey %>% count(ka_score_post))
# Compute mean scores for annotation
mean_pre <- round(mean(matched_survey$ka_score_pre, na.rm = TRUE), 2)
mean_post <- round(mean(matched_survey$ka_score_post, na.rm = TRUE), 2)
ka_caption <- str_wrap(
"Figure 4. Distribution of knowledge assessment scores at pre- and post-semester (n = 38). Score = number correct out of 5 items retained for adequate response rates. Mean improved from 3.82 to 4.34 (W = 234, p = .003, r = 0.37, medium effect). The combination of active learning strategies precludes attribution to any single activity; the result is consistent with a course environment that supported content comprehension alongside engagement.",
width = 120
)
ggplot(ka_data, aes(x = score, y = n, fill = time)) +
geom_col(position = position_dodge(width = 0.7), width = 0.65) +
geom_text(aes(label = ifelse(n > 0, n, "")),
position = position_dodge(width = 0.7),
vjust = -0.4, fontface = "bold", size = 4.5) +
scale_fill_manual(values = c("Pre" = "#D5E3F0", "Post" = "#1F3864"),
name = NULL) +
scale_y_continuous(limits = c(0, 22), breaks = seq(0, 20, 5)) +
annotate("text", x = 3.5, y = 21,
label = paste0("Mean: ", mean_pre, " \u2192 ", mean_post,
" (p = .003, r = 0.37)"),
fontface = "bold.italic", size = 4.5, color = "#1F3864") +
labs(title = "Knowledge Assessment: Pre- and Post-Semester Scores",
subtitle = "Students demonstrated significant gains in content knowledge over the semester",
caption = ka_caption,
x = "Score (items correct out of 5)",
y = "Number of students") +
theme_minimal(base_size = 13) +
theme(plot.title = element_text(face = "bold", hjust = 0.5, size = 14),
plot.subtitle = element_text(hjust = 0.5, color = "gray40", size = 11),
plot.caption = element_text(hjust = 0, size = 9,
color = "gray40", face = "italic"),
plot.caption.position = "plot",
legend.position = "top",
axis.text = element_text(face = "bold"),
panel.grid.major.x = element_blank())
ggsave("tilt/finding3_knowledge.png", width = 7, height = 5, dpi = 300)
# ------------------------------------------------------------
# RQ3. Finding 4 — Correlation heatmap
# Beliefs predict engagement intentions r = 0.50 to 0.65
# across all nine correlations.
# ------------------------------------------------------------
# Define variable groups with updated labels
bv_vars <- c(
"Growth mindset" = "bv_growth_score_pre",
"Grit" = "bv_persist_score_pre",
"Entrepreneurial identity" = "bv_relevance_score_pre"
)
beh_vars <- c(
"Podcasting" = "beh_podcast_pre",
"Case study" = "beh_casestudy_pre",
"Business case" = "beh_bizcase_pre",
"Mentorship" = "beh_mentor_pre"
)
# Compute Pearson correlations between each belief/values
# composite and each anticipated behavioral engagement item
cor_long <- expand.grid(
belief = names(bv_vars),
activity = names(beh_vars),
stringsAsFactors = FALSE
) %>%
rowwise() %>%
mutate(
r = cor(
matched_survey[[bv_vars[belief]]],
matched_survey[[beh_vars[activity]]],
use = "complete.obs",
method = "pearson"
)
) %>%
ungroup() %>%
mutate(
belief = factor(belief,
levels = c("Growth mindset", "Grit",
"Entrepreneurial identity")),
activity = factor(activity,
levels = c("Podcasting", "Case study",
"Business case", "Mentorship"))
)
# Verify correlations match previously reported values
print(cor_long %>% arrange(belief, activity) %>%
mutate(r = round(r, 3)))
fig2_caption <- str_wrap(
"Figure 5. Pearson correlations between pre-semester beliefs and values composites and anticipated behavioral engagement across the four course activities (n = 38). Growth mindset = belief that intelligence and ability can be developed through effort (Dweck et al., 2014). Grit = tendency to follow through on goals and overcome setbacks. Entrepreneurial identity = perceived applicability of entrepreneurship to students' own lives, interests, and futures. All 12 correlations are positive and range from r = 0.50 to r = 0.65.",
width = 120
)
ggplot(cor_long, aes(x = activity, y = belief, fill = r)) +
geom_tile(color = "white", linewidth = 1) +
geom_text(aes(label = round(r, 2)), size = 5, fontface = "bold") +
scale_fill_gradient(low = "#D5E3F0", high = "#1F3864",
limits = c(0.45, 0.70),
name = "Pearson r") +
scale_y_discrete(labels = scales::label_wrap(13)) +
labs(title = "Beliefs and Values vs. Anticipated Behavioral Engagement",
caption = fig2_caption,
x = NULL, y = NULL) +
theme_minimal(base_size = 14) +
theme(axis.text = element_text(face = "bold"),
axis.text.y = element_text(face = "bold", lineheight = 0.9),
plot.title = element_text(face = "bold", hjust = 0.5),
plot.caption = element_text(hjust = 0, size = 9,
color = "gray40", face = "italic"),
plot.caption.position = "plot",
legend.position = "right")
ggsave("tilt/finding4_correlation_heatmap.png",
width = 7, height = 4, dpi = 300)
# ------------------------------------------------------------
# Beliefs vs. post-semester realized behavioral engagement
# Side-by-side with pre-semester anticipated engagement
# for direct comparison
# ------------------------------------------------------------
# Post behavioral engagement variables
beh_vars_post <- c(
"Podcasting" = "beh_podcast_post",
"Case study" = "beh_casestudy_post",
"Business case" = "beh_bizcase_post",
"Mentorship" = "beh_mentor_post"
)
# Compute correlations: beliefs (pre) vs. realized engagement (post)
cor_long_post <- expand.grid(
belief = names(bv_vars),
activity = names(beh_vars_post),
stringsAsFactors = FALSE
) %>%
rowwise() %>%
mutate(
r = cor(
matched_survey[[bv_vars[belief]]],
matched_survey[[beh_vars_post[activity]]],
use = "complete.obs",
method = "pearson"
)
) %>%
ungroup() %>%
mutate(
belief = factor(belief,
levels = c("Growth mindset", "Grit",
"Entrepreneurial identity")),
activity = factor(activity,
levels = c("Podcasting", "Case study",
"Business case", "Mentorship")),
timing = "Realized (Post-Semester)"
)
# Add timing label to existing pre correlations
cor_long_pre <- cor_long %>%
mutate(timing = "Anticipated (Pre-Semester)")
# Combine
cor_both <- bind_rows(cor_long_pre, cor_long_post) %>%
mutate(timing = factor(timing,
levels = c("Anticipated (Pre-Semester)",
"Realized (Post-Semester)")))
# Verify post correlations
cat("Post-semester correlations:\n")
print(cor_long_post %>% arrange(belief, activity) %>%
mutate(r = round(r, 3)))
fig_cor_both_caption <- str_wrap(
"Figure X. Pearson correlations between pre-semester beliefs and values composites and behavioral engagement — anticipated at pre-semester (left) and realized at post-semester (right) — across the four course activities (n = 38). Growth mindset = belief that intelligence and ability can be developed through effort (Dweck et al., 2014). Grit = tendency to follow through on goals and overcome setbacks. Entrepreneurial identity = perceived applicability of entrepreneurship to students' own lives, interests, and futures.",
width = 120
)
# Shared color scale across both panels
r_limits <- range(cor_both$r, na.rm = TRUE)
r_limits <- c(floor(min(r_limits) * 20) / 20,
ceiling(max(r_limits) * 20) / 20)
ggplot(cor_both, aes(x = activity, y = belief, fill = r)) +
geom_tile(color = "white", linewidth = 1) +
geom_text(aes(label = round(r, 2)), size = 4.5, fontface = "bold") +
scale_fill_gradient(low = "#D5E3F0", high = "#1F3864",
limits = r_limits,
name = "Pearson r") +
scale_y_discrete(labels = scales::label_wrap(13)) +
facet_wrap(~ timing) +
labs(title = "Beliefs and Values vs. Behavioral Engagement: Anticipated and Realized",
caption = fig_cor_both_caption,
x = NULL, y = NULL) +
theme_minimal(base_size = 13) +
theme(axis.text = element_text(face = "bold"),
axis.text.y = element_text(face = "bold", lineheight = 0.9),
axis.text.x = element_text(angle = 15, hjust = 1),
plot.title = element_text(face = "bold", hjust = 0.5, size = 14),
plot.caption = element_text(hjust = 0, size = 9,
color = "gray40", face = "italic"),
plot.caption.position = "plot",
strip.text = element_text(face = "bold", size = 12),
legend.position = "right")
ggsave("tilt/finding_beliefs_pre_post_engagement.png",
width = 11, height = 4.5, dpi = 300)
fig_cor_both_caption <- str_wrap(
"Figure X. Pearson correlations between pre-semester beliefs and values composites and behavioral engagement — anticipated at pre-semester (left) and realized at post-semester (right) — across the four course activities (n = 38). Growth mindset = belief that intelligence and ability can be developed through effort (Dweck et al., 2014). Grit = tendency to follow through on goals and overcome setbacks. Entrepreneurial identity = perceived applicability of entrepreneurship to students' own lives, interests, and futures.",
width = 140
)
# Shared color scale across both panels
r_limits <- range(cor_both$r, na.rm = TRUE)
r_limits <- c(floor(min(r_limits) * 20) / 20,
ceiling(max(r_limits) * 20) / 20)
ggplot(cor_both, aes(x = activity, y = belief, fill = r)) +
geom_tile(color = "white", linewidth = 1) +
geom_text(aes(label = round(r, 2)), size = 4.5, fontface = "bold") +
scale_fill_gradient(low = "#D5E3F0", high = "#1F3864",
limits = r_limits,
name = "Pearson r") +
scale_y_discrete(labels = scales::label_wrap(13)) +
facet_wrap(~ timing) +
labs(title = "Beliefs and Values vs. Behavioral Engagement: Anticipated and Realized",
caption = fig_cor_both_caption,
x = NULL, y = NULL) +
theme_minimal(base_size = 13) +
theme(axis.text = element_text(face = "bold"),
axis.text.y = element_text(face = "bold", lineheight = 0.9),
axis.text.x = element_text(angle = 15, hjust = 1),
plot.title = element_text(face = "bold", hjust = 0.5, size = 14),
plot.caption = element_text(hjust = 0, size = 9,
color = "gray40", face = "italic"),
plot.caption.position = "plot",
strip.text = element_text(face = "bold", size = 12),
legend.position = "right")
ggsave("tilt/finding_beliefs_pre_post_engagement.png",
width = 11, height = 4.5, dpi = 300)
fig_cor_both_caption <- str_wrap(
"Figure 5. Pearson correlations between pre-semester beliefs and values composites and behavioral engagement — anticipated at pre-semester (left) and realized at post-semester (right) — across the four course activities (n = 38). Growth mindset = belief that intelligence and ability can be developed through effort (Dweck et al., 2014). Grit = tendency to follow through on goals and overcome setbacks. Entrepreneurial identity = perceived applicability of entrepreneurship to students' own lives, interests, and futures.",
width = 140
)
# Shared color scale across both panels
r_limits <- range(cor_both$r, na.rm = TRUE)
r_limits <- c(floor(min(r_limits) * 20) / 20,
ceiling(max(r_limits) * 20) / 20)
ggplot(cor_both, aes(x = activity, y = belief, fill = r)) +
geom_tile(color = "white", linewidth = 1) +
geom_text(aes(label = round(r, 2)), size = 4.5, fontface = "bold") +
scale_fill_gradient(low = "#D5E3F0", high = "#1F3864",
limits = r_limits,
name = "Pearson r") +
scale_y_discrete(labels = scales::label_wrap(13)) +
facet_wrap(~ timing) +
labs(title = "Beliefs and Values vs. Behavioral Engagement: Anticipated and Realized",
caption = fig_cor_both_caption,
x = NULL, y = NULL) +
theme_minimal(base_size = 13) +
theme(axis.text = element_text(face = "bold"),
axis.text.y = element_text(face = "bold", lineheight = 0.9),
axis.text.x = element_text(angle = 15, hjust = 1),
plot.title = element_text(face = "bold", hjust = 0.5, size = 14),
plot.caption = element_text(hjust = 0, size = 9,
color = "gray40", face = "italic"),
plot.caption.position = "plot",
strip.text = element_text(face = "bold", size = 12),
legend.position = "right")
ggsave("tilt/finding_beliefs_pre_post_engagement.png",
width = 11, height = 4.5, dpi = 300)
# Test significance of post-semester correlations
cor_long_post %>%
rowwise() %>%
mutate(
p_value = cor.test(
matched_survey[[bv_vars[belief]]],
matched_survey[[beh_vars_post[activity]]],
use = "complete.obs",
method = "pearson"
)$p.value,
p_value = round(p_value, 3),
sig = ifelse(p_value < .05, "*", "")
) %>%
select(belief, activity, r, p_value, sig) %>%
print(n = 12)
fig_cor_both_caption <- str_wrap(
"Figure 5. Pearson correlations between pre-semester beliefs and values composites and behavioral engagement — anticipated at pre-semester (left) and realized at post-semester (right) — across the four course activities (n = 38). Pre-semester correlations range from r = 0.50 to r = 0.65 (all p < .05). Post-semester correlations range from r = 0.06 to r = 0.32 (none significant; closest: growth mindset vs. case study, p = .050). Growth mindset = belief that intelligence and ability can be developed through effort (Dweck et al., 2014). Grit = tendency to follow through on goals and overcome setbacks. Entrepreneurial identity = perceived applicability of entrepreneurship to students' own lives, interests, and futures.",
width = 140
)
# Shared color scale across both panels
r_limits <- range(cor_both$r, na.rm = TRUE)
r_limits <- c(floor(min(r_limits) * 20) / 20,
ceiling(max(r_limits) * 20) / 20)
ggplot(cor_both, aes(x = activity, y = belief, fill = r)) +
geom_tile(color = "white", linewidth = 1) +
geom_text(aes(label = round(r, 2)), size = 4.5, fontface = "bold") +
scale_fill_gradient(low = "#D5E3F0", high = "#1F3864",
limits = r_limits,
name = "Pearson r") +
scale_y_discrete(labels = scales::label_wrap(13)) +
facet_wrap(~ timing) +
labs(title = "Beliefs and Values vs. Behavioral Engagement: Anticipated and Realized",
caption = fig_cor_both_caption,
x = NULL, y = NULL) +
theme_minimal(base_size = 13) +
theme(axis.text = element_text(face = "bold"),
axis.text.y = element_text(face = "bold", lineheight = 0.9),
axis.text.x = element_text(angle = 15, hjust = 1),
plot.title = element_text(face = "bold", hjust = 0.5, size = 14),
plot.caption = element_text(hjust = 0, size = 9,
color = "gray40", face = "italic"),
plot.caption.position = "plot",
strip.text = element_text(face = "bold", size = 12),
legend.position = "right")
fig_cor_both_caption <- str_wrap(
"Figure 5. Pearson correlations between pre-semester beliefs and values composites and behavioral engagement — anticipated at pre-semester (left) and realized at post-semester (right) — across the four course activities (n = 38). Pre-semester correlations range from r = 0.50 to r = 0.65 (all p < .05). Post-semester correlations range from r = 0.06 to r = 0.32 (none significant; closest: growth mindset vs. case study, p = .050). Growth mindset = belief that intelligence and ability can be developed through effort (Dweck et al., 2014). Grit = tendency to follow through on goals and overcome setbacks. Entrepreneurial identity = perceived applicability of entrepreneurship to students' own lives, interests, and futures.",
width = 150
)
# Shared color scale across both panels
r_limits <- range(cor_both$r, na.rm = TRUE)
r_limits <- c(floor(min(r_limits) * 20) / 20,
ceiling(max(r_limits) * 20) / 20)
ggplot(cor_both, aes(x = activity, y = belief, fill = r)) +
geom_tile(color = "white", linewidth = 1) +
geom_text(aes(label = round(r, 2)), size = 4.5, fontface = "bold") +
scale_fill_gradient(low = "#D5E3F0", high = "#1F3864",
limits = r_limits,
name = "Pearson r") +
scale_y_discrete(labels = scales::label_wrap(13)) +
facet_wrap(~ timing) +
labs(title = "Beliefs and Values vs. Behavioral Engagement: Anticipated and Realized",
caption = fig_cor_both_caption,
x = NULL, y = NULL) +
theme_minimal(base_size = 13) +
theme(axis.text = element_text(face = "bold"),
axis.text.y = element_text(face = "bold", lineheight = 0.9),
axis.text.x = element_text(angle = 15, hjust = 1),
plot.title = element_text(face = "bold", hjust = 0.5, size = 14),
plot.caption = element_text(hjust = 0, size = 9,
color = "gray40", face = "italic"),
plot.caption.position = "plot",
strip.text = element_text(face = "bold", size = 12),
legend.position = "right")
ggsave("tilt/finding_beliefs_pre_post_engagement.png",
width = 11, height = 4.5, dpi = 300)
# Test significance of pre-semester correlations
expand.grid(
belief = names(bv_vars),
activity = names(beh_vars),
stringsAsFactors = FALSE
) %>%
rowwise() %>%
mutate(
r = cor(
matched_survey[[bv_vars[belief]]],
matched_survey[[beh_vars[activity]]],
use = "complete.obs",
method = "pearson"
),
p_value = cor.test(
matched_survey[[bv_vars[belief]]],
matched_survey[[beh_vars[activity]]],
use = "complete.obs",
method = "pearson"
)$p.value,
r = round(r, 3),
p_value = round(p_value, 3),
sig = ifelse(p_value < .05, "*", "")
) %>%
ungroup() %>%
select(belief, activity, r, p_value, sig) %>%
arrange(belief, activity) %>%
print(n = 12)
fig_cor_both_caption <- str_wrap(
"Figure 5. Pearson correlations between pre-semester beliefs and values composites and behavioral engagement — anticipated at pre-semester (left) and realized at post-semester (right) — across the four course activities (n = 38). Pre-semester correlations range from r = 0.50 to r = 0.65, all p ≤ .001. Post-semester correlations range from r = 0.06 to r = 0.32, none significant (all p > .05). Growth mindset = belief that intelligence and ability can be developed through effort (Dweck et al., 2014). Grit = tendency to follow through on goals and overcome setbacks. Entrepreneurial identity = perceived applicability of entrepreneurship to students' own lives, interests, and futures.",
width = 150
)
# Shared color scale across both panels
r_limits <- range(cor_both$r, na.rm = TRUE)
r_limits <- c(floor(min(r_limits) * 20) / 20,
ceiling(max(r_limits) * 20) / 20)
ggplot(cor_both, aes(x = activity, y = belief, fill = r)) +
geom_tile(color = "white", linewidth = 1) +
geom_text(aes(label = round(r, 2)), size = 4.5, fontface = "bold") +
scale_fill_gradient(low = "#D5E3F0", high = "#1F3864",
limits = r_limits,
name = "Pearson r") +
scale_y_discrete(labels = scales::label_wrap(13)) +
facet_wrap(~ timing) +
labs(title = "Beliefs and Values vs. Behavioral Engagement: Anticipated and Realized",
caption = fig_cor_both_caption,
x = NULL, y = NULL) +
theme_minimal(base_size = 13) +
theme(axis.text = element_text(face = "bold"),
axis.text.y = element_text(face = "bold", lineheight = 0.9),
axis.text.x = element_text(angle = 15, hjust = 1),
plot.title = element_text(face = "bold", hjust = 0.5, size = 14),
plot.caption = element_text(hjust = 0, size = 9,
color = "gray40", face = "italic"),
plot.caption.position = "plot",
strip.text = element_text(face = "bold", size = 12),
legend.position = "right")
ggsave("tilt/finding_beliefs_pre_post_engagement.png",
width = 11, height = 4.5, dpi = 300)