For use later on.

calculate_pooled_sd <- function(sd_group1, n_group1, sd_group2, n_group2) {
  sqrt(((n_group1 - 1) * (sd_group1 ^ 2) + (n_group2 - 1) * (sd_group2 ^ 2)) / (n_group1 + n_group2 - 2))
}

# test
calculate_pooled_sd(sd_group1 = 17.85, n_group1 = 6, sd_group2 = 8.16, n_group2 = 8)
## [1] 13.09966

Mixed effects models

library(lme4)
## Loading required package: Matrix
m_utility_val <- lmer(PostUV_ave ~ Int + PreUV_ave*PreEff_Ave + (1|ClassTeacher), data = df)
sjPlot::sjt.lmer(m_utility_val)
## Warning in checkMatrixPackageVersion(): Package version inconsistency detected.
## TMB was built with Matrix version 1.2.10
## Current Matrix version is 1.2.11
## Please re-install 'TMB' from source or restore original 'Matrix' package
## Computing p-values via Kenward-Roger approximation. Use `p.kr = FALSE` if computation takes too long.
    PostUV_ave
    B CI p
Fixed Parts
(Intercept)   5.36 2.15 – 8.57 .001
Int   0.44 0.04 – 0.85 .034
PreUV_ave   -0.07 -0.69 – 0.56 .831
PreEff_Ave   -0.53 -1.17 – 0.12 .111
PreUV_ave:PreEff_Ave   0.11 -0.01 – 0.22 .080
Random Parts
σ2   1.773
τ00, ClassTeacher   0.075
NClassTeacher   8
ICCClassTeacher   0.040
Observations   170
R2 / Ω02   .268 / .267
m_val <- lmer(PostVal_Ave ~ Int + PreVal_Ave*PreEff_Ave + (1|ClassTeacher), data = df)
sjPlot::sjt.lmer(m_val)
## Computing p-values via Kenward-Roger approximation. Use `p.kr = FALSE` if computation takes too long.
    PostVal_Ave
    B CI p
Fixed Parts
(Intercept)   3.71 0.38 – 7.05 .030
Int   0.32 -0.02 – 0.65 .065
PreVal_Ave   0.30 -0.33 – 0.93 .358
PreEff_Ave   -0.30 -0.98 – 0.37 .376
PreVal_Ave:PreEff_Ave   0.05 -0.06 – 0.17 .373
Random Parts
σ2   1.252
τ00, ClassTeacher   0.095
NClassTeacher   8
ICCClassTeacher   0.071
Observations   177
R2 / Ω02   .322 / .321
m_interest <- lmer(PostInt_Ave ~ Int + PreInt_Ave*PreEff_Ave + (1|ClassTeacher), data = df)
sjPlot::sjt.lmer(m_interest)
## Computing p-values via Kenward-Roger approximation. Use `p.kr = FALSE` if computation takes too long.
    PostInt_Ave
    B CI p
Fixed Parts
(Intercept)   -1.15 -5.48 – 3.18 .603
Int   0.02 -0.38 – 0.41 .934
PreInt_Ave   1.14 0.33 – 1.94 .006
PreEff_Ave   0.63 -0.19 – 1.45 .134
PreInt_Ave:PreEff_Ave   -0.11 -0.26 – 0.04 .147
Random Parts
σ2   1.733
τ00, ClassTeacher   0.213
NClassTeacher   8
ICCClassTeacher   0.109
Observations   177
R2 / Ω02   .340 / .338

Models with gender added.

m_utility_val_g <- lmer(PostUV_ave ~ Int + PreUV_ave*PreEff_Ave + Gender + (1|ClassTeacher), data = df)
sjPlot::sjt.lmer(m_utility_val_g)
## Computing p-values via Kenward-Roger approximation. Use `p.kr = FALSE` if computation takes too long.
    PostUV_ave
    B CI p
