1. Loading data, setting up
library(tidyverse)
library(readxl)
library(jmRtools)
library(lme4)
library(corrr)
df <- read_excel("~/Dropbox/1_Research/REX Data/Papers for Publication/WrappingUpSurvey/WrappingUp Survey Data Lisa.xlsx")
df_ss <- df %>%
select(ID = `Student ID`,
crs = Class,
crslvl = `Course\r\nLevel`,
tchr = Teacher,
schl = School,
obs = `Observer\r\nOverall\r\nScore`,
tech = `Tech\r\nScore`,
implem = `Teacher\r\nImplementation\r\nScore`,
rexabr = `Rex Abridged?`,
delay = `Delay in survey (days)`,
order = `Order of >1 Rex`,
MF1 = Q1,
MF2 = Q2,
MV1 = Q3,
MF3 = Q4,
MV2 = Q5,
MV3 = Q6,
T1 = Q7,
MV4 = Q8,
T2 = Q9,
MF4 = Q10,
T3 = Q11,
T4 = Q12)
pre_int <- read_csv("~/Dropbox/1_Research/REX Data/Papers for Publication/WrappingUpSurvey/pre_personal_interest.csv")
## Warning: Missing column names filled in: 'X15' [15], 'X17' [17]
Processing data
df_ss <- df_ss %>%
mutate(ID = as.factor(ID),
crslvl = as.factor(crslvl))
df_ss <- df_ss %>%
mutate(flag = ifelse(ID %in% c(132, 134, 189),
"did_not_complete",
ifelse(ID %in% c(203, 197),
"declined_to_participate",
ifelse(ID == 225,
"did_not_take_seriously", NA))),
delay_flag = ifelse(delay > 10, 1, NA))
# this is our data frame with only the first REX experiments
df1 <- df_ss %>% filter(order == 1)
# View(df1)
df1 <- df1 %>% filter(is.na(flag) & is.na(delay_flag))
# write_csv(df1, "first_experiment_REX.csv")
df1$mf_comp <- composite_mean_maker(df1, MF1, MF2, MF3, MF4)
df1$mv_comp <- composite_mean_maker(df1, MV1, MV2, MV3, MV4)
df1$t_comp <- composite_mean_maker(df1, T1, T2, T3, T4)
df1$overall_comp <- composite_mean_maker(df1,
MF1, MF2, MF3, MF4,
MV1, MV2, MV3, MV4,
T1, T2, T3, T4)
df1 <- select(df1, ID, crs, crslvl, tchr, schl, obs, tech, implem, rexabr, delay, order, contains("comp"))
pre_int$pre_personal_interest <- composite_mean_maker(pre_int,
`Q27 - I enjoy science.`,
`Q35 - Science is exciting to me.`,
`Q30 - I like science.`,
`Q29 - Being someone who is good at science is important to me.`,
`Q34 - Being good in science is an important part of who I am.`,
`Q37 - Science concepts are valuable because they will help me in the future.`,
`Q31 - Science is practical for me to know.`,
`Q33 - Science helps me in my daily life outside of school.`)
pre_int$pre_identity <- composite_mean_maker(pre_int,
`Q28 - I consider myself a science person.`,
`Q36 - Being involved in science is a key part of who I am.`,
`Q29 - Being someone who is good at science is important to me.`,
`Q34 - Being good in science is an important part of who I am.`)
pre_int <- rename(pre_int, crs = ClassID)
pre_int <- select(pre_int, crs, pre_personal_interest, pre_identity)
Preparing for analysis
to_join <- pre_int %>%
group_by(crs) %>%
summarize(n = n(),
mean_pre_personal_interest = mean(pre_personal_interest),
sd_pre_personal_interest = sd(pre_personal_interest),
mean_pre_identity = mean(pre_identity),
sd_pre_identity = mean(pre_identity)) %>%
mutate(se_pre_personal_interest = sd_pre_personal_interest / sqrt(n - 1),
se_pre_identity = sd_pre_personal_interest / sqrt(n - 1),
course_with_n = paste0(crs, " (n = ", n, ")"))
df_m <- left_join(df1, to_join, by = "crs")
df_p <- df_m %>%
group_by(crs) %>%
select(contains("comp")) %>%
summarize_all(funs(mean, sd, n())) %>%
select(-mf_comp_n, -mv_comp_n, -t_comp_n) %>%
rename(n = overall_comp_n) %>%
mutate(overall_comp_se = overall_comp_sd / sqrt(n - 1),
mf_comp_se = mf_comp_sd / sqrt(n - 1),
mv_comp_se = mv_comp_sd / sqrt(n - 1),
t_comp_se = t_comp_sd / sqrt(n - 1),
course_with_n = paste0(crs, " (n = ", n, ")")) %>%
select(course_with_n,
mf_comp_mean, mv_comp_mean, t_comp_mean, overall_comp_mean,
mf_comp_se, mv_comp_se, t_comp_se, overall_comp_se)
Correlations
df_m %>%
select(obs, tech, implem, contains("comp"), mean_pre_personal_interest, mean_pre_identity) %>%
correlate() %>%
shave() %>%
fashion()
## rowname obs tech implem mf_comp mv_comp t_comp
## 1 obs
## 2 tech .74
## 3 implem .98 .63
## 4 mf_comp -.03 -.18 -.02
## 5 mv_comp -.05 -.20 -.04 .79
## 6 t_comp -.06 -.24 -.04 .90 .71
## 7 overall_comp -.05 -.22 -.04 .96 .89 .94
## 8 mean_pre_personal_interest -.32 -.05 -.41 .05 .03 .03
## 9 mean_pre_identity .51 .53 .45 -.06 -.17 -.09
## overall_comp mean_pre_personal_interest mean_pre_identity
## 1
## 2
## 3
## 4
## 5
## 6
## 7
## 8 .04
## 9 -.11 .19
Plots of outcomes
df_p %>%
ggplot(aes(x = reorder(course_with_n, overall_comp_mean), y = overall_comp_mean)) +
geom_col() +
geom_errorbar(aes(ymin = overall_comp_mean - overall_comp_se,
ymax = overall_comp_mean + overall_comp_se)) +
xlab("Course (with number of students in the course)") +
ylab("Mean Overall Situational Interest") +
coord_flip()
## Warning: Removed 1 rows containing missing values (geom_errorbar).