Fixed Parts
(Intercept)   5.52 2.31 – 8.72 <.001
Int   0.44 0.04 – 0.85 .034
PreUV_ave   -0.08 -0.70 – 0.55 .809
PreEff_Ave   -0.53 -1.17 – 0.11 .108
Gender   -0.29 -0.69 – 0.11 .156
PreUV_ave:PreEff_Ave   0.11 -0.01 – 0.22 .074
Random Parts
σ2   1.758
τ00, ClassTeacher   0.083
NClassTeacher   8
ICCClassTeacher   0.045
Observations   170
R2 / Ω02   .280 / .279
m_val_g <- lmer(PostVal_Ave ~ Int + PreVal_Ave*PreEff_Ave + Gender + (1|ClassTeacher), data = df)
sjPlot::sjt.lmer(m_val_g)
## Computing p-values via Kenward-Roger approximation. Use `p.kr = FALSE` if computation takes too long.
    PostVal_Ave
    B CI p
Fixed Parts
(Intercept)   3.77 0.41 – 7.12 .029
Int   0.32 -0.02 – 0.65 .066
PreVal_Ave   0.29 -0.34 – 0.92 .369
PreEff_Ave   -0.31 -0.98 – 0.37 .373
Gender   -0.07 -0.40 – 0.27 .695
PreVal_Ave:PreEff_Ave   0.05 -0.06 – 0.17 .366
Random Parts
σ2   1.258
τ00, ClassTeacher   0.097
NClassTeacher   8
ICCClassTeacher   0.071
Observations   177
R2 / Ω02   .323 / .322
m_interest_g <- lmer(PostInt_Ave ~ Int + PreInt_Ave*PreEff_Ave + Gender + (1|ClassTeacher), data = df)
sjPlot::sjt.lmer(m_interest_g)
## Computing p-values via Kenward-Roger approximation. Use `p.kr = FALSE` if computation takes too long.
    PostInt_Ave
    B CI p
Fixed Parts
(Intercept)   -0.80 -5.15 – 3.54 .718
Int   0.02 -0.38 – 0.41 .933
PreInt_Ave   1.08 0.28 – 1.88 .009
PreEff_Ave   0.60 -0.22 – 1.43 .151
Gender   -0.26 -0.66 – 0.13 .193
PreInt_Ave:PreEff_Ave   -0.10 -0.25 – 0.05 .178
Random Parts
σ2   1.724
τ00, ClassTeacher   0.223
NClassTeacher   8
ICCClassTeacher   0.115
Observations   177
R2 / Ω02   .347 / .346

Participant flow

df <- tbl_df(df)

# UTILITY VALUE

df %>%
  filter(is.na(PreUV_ave)) # 3 students missing pre UV
## # A tibble: 3 x 13
##   Gender   Age PreUV_all_ave PostUV_all_ave PreInt_Ave PreEff_Ave   Int
##    <int> <int>         <dbl>          <dbl>      <dbl>      <dbl> <int>
## 1      1    10            NA            6.2        4.0        6.2     1
## 2      0    11            NA            2.4        4.6        4.2     1
## 3      0    11            NA            4.8        7.0        5.4     0
## # ... with 6 more variables: PreUV_ave <dbl>, PostUV_ave <dbl>,
## #   PostInt_Ave <dbl>, PreVal_Ave <dbl>, PostVal_Ave <dbl>,
## #   ClassTeacher <fctr>
df %>%
  filter(is.na(PostUV_ave)) # 20 students missing pre UV