df_p %>%
ggplot(aes(x = reorder(course_with_n, t_comp_mean), y = t_comp_mean)) +
geom_col() +
geom_errorbar(aes(ymin = t_comp_mean - t_comp_se,
ymax = t_comp_mean + t_comp_se)) +
xlab("Course (with number of students in the course)") +
ylab("Mean Triggered Situational Interest") +
coord_flip()
## Warning: Removed 1 rows containing missing values (geom_errorbar).

df_p %>%
ggplot(aes(x = reorder(course_with_n, mv_comp_mean), y = mv_comp_mean)) +
geom_col() +
geom_errorbar(aes(ymin = mv_comp_mean - mv_comp_se,
ymax = mv_comp_mean + mv_comp_se)) +
xlab("Course (with number of students in the course)") +
ylab("Mean Personal Interest") +
ggtitle("Mean Maintained-Value Situational Interest") +
coord_flip()
## Warning: Removed 1 rows containing missing values (geom_errorbar).

df_p %>%
ggplot(aes(x = reorder(course_with_n, mf_comp_mean), y = mf_comp_mean)) +
geom_col() +
geom_errorbar(aes(ymin = mf_comp_mean - mf_comp_se,
ymax = mf_comp_mean + mf_comp_se)) +
xlab("Course (with number of students in the course)") +
ylab("Mean Personal Interest") +
ggtitle("Mean Maintained-Feeling Situational Interest") +
coord_flip()
## Warning: Removed 1 rows containing missing values (geom_errorbar).