## # A tibble: 20 x 13
##    Gender   Age PreUV_all_ave PostUV_all_ave PreInt_Ave PreEff_Ave   Int
##     <int> <int>         <dbl>          <dbl>      <dbl>      <dbl> <int>
##  1      0    11           7.0             NA       7.00        7.0     1
##  2      0    10           3.6             NA       5.60        3.2    NA
##  3      0    11           3.6             NA       4.40        6.2     1
##  4      0    11           6.8             NA       6.80        5.4     1
##  5      0    11           6.8             NA       6.40        6.4     1
##  6      1    11           7.0             NA       7.00        6.8     1
##  7      0    10           5.6             NA       6.00        5.4     0
##  8      1    11           6.4             NA       6.80        3.0    NA
##  9      1    11           5.2             NA       7.00        5.6     0
## 10      1    10            NA             NA       6.75        6.6    NA
## 11      0    10           7.0             NA       7.00        7.0     1
## 12      1    10           6.4             NA       6.60        5.8     1
## 13      0    10           7.0             NA       7.00        6.4     1
## 14      0    11           4.8             NA       6.60        5.8     0
## 15      1    10           5.4             NA       6.80        5.6     0
## 16      0    10           5.8             NA       6.40        3.6     1
## 17      1    11           6.4             NA       6.60        5.8     0
## 18      0    10           5.2             NA       5.00        2.8    NA
## 19      0    11           4.2             NA       2.25        6.2     0
## 20      0    10           2.8             NA       1.00        3.4    NA
## # ... with 6 more variables: PreUV_ave <dbl>, PostUV_ave <dbl>,
## #   PostInt_Ave <dbl>, PreVal_Ave <dbl>, PostVal_Ave <dbl>,
## #   ClassTeacher <fctr>
df %>%
  filter(is.na(PreUV_ave) | is.na(PostUV_ave)) # 23 students missing either pre or post UV
## # A tibble: 23 x 13
##    Gender   Age PreUV_all_ave PostUV_all_ave PreInt_Ave PreEff_Ave   Int
##     <int> <int>         <dbl>          <dbl>      <dbl>      <dbl> <int>
##  1      1    10            NA            6.2        4.0        6.2     1
##  2      0    11           7.0             NA        7.0        7.0     1
##  3      0    10           3.6             NA        5.6        3.2    NA
##  4      0    11           3.6             NA        4.4        6.2     1
##  5      0    11            NA            2.4        4.6        4.2     1
##  6      0    11           6.8             NA        6.8        5.4     1
##  7      0    11           6.8             NA        6.4        6.4     1
##  8      1    11           7.0             NA        7.0        6.8     1
##  9      0    10           5.6             NA        6.0        5.4     0
## 10      1    11           6.4             NA        6.8        3.0    NA
## # ... with 13 more rows, and 6 more variables: PreUV_ave <dbl>,
## #   PostUV_ave <dbl>, PostInt_Ave <dbl>, PreVal_Ave <dbl>,
## #   PostVal_Ave <dbl>, ClassTeacher <fctr>
# VALUE

df %>%
  filter(is.na(PreVal_Ave)) # 0 students missing pre val
## # A tibble: 0 x 13
## # ... with 13 variables: Gender <int>, Age <int>, PreUV_all_ave <dbl>,
## #   PostUV_all_ave <dbl>, PreInt_Ave <dbl>, PreEff_Ave <dbl>, Int <int>,
## #   PreUV_ave <dbl>, PostUV_ave <dbl>, PostInt_Ave <dbl>,
## #   PreVal_Ave <dbl>, PostVal_Ave <dbl>, ClassTeacher <fctr>
df %>%
  filter(is.na(PostVal_Ave)) # 16 students missing pre val
## # A tibble: 16 x 13
##    Gender   Age PreUV_all_ave PostUV_all_ave PreInt_Ave PreEff_Ave   Int
##     <int> <int>         <dbl>          <dbl>      <dbl>      <dbl> <int>
##  1      0    11           7.0             NA       7.00        7.0     1
##  2      0    10           3.6             NA       5.60        3.2    NA
##  3      0    11           3.6             NA       4.40        6.2     1
##  4      0    11           6.8             NA       6.40        6.4     1
##  5      1    11           7.0             NA       7.00        6.8     1
##  6      1    11           6.4             NA       6.80        3.0    NA
##  7      1    11           5.2             NA       7.00        5.6     0
##  8      1    10            NA             NA       6.75        6.6    NA
##  9      0    10           7.0             NA       7.00        7.0     1
## 10      1    10           6.4             NA       6.60        5.8     1
## 11      0    11           4.8             NA       6.60        5.8     0
## 12      1    10           5.4             NA       6.80        5.6     0
## 13      0    10           5.8             NA       6.40        3.6     1
## 14      1    11           6.4             NA       6.60        5.8     0
## 15      0    10           5.2             NA       5.00        2.8    NA
## 16      0    10           2.8             NA       1.00        3.4    NA
## # ... with 6 more variables: PreUV_ave <dbl>, PostUV_ave <dbl>,
## #   PostInt_Ave <dbl>, PreVal_Ave <dbl>, PostVal_Ave <dbl>,
## #   ClassTeacher <fctr>
df %>%
  filter(is.na(PreVal_Ave) | is.na(PostVal_Ave)) # 16 students missing either pre or post val