testing ICCs for personal interest
int_m1 <- lmer(pre_personal_interest ~ 1 +
(1 | crs),
data = pre_int)
ranef(int_m1)
## $crs
## (Intercept)
## 1 0
## 2 0
## 3 0
## 4 0
## 5 0
## 6 0
## 7 0
## 8 0
## 9 0
## 10 0
## 11 0
## 12 0
## 13 0
summary(int_m1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: pre_personal_interest ~ 1 + (1 | crs)
## Data: pre_int
##
## REML criterion at convergence: 998.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.4320 -0.3306 -0.0988 0.0751 5.5241
##
## Random effects:
## Groups Name Variance Std.Dev.
## crs (Intercept) 0.00 0.000
## Residual 4.65 2.156
## Number of obs: 228, groups: crs, 13
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 4.0880 0.1428 28.63
sjstats::icc(int_m1)
## Linear mixed model
## Family: gaussian (identity)
## Formula: pre_personal_interest ~ 1 + (1 | crs)
##
## ICC (crs): 0.000000
to_join %>%
ggplot(aes(x = reorder(course_with_n, mean_pre_personal_interest), y = mean_pre_personal_interest)) +
geom_col() +
geom_errorbar(aes(ymin = mean_pre_personal_interest - se_pre_personal_interest,
ymax = mean_pre_personal_interest + se_pre_personal_interest)) +
xlab("Course (with number of students in the course)") +
ylab("Mean Personal Interest") +
ggtitle("Mean Pre-Personal Interest by Course") +
coord_flip()

int_m2 <- lmer(pre_identity ~ 1 +
(1 | crs),
data = pre_int)
summary(int_m2)
## Linear mixed model fit by REML ['lmerMod']
## Formula: pre_identity ~ 1 + (1 | crs)
## Data: pre_int
##
## REML criterion at convergence: 1130
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -0.8918 -0.3089 -0.0975 0.1293 8.2709
##
## Random effects:
## Groups Name Variance Std.Dev.
## crs (Intercept) 0.07196 0.2682
## Residual 8.23931 2.8704
## Number of obs: 228, groups: crs, 13
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 3.6386 0.2063 17.64
sjstats::icc(int_m2)
## Linear mixed model
## Family: gaussian (identity)
## Formula: pre_identity ~ 1 + (1 | crs)
##
## ICC (crs): 0.008658
to_join %>%
ggplot(aes(x = reorder(course_with_n, mean_pre_identity), y = mean_pre_identity)) +
geom_col() +
geom_errorbar(aes(ymin = mean_pre_identity - se_pre_identity,
ymax = mean_pre_identity + se_pre_identity)) +
xlab("Course (with number of students in the course)") +
ylab("Mean Identity") +
ggtitle("Mean Pre-Identity by Course") +
coord_flip()

Fidelity - overall
int_m1 <- lmer(overall_comp ~ obs +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m1, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
overall_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.62
|
0.64
|
<.001
|
obs
|
|
-0.09
|
0.16
|
.576
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.245
|
Observations
|
|
166
|
R2 / Ω02
|
|
.280 / .273
|
int_m2 <- lmer(overall_comp ~ tech +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m2, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
overall_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.95
|
0.51
|
<.001
|
tech
|
|
-0.18
|
0.13
|
.174
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.212
|
Observations
|
|
166
|
R2 / Ω02
|
|
.277 / .271
|
int_m3 <- lmer(overall_comp ~ implem +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m3, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
overall_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.55
|
0.62
|
<.001
|
implem
|
|
-0.07
|
0.15
|
.641
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.248
|
Observations
|
|
166
|
R2 / Ω02
|
|
.280 / .273
|
Fidelity - maintained value
int_m1 <- lmer(mv_comp ~ obs +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m1, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
mv_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.78
|
0.56
|
<.001
|
obs
|
|
-0.08
|
0.14
|
.541
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.154
|
Observations
|
|
166
|
R2 / Ω02
|
|
.185 / .173
|
int_m2 <- lmer(mv_comp ~ tech +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m2, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
mv_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
4.08
|
0.43
|
<.001
|
tech
|
|
-0.17
|
0.11
|
.129
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.117
|
Observations
|
|
166
|
R2 / Ω02
|
|
.177 / .167
|
int_m3 <- lmer(mv_comp ~ implem +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m3, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
mv_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.72
|
0.53
|
<.001
|
implem
|
|
-0.07
|
0.13
|
.592
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.156
|
Observations
|
|
166
|
R2 / Ω02
|
|
.185 / .173
|
Fidelity - maintained feeling
int_m1 <- lmer(mf_comp ~ obs +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m1, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
mf_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.53
|
0.66
|
<.001
|
obs
|
|
-0.05
|
0.16
|
.738
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.207
|
Observations
|
|
166
|
R2 / Ω02
|
|
.247 / .239
|
int_m2 <- lmer(mf_comp ~ tech +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m2, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
mf_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.85
|
0.54
|
<.001
|
tech
|
|
-0.15
|
0.14
|
.300
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.185
|
Observations
|
|
166
|
R2 / Ω02
|
|
.245 / .238
|
int_m3 <- lmer(mf_comp ~ implem +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m3, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
mf_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.48
|
0.63
|
<.001
|
implem
|
|
-0.04
|
0.15
|
.791
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.208
|
Observations
|
|
166
|
R2 / Ω02
|
|
.247 / .239
|
Fidelity - triggered
int_m1 <- lmer(t_comp ~ obs +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m1, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
t_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.54
|
0.78
|
<.001
|
obs
|
|
-0.12
|
0.19
|
.528
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.302
|
Observations
|
|
166
|
R2 / Ω02
|
|
.343 / .338
|
int_m2 <- lmer(t_comp ~ tech +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m2, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
t_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.91
|
0.62
|
<.001
|
tech
|
|
-0.23
|
0.16
|
.157
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.267
|
Observations
|
|
166
|
R2 / Ω02
|
|
.341 / .336
|
int_m3 <- lmer(t_comp ~ implem +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(int_m3, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
t_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.44
|
0.75
|
<.001
|
implem
|
|
-0.09
|
0.18
|
.606
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.306
|
Observations
|
|
166
|
R2 / Ω02
|
|
.343 / .338
|
class level - overall
cls_m1 <- lmer(overall_comp ~ as.factor(crslvl) +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(cls_m1, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
overall_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.52
|
0.27
|
<.001
|
as.factor(crslvl) (2)
|
|
-0.42
|
0.32
|
.196
|
as.factor(crslvl) (3)
|
|
-0.01
|
0.44
|
.990
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.226
|
Observations
|
|
166
|
R2 / Ω02
|
|
.279 / .274
|
class level - maintained value
cls_m1 <- lmer(mv_comp ~ as.factor(crslvl) +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(cls_m1, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
mv_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.77
|
0.25
|
<.001
|
as.factor(crslvl) (2)
|
|
-0.48
|
0.29
|
.094
|
as.factor(crslvl) (3)
|
|
-0.19
|
0.38
|
.621
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.139
|
Observations
|
|
166
|
R2 / Ω02
|
|
.186 / .178
|
class level - maintained feeling
cls_m1 <- lmer(mf_comp ~ as.factor(crslvl) +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(cls_m1, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
mf_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.47
|
0.29
|
<.001
|
as.factor(crslvl) (2)
|
|
-0.30
|
0.33
|
.377
|
as.factor(crslvl) (3)
|
|
0.15
|
0.45
|
.741
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.190
|
Observations
|
|
166
|
R2 / Ω02
|
|
.245 / .239
|
class level - triggered
cls_m1 <- lmer(t_comp ~ as.factor(crslvl) +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(cls_m1, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
t_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.32
|
0.33
|
<.001
|
as.factor(crslvl) (2)
|
|
-0.45
|
0.39
|
.250
|
as.factor(crslvl) (3)
|
|
0.03
|
0.53
|
.955
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.291
|
Observations
|
|
166
|
R2 / Ω02
|
|
.342 / .339
|
personal interest
pi_m1 <- lmer(overall_comp ~ mean_pre_personal_interest +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(pi_m1, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
overall_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.90
|
1.31
|
.003
|
mean_pre_personal_interest
|
|
-0.15
|
0.31
|
.630
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.250
|
Observations
|
|
166
|
R2 / Ω02
|
|
.281 / .274
|
identity
pi_m2 <- lmer(overall_comp ~ mean_pre_identity +
(1 | crs),
data = df_m)
sjPlot::sjt.lmer(pi_m2, p.kr = F, show.re.var = F, show.ci = F, show.se = T)
|
|
overall_comp
|
|
|
B
|
std. Error
|
p
|
Fixed Parts
|
(Intercept)
|
|
3.97
|
0.45
|
<.001
|
mean_pre_identity
|
|
-0.18
|
0.11
|
.104
|
Random Parts
|
Ncrs
|
|
13
|
ICCcrs
|
|
0.220
|
Observations
|
|
166
|
R2 / Ω02
|
|
.284 / .277
|