## # A tibble: 16 x 13
##    Gender   Age PreUV_all_ave PostUV_all_ave PreInt_Ave PreEff_Ave   Int
##     <int> <int>         <dbl>          <dbl>      <dbl>      <dbl> <int>
##  1      0    11           7.0             NA       7.00        7.0     1
##  2      0    10           3.6             NA       5.60        3.2    NA
##  3      0    11           3.6             NA       4.40        6.2     1
##  4      0    11           6.8             NA       6.40        6.4     1
##  5      1    11           7.0             NA       7.00        6.8     1
##  6      1    11           6.4             NA       6.80        3.0    NA
##  7      1    11           5.2             NA       7.00        5.6     0
##  8      1    10            NA             NA       6.75        6.6    NA
##  9      0    10           7.0             NA       7.00        7.0     1
## 10      1    10           6.4             NA       6.60        5.8     1
## 11      0    11           4.8             NA       6.60        5.8     0
## 12      1    10           5.4             NA       6.80        5.6     0
## 13      0    10           5.8             NA       6.40        3.6     1
## 14      1    11           6.4             NA       6.60        5.8     0
## 15      0    10           5.2             NA       5.00        2.8    NA
## 16      0    10           2.8             NA       1.00        3.4    NA
## # ... with 6 more variables: PreUV_ave <dbl>, PostUV_ave <dbl>,
## #   PostInt_Ave <dbl>, PreVal_Ave <dbl>, PostVal_Ave <dbl>,
## #   ClassTeacher <fctr>
# INTEREST

df %>%
  filter(is.na(PreInt_Ave)) # 0 students missing pre interest
## # A tibble: 0 x 13
## # ... with 13 variables: Gender <int>, Age <int>, PreUV_all_ave <dbl>,
## #   PostUV_all_ave <dbl>, PreInt_Ave <dbl>, PreEff_Ave <dbl>, Int <int>,
## #   PreUV_ave <dbl>, PostUV_ave <dbl>, PostInt_Ave <dbl>,
## #   PreVal_Ave <dbl>, PostVal_Ave <dbl>, ClassTeacher <fctr>
df %>%
  filter(is.na(PostInt_Ave)) # 16 students missing pre int
## # A tibble: 16 x 13
##    Gender   Age PreUV_all_ave PostUV_all_ave PreInt_Ave PreEff_Ave   Int
##     <int> <int>         <dbl>          <dbl>      <dbl>      <dbl> <int>
##  1      0    11           7.0             NA       7.00        7.0     1
##  2      0    10           3.6             NA       5.60        3.2    NA
##  3      0    11           3.6             NA       4.40        6.2     1
##  4      0    11           6.8             NA       6.40        6.4     1
##  5      1    11           7.0             NA       7.00        6.8     1
##  6      1    11           6.4             NA       6.80        3.0    NA
##  7      1    11           5.2             NA       7.00        5.6     0
##  8      1    10            NA             NA       6.75        6.6    NA
##  9      0    10           7.0             NA       7.00        7.0     1
## 10      1    10           6.4             NA       6.60        5.8     1
## 11      0    11           4.8             NA       6.60        5.8     0
## 12      1    10           5.4             NA       6.80        5.6     0
## 13      0    10           5.8             NA       6.40        3.6     1
## 14      1    11           6.4             NA       6.60        5.8     0
## 15      0    10           5.2             NA       5.00        2.8    NA
## 16      0    10           2.8             NA       1.00        3.4    NA
## # ... with 6 more variables: PreUV_ave <dbl>, PostUV_ave <dbl>,
## #   PostInt_Ave <dbl>, PreVal_Ave <dbl>, PostVal_Ave <dbl>,
## #   ClassTeacher <fctr>
df %>%
  filter(is.na(PreInt_Ave) | is.na(PostInt_Ave)) # 16 students missing either pre or post int
## # A tibble: 16 x 13
##    Gender   Age PreUV_all_ave PostUV_all_ave PreInt_Ave PreEff_Ave   Int
##     <int> <int>         <dbl>          <dbl>      <dbl>      <dbl> <int>
##  1      0    11           7.0             NA       7.00        7.0     1
##  2      0    10           3.6             NA       5.60        3.2    NA
##  3      0    11           3.6             NA       4.40        6.2     1
##  4      0    11           6.8             NA       6.40        6.4     1
##  5      1    11           7.0             NA       7.00        6.8     1
##  6      1    11           6.4             NA       6.80        3.0    NA
##  7      1    11           5.2             NA       7.00        5.6     0
##  8      1    10            NA             NA       6.75        6.6    NA
##  9      0    10           7.0             NA       7.00        7.0     1
## 10      1    10           6.4             NA       6.60        5.8     1
## 11      0    11           4.8             NA       6.60        5.8     0
## 12      1    10           5.4             NA       6.80        5.6     0
## 13      0    10           5.8             NA       6.40        3.6     1
## 14      1    11           6.4             NA       6.60        5.8     0
## 15      0    10           5.2             NA       5.00        2.8    NA
## 16      0    10           2.8             NA       1.00        3.4    NA
## # ... with 6 more variables: PreUV_ave <dbl>, PostUV_ave <dbl>,
## #   PostInt_Ave <dbl>, PreVal_Ave <dbl>, PostVal_Ave <dbl>,
## #   ClassTeacher <fctr>
# SELF-EFFICACY

df %>% 
  filter(is.na(PreEff_Ave)) # 0 students missing pre eff ave
## # A tibble: 0 x 13
## # ... with 13 variables: Gender <int>, Age <int>, PreUV_all_ave <dbl>,
## #   PostUV_all_ave <dbl>, PreInt_Ave <dbl>, PreEff_Ave <dbl>, Int <int>,
## #   PreUV_ave <dbl>, PostUV_ave <dbl>, PostInt_Ave <dbl>,
## #   PreVal_Ave <dbl>, PostVal_Ave <dbl>, ClassTeacher <fctr>
# GENDER

df %>% 
  filter(is.na(Gender)) # 0 missing
## # A tibble: 0 x 13
## # ... with 13 variables: Gender <int>, Age <int>, PreUV_all_ave <dbl>,
## #   PostUV_all_ave <dbl>, PreInt_Ave <dbl>, PreEff_Ave <dbl>, Int <int>,
## #   PreUV_ave <dbl>, PostUV_ave <dbl>, PostInt_Ave <dbl>,
## #   PreVal_Ave <dbl>, PostVal_Ave <dbl>, ClassTeacher <fctr>
df %>% 
  filter(is.na(ClassTeacher)) # 0 missing
## # A tibble: 0 x 13
## # ... with 13 variables: Gender <int>, Age <int>, PreUV_all_ave <dbl>,
## #   PostUV_all_ave <dbl>, PreInt_Ave <dbl>, PreEff_Ave <dbl>, Int <int>,
## #   PreUV_ave <dbl>, PostUV_ave <dbl>, PostInt_Ave <dbl>,
## #   PreVal_Ave <dbl>, PostVal_Ave <dbl>, ClassTeacher <fctr>