library(tidyverse)
## Warning: package 'tibble' was built under R version 3.4.3
## Warning: package 'tidyr' was built under R version 3.4.3
library(lmerTest)
## Warning: package 'lmerTest' was built under R version 3.4.3
## Warning: package 'lme4' was built under R version 3.4.3
library(lme4)
library(corrr)
library(jmRtools)
library(gmodels)
library(psych)
esm <- read_csv("/Volumes/SCHMIDTLAB/PSE/data/STEM-IE/STEM-IE-esm.csv")
pre_survey_data_processed <- read_csv("/Volumes/SCHMIDTLAB/PSE/data/STEM-IE/STEM-IE-pre-survey.csv")
pre_survey_all_variables <- read_csv("/Volumes/SCHMIDTLAB/PSE/data/STEM-IE/STEM-IE-pre-survey-data-processed.csv")
post_survey_data_partially_processed <- read_csv("/Volumes/SCHMIDTLAB/PSE/data/STEM-IE/STEM-IE-post-survey.csv")
video <- read_csv("/Volumes/SCHMIDTLAB/PSE/data/STEM-IE/STEM-IE-video.csv")
pqa <- read_csv("/Volumes/SCHMIDTLAB/PSE/data/STEM-IE/STEM-IE-pqa.csv")
attendance <- read_csv("/Volumes/SCHMIDTLAB/PSE/data/STEM-IE/STEM-IE-attendance.csv")
class_data <- read_csv("/Volumes/SCHMIDTLAB/PSE/data/STEM-IE/STEM-IE-class-video.csv")
demographics <- read_csv("/Volumes/SCHMIDTLAB/PSE/data/STEM-IE/STEM-IE-demographics.csv")
pm <- read_csv("/Volumes/SCHMIDTLAB/PSE/Data/STEM-IE/STEM-IE-program-match.csv")
value <- read_csv("/Volumes/SCHMIDTLAB/PSE/Data/STEM-IE/STEM-IE-value.csv")
community_space <- read_csv("/Volumes/SCHMIDTLAB/PSE/Data/STEM-IE/STEM-IE-community-space-content.csv")

Creating motivation to attend variable

pre_survey_all_variables$motivation_to_attend <- ifelse(pre_survey_all_variables$how_much_looking_forward == 1, 0, 1)
attendance <- rename(attendance, participant_ID = ParticipantID)
attendance <- mutate(attendance, prop_attend = DaysAttended / DaysScheduled, 
                     participant_ID = as.integer(participant_ID))
attendance <- select(attendance, participant_ID, prop_attend)

demographics <- filter(demographics, participant_ID!= 7187)
demographics <- left_join(demographics, attendance)

esm$overall_engagement <- jmRtools::composite_mean_maker(esm, hard_working, concentrating, enjoy, interest)

pre_survey_all_variables <- rename(pre_survey_all_variables, program_ID_string = program_ID)
pre_survey_all_variables <- rename(pre_survey_all_variables, program_providence_useless = program_providence)
df <- left_join(esm, pre_survey_data_processed, by = "participant_ID") # df = esm & pre-survey
df <- left_join(df, video, by = c("program_ID", "response_date", "sociedad_class", "signal_number")) # df & video
df <- left_join(df, demographics, by = c("participant_ID", "program_ID")) # df and demographics
df <- left_join(df, pre_survey_all_variables, by = "participant_ID") #df & pre-survey all variables Not sure what two program id's now
pqa <- mutate(pqa, 
              active = active_part_1 + active_part_2,
              ho_thinking = ho_thinking_1 + ho_thinking_2 + ho_thinking_3,
              belonging = belonging_1 + belonging_2,
              agency = agency_1 + agency_2 + agency_3 + agency_4,
              youth_development_overall = active_part_1 + active_part_2 + ho_thinking_1 + ho_thinking_2 + ho_thinking_3 + belonging_1 + belonging_2 + agency_1 + agency_2 + agency_3 + agency_4,
              making_observations = stem_sb_8,
              data_modeling = stem_sb_2 + stem_sb_3 + stem_sb_9,
              interpreting_communicating = stem_sb_6,
              generating_data = stem_sb_4,
              asking_questions = stem_sb_1,
              stem_sb = stem_sb_1 + stem_sb_2 + stem_sb_3 + stem_sb_4 + stem_sb_5 + stem_sb_6 + stem_sb_7 + stem_sb_8 + stem_sb_9)

pqa$stem_sb_dummy <- ifelse(pqa$stem_sb == 0, 0, 1)

# pqa <- rename(pqa, sixth_math_sociedad = sixth_math)
# pqa <- rename(pqa, seventh_math_sociedad = seventh_math)
# pqa <- rename(pqa, eighth_math_sociedad = eighth_math)
# pqa <- rename(pqa, dance_sociedad = dance)
# pqa <- rename(pqa, robotics_sociedad = robotics)

pqa$sociedad_class <- ifelse(pqa$eighth_math == 1, "8th Math",
                             ifelse(pqa$seventh_math == 1, "7th Math",
                                    ifelse(pqa$sixth_math == 1, "6th Math",
                                           ifelse(pqa$robotics == 1, "Robotics",
                                                  ifelse(pqa$dance == 1, "Dance", NA)))))

pqa <- rename(pqa, 
              program_ID = SiteIDNumeric,
              response_date = resp_date,
              signal_number = signal)

pqa$program_ID <- as.character(pqa$program_ID)

df <- left_join(df, pqa, by = c("response_date", "program_ID", "signal_number", "sociedad_class"))
## Warning: Column `program_ID` joining factor and character vector, coercing
## into character vector
# !!! MERGE PQA

pqa$sociedad_class <- ifelse(pqa$eighth_math == 1, "8th Math",
                             ifelse(pqa$seventh_math == 1, "7th Math",
                                    ifelse(pqa$sixth_math == 1, "6th Math",
                                           ifelse(pqa$robotics == 1, "Robotics",
                                                  ifelse(pqa$dance == 1, "Dance", NA)))))

pqa$program_ID <- as.character(pqa$program_ID)

df <- left_join(df, pqa, by = c("response_date", "program_ID", "signal_number", "sociedad_class"))

# !!!

# !!! MERGE CLASS

class_data$COMPOSIT <- jmRtools::composite_mean_maker(class_data, ID, P, AI, ILF, QF, CU)

class_data$sociedad_class <- ifelse(class_data$eighth_math == 1, "8th Math",
                                    ifelse(class_data$seventh_math == 1, "7th Math",
                                           ifelse(class_data$sixth_math == 1, "6th Math",
                                                  ifelse(class_data$robotics == 1, "Robotics",
                                                         ifelse(class_data$dance == 1, "Dance", NA)))))

class_data$program_ID <- as.character(class_data$SiteIDNumeric)

class_data <- rename(class_data,
                     response_date = Responsedate,
                     signal_number = r_signal_number)

df <- left_join(df, class_data, by = c("response_date", "program_ID", "signal_number", "sociedad_class"))

df <-left_join(df, pqa)

# !!!
df <- df %>% 
    mutate(youth_activity_three = case_when(
        youth_activity_rc == "Creating Product" ~ "Creating Product",
        youth_activity_rc == "Basic Skills Activity" ~ "Basic Skills Activity",
        TRUE ~ "Other"
    ))

df$youth_activity_three <- fct_relevel(df$youth_activity_three, 
                                       "Other")
df <- df %>% 
    mutate(ho_thinking_dummy = ifelse(ho_thinking > 0, 1, 0),
           agency_dummy = ifelse(agency > 0, 1, 0),
           active_dummy = ifelse(active > 0, 1, 0),
           belonging_dummy = ifelse(belonging > 0, 1, 0),
           stem_sb_dummy = ifelse(sum_stem_sb > 0, 1, 0))

Creating subject variable

#pqa$subject <-ifelse(pqa$science == 1, "Science",
#ifelse(pqa$mathematics == 1, "Math",
#ifelse(pqa$building == 1, "Building", NA)))

df$subject <-ifelse(df$science == 1, "Science",
                    ifelse(df$mathematics == 1, "Math",
                           ifelse(df$building == 1, "Building", NA)))

df$subject_other <- ifelse(df$science == 0 &
                               df$mathematics == 0 &
                               df$building == 0, 1, 0)

Creating variable that is >=3

df$agency_comp_three <- ifelse(df$agency >= 3 & df$COMPOSIT >=3, 1, 0)

Joining Community Space data set

community_space <- rename(community_space,
                          response_date = resp_date,
                          signal_number = signal,
                          program_ID = SiteIDNumeric)

community_space$program_ID <- as.character(community_space$program_ID)



community_space$sociedad_class <- ifelse(community_space$eighth_math == 1, "8th Math",
                                         ifelse(community_space$seventh_math == 1, "7th Math",
                                                ifelse(community_space$sixth_math == 1, "6th Math",
                                                       ifelse(community_space$robotics == 1, "Robotics",
                                                              ifelse(community_space$dance == 1, "Dance", NA)))))

community_space$response_date <- format(as.Date(community_space$response_date, format = "%m/%d/%Y"), "%Y-%m-%d")
## Warning in strptime(x, format, tz = "GMT"): unknown timezone 'zone/tz/
## 2018c.1.0/zoneinfo/America/Detroit'
community_space <- mutate(community_space, response_date = as.character(response_date))
df <- mutate(df, response_date = as.character(response_date))

df <- left_join(df, community_space, by = c("response_date", "program_ID", "signal_number", "sociedad_class"))

Joining Value data set

value <- rename(value,
                response_date = resp_date,
                signal_number = signal,
                program_ID = SiteIDNumeric)

value$program_ID <- as.character(value$program_ID)

value$sociedad_class <- ifelse(value$eighth_math == 1, "8th Math",
                               ifelse(value$seventh_math == 1, "7th Math",
                                      ifelse(value$sixth_math == 1, "6th Math",
                                             ifelse(value$robotics == 1, "Robotics",
                                                    ifelse(value$dance == 1, "Dance", NA)))))

value$response_date <- format(as.Date(value$response_date, format = "%m/%d/%Y"), "%Y-%m-%d")

value <- mutate(value, response_date = as.character(response_date))

df <- left_join(df, value, by = c("response_date", "program_ID", "signal_number", "sociedad_class"))

Creating variables for value

df$all_value_sum <- df$V01.01.HighUtility_sum + df$V01.03.HighIntrinsic_sum + df$V01.05.HighAttainment_sum

Engagement Models

Predicting engagement

engagement_model <- lmer(overall_engagement ~ 
                             gender_female +
                             challenge + 
                             relevance + 
                             learning + 
                             overall_pre_competence_beliefs +
                             Community_Space_Content +
                             (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                         data = df)

summary(engagement_model)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: overall_engagement ~ gender_female + challenge + relevance +  
##     learning + overall_pre_competence_beliefs + Community_Space_Content +  
##     (1 | program_ID) + (1 | participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 3882.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0286 -0.5407  0.0273  0.5170  3.8923 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.01656  0.1287  
##  participant_ID (Intercept) 0.07302  0.2702  
##  program_ID     (Intercept) 0.01067  0.1033  
##  Residual                   0.22235  0.4715  
## Number of obs: 2558, groups:  
## beep_ID_new, 237; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                  Estimate Std. Error         df t value
## (Intercept)                       0.88964    0.11163  132.00000   7.969
## gender_female                     0.03517    0.04713  172.30000   0.746
## challenge                         0.03602    0.01142 2518.00000   3.156
## relevance                         0.36014    0.01633 2486.20000  22.049
## learning                          0.28871    0.01295 2483.60000  22.302
## overall_pre_competence_beliefs    0.04457    0.02978  170.90000   1.497
## Community_Space_Content          -0.06825    0.03592  216.60000  -1.900
##                                Pr(>|t|)    
## (Intercept)                    6.59e-13 ***
## gender_female                   0.45661    
## challenge                       0.00162 ** 
## relevance                       < 2e-16 ***
## learning                        < 2e-16 ***
## overall_pre_competence_beliefs  0.13636    
## Community_Space_Content         0.05875 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f chllng relvnc lernng ovr___
## gender_feml -0.204                                   
## challenge   -0.198  0.042                            
## relevance   -0.175  0.068 -0.156                     
## learning    -0.080 -0.023 -0.086 -0.496              
## ovrll_pr_c_ -0.808 -0.052  0.051 -0.025 -0.034       
## Cmmnty_Sp_C -0.045  0.001 -0.020 -0.037 -0.007 -0.001

Predicting engagement with gender interactions

engagement_model_gender <- lmer(overall_engagement ~ 
                                    gender_female +
                                    challenge + 
                                    relevance + 
                                    learning + 
                                    overall_pre_competence_beliefs +
                                    Community_Space_Content +
                                    gender_female*challenge +
                                    gender_female*relevance +
                                    gender_female*learning + 
                                    (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                                data = df)

summary(engagement_model_gender)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: overall_engagement ~ gender_female + challenge + relevance +  
##     learning + overall_pre_competence_beliefs + Community_Space_Content +  
##     gender_female * challenge + gender_female * relevance + gender_female *  
##     learning + (1 | program_ID) + (1 | participant_ID) + (1 |  
##     beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 3886
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0050 -0.5360  0.0197  0.5181  4.0385 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.01681  0.1296  
##  participant_ID (Intercept) 0.07237  0.2690  
##  program_ID     (Intercept) 0.01125  0.1060  
##  Residual                   0.22134  0.4705  
## Number of obs: 2558, groups:  
## beep_ID_new, 237; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                  Estimate Std. Error         df t value
## (Intercept)                       0.75165    0.11957  161.00000   6.286
## gender_female                     0.28988    0.09560  960.30000   3.032
## challenge                         0.05620    0.01575 2506.30000   3.567
## relevance                         0.40728    0.02396 2481.90000  16.997
## learning                          0.27533    0.01982 2484.70000  13.888
## overall_pre_competence_beliefs    0.04354    0.02975  171.90000   1.463
## Community_Space_Content          -0.06320    0.03604  216.80000  -1.754
## gender_female:challenge          -0.04110    0.02237 2472.80000  -1.837
## gender_female:relevance          -0.08581    0.03246 2449.90000  -2.643
## gender_female:learning            0.02294    0.02609 2467.20000   0.879
##                                Pr(>|t|)    
## (Intercept)                    2.92e-09 ***
## gender_female                  0.002492 ** 
## challenge                      0.000368 ***
## relevance                       < 2e-16 ***
## learning                        < 2e-16 ***
## overall_pre_competence_beliefs 0.145176    
## Community_Space_Content        0.080913 .  
## gender_female:challenge        0.066336 .  
## gender_female:relevance        0.008264 ** 
## gender_female:learning         0.379470    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f chllng relvnc lernng ovr___ Cm_S_C gndr_fml:c
## gender_feml -0.403                                                     
## challenge   -0.228  0.234                                              
## relevance   -0.252  0.330 -0.132                                       
## learning    -0.109  0.194 -0.105 -0.516                                
## ovrll_pr_c_ -0.739 -0.058  0.038 -0.014 -0.057                         
## Cmmnty_Sp_C -0.057  0.033  0.007 -0.010 -0.007 -0.002                  
## gndr_fml:ch  0.138 -0.324 -0.690  0.091  0.073  0.000 -0.030           
## gndr_fml:rl  0.196 -0.428  0.096 -0.732  0.379 -0.003 -0.021 -0.154    
## gndr_fml:lr  0.081 -0.269  0.086  0.388 -0.759  0.046  0.003 -0.099    
##             gndr_fml:r
## gender_feml           
## challenge             
## relevance             
## learning              
## ovrll_pr_c_           
## Cmmnty_Sp_C           
## gndr_fml:ch           
## gndr_fml:rl           
## gndr_fml:lr -0.496

Predicting engagement with competence interactions

engagement_model_competence <- lmer(overall_engagement ~ 
                                        gender_female +
                                        challenge + 
                                        relevance + 
                                        learning + 
                                        overall_pre_competence_beliefs +
                                        Community_Space_Content +
                                        overall_pre_competence_beliefs*challenge +
                                        overall_pre_competence_beliefs*relevance +
                                        overall_pre_competence_beliefs*learning + 
                                        (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                                    data = df)

summary(engagement_model_competence)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: overall_engagement ~ gender_female + challenge + relevance +  
##     learning + overall_pre_competence_beliefs + Community_Space_Content +  
##     overall_pre_competence_beliefs * challenge + overall_pre_competence_beliefs *  
##     relevance + overall_pre_competence_beliefs * learning + (1 |  
##     program_ID) + (1 | participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 3880.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9418 -0.5428  0.0256  0.5246  4.0097 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.01682  0.1297  
##  participant_ID (Intercept) 0.07293  0.2701  
##  program_ID     (Intercept) 0.01072  0.1036  
##  Residual                   0.22041  0.4695  
## Number of obs: 2558, groups:  
## beep_ID_new, 237; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                            Estimate Std. Error         df
## (Intercept)                                 0.91534    0.19373  608.90000
## gender_female                               0.03889    0.04718  172.90000
## challenge                                   0.21781    0.04388 2501.80000
## relevance                                   0.25648    0.06574 2475.00000
## learning                                    0.21242    0.05076 2501.20000
## overall_pre_competence_beliefs              0.03537    0.05927  820.30000
## Community_Space_Content                    -0.06923    0.03599  216.60000
## challenge:overall_pre_competence_beliefs   -0.05770    0.01353 2480.00000
## relevance:overall_pre_competence_beliefs    0.03252    0.02015 2434.50000
## learning:overall_pre_competence_beliefs     0.02383    0.01555 2505.50000
##                                          t value Pr(>|t|)    
## (Intercept)                                4.725 2.86e-06 ***
## gender_female                              0.824   0.4108    
## challenge                                  4.964 7.37e-07 ***
## relevance                                  3.901 9.83e-05 ***
## learning                                   4.185 2.96e-05 ***
## overall_pre_competence_beliefs             0.597   0.5508    
## Community_Space_Content                   -1.923   0.0557 .  
## challenge:overall_pre_competence_beliefs  -4.265 2.07e-05 ***
## relevance:overall_pre_competence_beliefs   1.614   0.1067    
## learning:overall_pre_competence_beliefs    1.533   0.1255    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f chllng relvnc lernng ovr___ Cm_S_C ch:___ rl:___
## gender_feml -0.075                                                        
## challenge   -0.319  0.003                                                 
## relevance   -0.438  0.016 -0.181                                          
## learning    -0.245 -0.059 -0.107 -0.453                                   
## ovrll_pr_c_ -0.941 -0.070  0.310  0.429  0.250                            
## Cmmnty_Sp_C  0.002  0.001 -0.021 -0.041  0.009 -0.030                     
## chllng:v___  0.309  0.009 -0.966  0.171  0.099 -0.325  0.017              
## rlvnc:vr___  0.429  0.001  0.173 -0.969  0.435 -0.448  0.033 -0.173       
## lrnng:vr___  0.243  0.055  0.101  0.437 -0.967 -0.265 -0.011 -0.098 -0.451

Challenge models

Predicting challenge with gender interactions

challenge_model <- lmer(challenge ~ 
                            gender_female + 
                            overall_pre_competence_beliefs +
                            Community_Space_Content +
                            youth_activity_rc + 
                            (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                        data = df)

summary(challenge_model)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: challenge ~ gender_female + overall_pre_competence_beliefs +  
##     Community_Space_Content + youth_activity_rc + (1 | program_ID) +  
##     (1 | participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 6561.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8804 -0.6343 -0.0339  0.5665  3.3306 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.06010  0.2452  
##  participant_ID (Intercept) 0.46579  0.6825  
##  program_ID     (Intercept) 0.01458  0.1207  
##  Residual                   0.65855  0.8115  
## Number of obs: 2474, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                         Estimate Std. Error        df
## (Intercept)                              2.70923    0.23030  98.06000
## gender_female                           -0.24095    0.11062 174.27000
## overall_pre_competence_beliefs          -0.12249    0.06811 133.55000
## Community_Space_Content                  0.20156    0.07608 184.93000
## youth_activity_rcBasic Skills Activity   0.03632    0.07055 194.87000
## youth_activity_rcCreating Product        0.32834    0.06898 210.82000
## youth_activity_rcField Trip Speaker     -0.27165    0.14565 133.87000
## youth_activity_rcLab Activity            0.07836    0.13397 152.93000
## youth_activity_rcProgram Staff Led      -0.14343    0.07986 180.60000
##                                        t value Pr(>|t|)    
## (Intercept)                             11.764  < 2e-16 ***
## gender_female                           -2.178  0.03075 *  
## overall_pre_competence_beliefs          -1.798  0.07439 .  
## Community_Space_Content                  2.649  0.00877 ** 
## youth_activity_rcBasic Skills Activity   0.515  0.60730    
## youth_activity_rcCreating Product        4.760  3.6e-06 ***
## youth_activity_rcField Trip Speaker     -1.865  0.06436 .  
## youth_activity_rcLab Activity            0.585  0.55948    
## youth_activity_rcProgram Staff Led      -1.796  0.07418 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f ovr___ Cm_S_C y__BSA yt__CP y__FTS yt__LA
## gender_feml -0.213                                                 
## ovrll_pr_c_ -0.906 -0.036                                          
## Cmmnty_Sp_C -0.042  0.011  0.009                                   
## yth_ctv_BSA -0.088 -0.008 -0.023 -0.272                            
## yth_ctvt_CP -0.103  0.008 -0.016  0.033  0.375                     
## yth_ctv_FTS -0.023  0.008 -0.033 -0.391  0.320  0.189              
## yth_ctvt_LA -0.034 -0.011 -0.022 -0.220  0.255  0.188  0.205       
## yth_ctv_PSL -0.103 -0.020  0.004 -0.054  0.410  0.311  0.187  0.194

Predicting challenge with gender interactions

challenge_model_female <- lmer(challenge ~ 
                                   gender_female + 
                                   overall_pre_competence_beliefs +
                                   Community_Space_Content +
                                   youth_activity_rc + 
                                   gender_female*youth_activity_rc +
                                   (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                               data = df)

summary(challenge_model_female)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: challenge ~ gender_female + overall_pre_competence_beliefs +  
##     Community_Space_Content + youth_activity_rc + gender_female *  
##     youth_activity_rc + (1 | program_ID) + (1 | participant_ID) +  
##     (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 6570.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8251 -0.6385 -0.0339  0.5614  3.2442 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.06034  0.2456  
##  participant_ID (Intercept) 0.46743  0.6837  
##  program_ID     (Intercept) 0.01391  0.1179  
##  Residual                   0.65884  0.8117  
## Number of obs: 2474, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                        Estimate Std. Error
## (Intercept)                                             2.73668    0.23148
## gender_female                                          -0.29683    0.12238
## overall_pre_competence_beliefs                         -0.12174    0.06816
## Community_Space_Content                                 0.19893    0.07620
## youth_activity_rcBasic Skills Activity                 -0.02198    0.08781
## youth_activity_rcCreating Product                       0.27790    0.08728
## youth_activity_rcField Trip Speaker                    -0.35267    0.16260
## youth_activity_rcLab Activity                           0.15492    0.17322
## youth_activity_rcProgram Staff Led                     -0.17431    0.10398
## gender_female:youth_activity_rcBasic Skills Activity    0.10958    0.09851
## gender_female:youth_activity_rcCreating Product         0.09366    0.10293
## gender_female:youth_activity_rcField Trip Speaker       0.18638    0.17330
## gender_female:youth_activity_rcLab Activity            -0.12254    0.18513
## gender_female:youth_activity_rcProgram Staff Led        0.05859    0.11494
##                                                              df t value
## (Intercept)                                            99.00000  11.823
## gender_female                                         257.90000  -2.425
## overall_pre_competence_beliefs                        132.20000  -1.786
## Community_Space_Content                               185.10000   2.611
## youth_activity_rcBasic Skills Activity                428.50000  -0.250
## youth_activity_rcCreating Product                     488.40000   3.184
## youth_activity_rcField Trip Speaker                   204.40000  -2.169
## youth_activity_rcLab Activity                         388.40000   0.894
## youth_activity_rcProgram Staff Led                    471.40000  -1.676
## gender_female:youth_activity_rcBasic Skills Activity 2342.00000   1.112
## gender_female:youth_activity_rcCreating Product      2346.50000   0.910
## gender_female:youth_activity_rcField Trip Speaker    2253.20000   1.075
## gender_female:youth_activity_rcLab Activity          2348.40000  -0.662
## gender_female:youth_activity_rcProgram Staff Led     2320.60000   0.510
##                                                      Pr(>|t|)    
## (Intercept)                                           < 2e-16 ***
## gender_female                                         0.01598 *  
## overall_pre_competence_beliefs                        0.07639 .  
## Community_Space_Content                               0.00978 ** 
## youth_activity_rcBasic Skills Activity                0.80246    
## youth_activity_rcCreating Product                     0.00155 ** 
## youth_activity_rcField Trip Speaker                   0.03124 *  
## youth_activity_rcLab Activity                         0.37166    
## youth_activity_rcProgram Staff Led                    0.09433 .  
## gender_female:youth_activity_rcBasic Skills Activity  0.26608    
## gender_female:youth_activity_rcCreating Product       0.36294    
## gender_female:youth_activity_rcField Trip Speaker     0.28227    
## gender_female:youth_activity_rcLab Activity           0.50808    
## gender_female:youth_activity_rcProgram Staff Led      0.61029    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Predicting challenge with competence interactions

challenge_model_competence <- lmer(challenge ~ 
                                       gender_female + 
                                       overall_pre_competence_beliefs +
                                       Community_Space_Content +
                                       youth_activity_rc + 
                                       overall_pre_competence_beliefs*youth_activity_rc +
                                       (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                                   data = df)

summary(challenge_model_competence)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: challenge ~ gender_female + overall_pre_competence_beliefs +  
##     Community_Space_Content + youth_activity_rc + overall_pre_competence_beliefs *  
##     youth_activity_rc + (1 | program_ID) + (1 | participant_ID) +  
##     (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 6573
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8421 -0.6336 -0.0343  0.5591  3.4796 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.06049  0.2459  
##  participant_ID (Intercept) 0.46462  0.6816  
##  program_ID     (Intercept) 0.01545  0.1243  
##  Residual                   0.65862  0.8116  
## Number of obs: 2474, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                                         Estimate
## (Intercept)                                                              2.73062
## gender_female                                                           -0.23674
## overall_pre_competence_beliefs                                          -0.12977
## Community_Space_Content                                                  0.20635
## youth_activity_rcBasic Skills Activity                                  -0.10980
## youth_activity_rcCreating Product                                        0.40251
## youth_activity_rcField Trip Speaker                                      0.31374
## youth_activity_rcLab Activity                                           -0.09225
## youth_activity_rcProgram Staff Led                                      -0.35243
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity    0.04517
## overall_pre_competence_beliefs:youth_activity_rcCreating Product        -0.02267
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker      -0.17088
## overall_pre_competence_beliefs:youth_activity_rcLab Activity             0.05089
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led        0.06691
##                                                                       Std. Error
## (Intercept)                                                              0.24720
## gender_female                                                            0.11060
## overall_pre_competence_beliefs                                           0.07434
## Community_Space_Content                                                  0.07661
## youth_activity_rcBasic Skills Activity                                   0.20994
## youth_activity_rcCreating Product                                        0.20862
## youth_activity_rcField Trip Speaker                                      0.42647
## youth_activity_rcLab Activity                                            0.45104
## youth_activity_rcProgram Staff Led                                       0.23844
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity    0.06250
## overall_pre_competence_beliefs:youth_activity_rcCreating Product         0.06270
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker       0.11931
## overall_pre_competence_beliefs:youth_activity_rcLab Activity             0.13131
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led        0.07343
##                                                                               df
## (Intercept)                                                            134.50000
## gender_female                                                          174.40000
## overall_pre_competence_beliefs                                         199.10000
## Community_Space_Content                                                188.20000
## youth_activity_rcBasic Skills Activity                                1687.30000
## youth_activity_rcCreating Product                                     2039.40000
## youth_activity_rcField Trip Speaker                                   1435.80000
## youth_activity_rcLab Activity                                         1862.70000
## youth_activity_rcProgram Staff Led                                    1731.00000
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity 2271.90000
## overall_pre_competence_beliefs:youth_activity_rcCreating Product      2348.80000
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker    2153.80000
## overall_pre_competence_beliefs:youth_activity_rcLab Activity          2212.90000
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led     2231.20000
##                                                                       t value
## (Intercept)                                                            11.046
## gender_female                                                          -2.140
## overall_pre_competence_beliefs                                         -1.746
## Community_Space_Content                                                 2.693
## youth_activity_rcBasic Skills Activity                                 -0.523
## youth_activity_rcCreating Product                                       1.929
## youth_activity_rcField Trip Speaker                                     0.736
## youth_activity_rcLab Activity                                          -0.205
## youth_activity_rcProgram Staff Led                                     -1.478
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity   0.723
## overall_pre_competence_beliefs:youth_activity_rcCreating Product       -0.362
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker     -1.432
## overall_pre_competence_beliefs:youth_activity_rcLab Activity            0.388
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led       0.911
##                                                                       Pr(>|t|)
## (Intercept)                                                            < 2e-16
## gender_female                                                          0.03371
## overall_pre_competence_beliefs                                         0.08243
## Community_Space_Content                                                0.00771
## youth_activity_rcBasic Skills Activity                                 0.60103
## youth_activity_rcCreating Product                                      0.05382
## youth_activity_rcField Trip Speaker                                    0.46205
## youth_activity_rcLab Activity                                          0.83796
## youth_activity_rcProgram Staff Led                                     0.13957
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity  0.46989
## overall_pre_competence_beliefs:youth_activity_rcCreating Product       0.71775
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker     0.15224
## overall_pre_competence_beliefs:youth_activity_rcLab Activity           0.69837
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led      0.36229
##                                                                          
## (Intercept)                                                           ***
## gender_female                                                         *  
## overall_pre_competence_beliefs                                        .  
## Community_Space_Content                                               ** 
## youth_activity_rcBasic Skills Activity                                   
## youth_activity_rcCreating Product                                     .  
## youth_activity_rcField Trip Speaker                                      
## youth_activity_rcLab Activity                                            
## youth_activity_rcProgram Staff Led                                       
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity    
## overall_pre_competence_beliefs:youth_activity_rcCreating Product         
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker       
## overall_pre_competence_beliefs:youth_activity_rcLab Activity             
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led        
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Relevance Models

Predicting relevance

relevance_model <- lmer(relevance ~ 
                            gender_female + 
                            overall_pre_competence_beliefs +
                            Community_Space_Content +
                            youth_activity_rc + 
                            (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                        data = df)

summary(relevance_model)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: relevance ~ gender_female + overall_pre_competence_beliefs +  
##     Community_Space_Content + youth_activity_rc + (1 | program_ID) +  
##     (1 | participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 5375.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8799 -0.5198  0.0240  0.5733  4.0732 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.008112 0.09006 
##  participant_ID (Intercept) 0.478767 0.69193 
##  program_ID     (Intercept) 0.010293 0.10145 
##  Residual                   0.410223 0.64049 
## Number of obs: 2474, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                         Estimate Std. Error        df
## (Intercept)                              2.41826    0.22230  97.81000
## gender_female                           -0.24514    0.10890 176.89000
## overall_pre_competence_beliefs           0.05636    0.06641 124.14000
## Community_Space_Content                  0.14332    0.04670 181.27000
## youth_activity_rcBasic Skills Activity   0.09519    0.04348 189.58000
## youth_activity_rcCreating Product        0.20051    0.04315 230.25000
## youth_activity_rcField Trip Speaker      0.15841    0.08455 115.88000
## youth_activity_rcLab Activity            0.04009    0.07951 140.29000
## youth_activity_rcProgram Staff Led       0.11707    0.04878 180.82000
##                                        t value Pr(>|t|)    
## (Intercept)                             10.878  < 2e-16 ***
## gender_female                           -2.251  0.02561 *  
## overall_pre_competence_beliefs           0.849  0.39769    
## Community_Space_Content                  3.069  0.00248 ** 
## youth_activity_rcBasic Skills Activity   2.189  0.02980 *  
## youth_activity_rcCreating Product        4.647 5.67e-06 ***
## youth_activity_rcField Trip Speaker      1.874  0.06351 .  
## youth_activity_rcLab Activity            0.504  0.61492    
## youth_activity_rcProgram Staff Led       2.400  0.01741 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f ovr___ Cm_S_C y__BSA yt__CP y__FTS yt__LA
## gender_feml -0.223                                                 
## ovrll_pr_c_ -0.918 -0.030                                          
## Cmmnty_Sp_C -0.030  0.011  0.006                                   
## yth_ctv_BSA -0.052 -0.006 -0.017 -0.267                            
## yth_ctvt_CP -0.062  0.005 -0.014  0.049  0.361                     
## yth_ctv_FTS -0.012  0.003 -0.025 -0.406  0.337  0.189              
## yth_ctvt_LA -0.017 -0.009 -0.018 -0.226  0.262  0.188  0.225       
## yth_ctv_PSL -0.064 -0.015  0.002 -0.052  0.419  0.306  0.196  0.200

Predicting relevance with gender interactions

relevance_model_female <- lmer(relevance ~ 
                                   gender_female + 
                                   overall_pre_competence_beliefs +
                                   Community_Space_Content +
                                   youth_activity_rc + 
                                   gender_female*youth_activity_rc +
                                   (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                               data = df)

summary(relevance_model_female)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: relevance ~ gender_female + overall_pre_competence_beliefs +  
##     Community_Space_Content + youth_activity_rc + gender_female *  
##     youth_activity_rc + (1 | program_ID) + (1 | participant_ID) +  
##     (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 5384.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8874 -0.5205  0.0297  0.5783  4.1480 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.007551 0.08690 
##  participant_ID (Intercept) 0.480271 0.69302 
##  program_ID     (Intercept) 0.009871 0.09935 
##  Residual                   0.410514 0.64071 
## Number of obs: 2474, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                        Estimate Std. Error
## (Intercept)                                             2.45382    0.22301
## gender_female                                          -0.31901    0.11618
## overall_pre_competence_beliefs                          0.05796    0.06645
## Community_Space_Content                                 0.13989    0.04646
## youth_activity_rcBasic Skills Activity                  0.03152    0.05924
## youth_activity_rcCreating Product                       0.11812    0.05976
## youth_activity_rcField Trip Speaker                     0.15043    0.10103
## youth_activity_rcLab Activity                          -0.05262    0.11568
## youth_activity_rcProgram Staff Led                      0.07868    0.07092
## gender_female:youth_activity_rcBasic Skills Activity    0.11685    0.07643
## gender_female:youth_activity_rcCreating Product         0.15473    0.07937
## gender_female:youth_activity_rcField Trip Speaker      -0.00497    0.13651
## gender_female:youth_activity_rcLab Activity             0.16103    0.14164
## gender_female:youth_activity_rcProgram Staff Led        0.07140    0.08941
##                                                              df t value
## (Intercept)                                            98.40000  11.003
## gender_female                                         227.00000  -2.746
## overall_pre_competence_beliefs                        123.10000   0.872
## Community_Space_Content                               181.80000   3.011
## youth_activity_rcBasic Skills Activity                543.30000   0.532
## youth_activity_rcCreating Product                     684.50000   1.977
## youth_activity_rcField Trip Speaker                   231.90000   1.489
## youth_activity_rcLab Activity                         480.60000  -0.455
## youth_activity_rcProgram Staff Led                    648.00000   1.109
## gender_female:youth_activity_rcBasic Skills Activity 2323.70000   1.529
## gender_female:youth_activity_rcCreating Product      2282.70000   1.950
## gender_female:youth_activity_rcField Trip Speaker    2295.10000  -0.036
## gender_female:youth_activity_rcLab Activity          2092.20000   1.137
## gender_female:youth_activity_rcProgram Staff Led     2329.60000   0.799
##                                                      Pr(>|t|)    
## (Intercept)                                           < 2e-16 ***
## gender_female                                         0.00652 ** 
## overall_pre_competence_beliefs                        0.38475    
## Community_Space_Content                               0.00297 ** 
## youth_activity_rcBasic Skills Activity                0.59485    
## youth_activity_rcCreating Product                     0.04848 *  
## youth_activity_rcField Trip Speaker                   0.13784    
## youth_activity_rcLab Activity                         0.64937    
## youth_activity_rcProgram Staff Led                    0.26767    
## gender_female:youth_activity_rcBasic Skills Activity  0.12642    
## gender_female:youth_activity_rcCreating Product       0.05135 .  
## gender_female:youth_activity_rcField Trip Speaker     0.97096    
## gender_female:youth_activity_rcLab Activity           0.25573    
## gender_female:youth_activity_rcProgram Staff Led      0.42459    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Predicting relevance with competence interactions

relevance_model_competence <- lmer(relevance ~ 
                                       gender_female + 
                                       overall_pre_competence_beliefs +
                                       Community_Space_Content +
                                       youth_activity_rc + 
                                       overall_pre_competence_beliefs*youth_activity_rc +
                                       (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                                   data = df)

summary(relevance_model_competence)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: relevance ~ gender_female + overall_pre_competence_beliefs +  
##     Community_Space_Content + youth_activity_rc + overall_pre_competence_beliefs *  
##     youth_activity_rc + (1 | program_ID) + (1 | participant_ID) +  
##     (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 5384.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.0007 -0.5180  0.0261  0.5655  4.0816 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.007749 0.08803 
##  participant_ID (Intercept) 0.475006 0.68921 
##  program_ID     (Intercept) 0.010388 0.10192 
##  Residual                   0.409952 0.64028 
## Number of obs: 2474, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                                         Estimate
## (Intercept)                                                              2.39506
## gender_female                                                           -0.24746
## overall_pre_competence_beliefs                                           0.06434
## Community_Space_Content                                                  0.14624
## youth_activity_rcBasic Skills Activity                                   0.30623
## youth_activity_rcCreating Product                                       -0.07031
## youth_activity_rcField Trip Speaker                                      0.31808
## youth_activity_rcLab Activity                                            0.37203
## youth_activity_rcProgram Staff Led                                       0.23394
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity   -0.06628
## overall_pre_competence_beliefs:youth_activity_rcCreating Product         0.08395
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker      -0.04934
## overall_pre_competence_beliefs:youth_activity_rcLab Activity            -0.10098
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led       -0.03735
##                                                                       Std. Error
## (Intercept)                                                              0.23177
## gender_female                                                            0.10854
## overall_pre_competence_beliefs                                           0.07000
## Community_Space_Content                                                  0.04687
## youth_activity_rcBasic Skills Activity                                   0.15519
## youth_activity_rcCreating Product                                        0.15729
## youth_activity_rcField Trip Speaker                                      0.30865
## youth_activity_rcLab Activity                                            0.33469
## youth_activity_rcProgram Staff Led                                       0.17669
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity    0.04747
## overall_pre_competence_beliefs:youth_activity_rcCreating Product         0.04821
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker       0.08891
## overall_pre_competence_beliefs:youth_activity_rcLab Activity             0.09862
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led        0.05557
##                                                                               df
## (Intercept)                                                            119.50000
## gender_female                                                          177.10000
## overall_pre_competence_beliefs                                         160.30000
## Community_Space_Content                                                186.30000
## youth_activity_rcBasic Skills Activity                                1549.40000
## youth_activity_rcCreating Product                                     2032.00000
## youth_activity_rcField Trip Speaker                                    937.50000
## youth_activity_rcLab Activity                                         1503.30000
## youth_activity_rcProgram Staff Led                                    1613.10000
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity 2045.80000
## overall_pre_competence_beliefs:youth_activity_rcCreating Product      2267.80000
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker    1343.80000
## overall_pre_competence_beliefs:youth_activity_rcLab Activity          1633.80000
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led     1972.90000
##                                                                       t value
## (Intercept)                                                            10.334
## gender_female                                                          -2.280
## overall_pre_competence_beliefs                                          0.919
## Community_Space_Content                                                 3.120
## youth_activity_rcBasic Skills Activity                                  1.973
## youth_activity_rcCreating Product                                      -0.447
## youth_activity_rcField Trip Speaker                                     1.031
## youth_activity_rcLab Activity                                           1.112
## youth_activity_rcProgram Staff Led                                      1.324
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity  -1.396
## overall_pre_competence_beliefs:youth_activity_rcCreating Product        1.741
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker     -0.555
## overall_pre_competence_beliefs:youth_activity_rcLab Activity           -1.024
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led      -0.672
##                                                                       Pr(>|t|)
## (Intercept)                                                             <2e-16
## gender_female                                                           0.0238
## overall_pre_competence_beliefs                                          0.3594
## Community_Space_Content                                                 0.0021
## youth_activity_rcBasic Skills Activity                                  0.0486
## youth_activity_rcCreating Product                                       0.6549
## youth_activity_rcField Trip Speaker                                     0.3030
## youth_activity_rcLab Activity                                           0.2665
## youth_activity_rcProgram Staff Led                                      0.1857
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity   0.1628
## overall_pre_competence_beliefs:youth_activity_rcCreating Product        0.0818
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker      0.5791
## overall_pre_competence_beliefs:youth_activity_rcLab Activity            0.3060
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led       0.5016
##                                                                          
## (Intercept)                                                           ***
## gender_female                                                         *  
## overall_pre_competence_beliefs                                           
## Community_Space_Content                                               ** 
## youth_activity_rcBasic Skills Activity                                *  
## youth_activity_rcCreating Product                                        
## youth_activity_rcField Trip Speaker                                      
## youth_activity_rcLab Activity                                            
## youth_activity_rcProgram Staff Led                                       
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity    
## overall_pre_competence_beliefs:youth_activity_rcCreating Product      .  
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker       
## overall_pre_competence_beliefs:youth_activity_rcLab Activity             
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led        
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Learning models

Predicting learning

learning_model <- lmer(learning ~ 
                           gender_female + 
                           overall_pre_competence_beliefs +
                           Community_Space_Content +
                           youth_activity_rc + 
                           (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                       data = df)

summary(learning_model)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: 
## learning ~ gender_female + overall_pre_competence_beliefs + Community_Space_Content +  
##     youth_activity_rc + (1 | program_ID) + (1 | participant_ID) +  
##     (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 6604.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.1852 -0.5625  0.1224  0.5818  2.7914 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev. 
##  beep_ID_new    (Intercept) 1.084e-02 1.041e-01
##  participant_ID (Intercept) 3.993e-01 6.319e-01
##  program_ID     (Intercept) 1.133e-14 1.064e-07
##  Residual                   7.115e-01 8.435e-01
## Number of obs: 2473, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                         Estimate Std. Error        df
## (Intercept)                              2.48735    0.20357 185.09000
## gender_female                           -0.07685    0.10225 177.61000
## overall_pre_competence_beliefs           0.07299    0.06109 182.55000
## Community_Space_Content                  0.08146    0.05930 160.88000
## youth_activity_rcBasic Skills Activity   0.18533    0.05551 167.20000
## youth_activity_rcCreating Product        0.10821    0.05544 203.74000
## youth_activity_rcField Trip Speaker      0.01733    0.10710 100.16000
## youth_activity_rcLab Activity            0.16330    0.10143 121.53000
## youth_activity_rcProgram Staff Led       0.06118    0.06235 159.90000
##                                        t value Pr(>|t|)    
## (Intercept)                             12.218  < 2e-16 ***
## gender_female                           -0.752  0.45327    
## overall_pre_competence_beliefs           1.195  0.23371    
## Community_Space_Content                  1.374  0.17144    
## youth_activity_rcBasic Skills Activity   3.339  0.00104 ** 
## youth_activity_rcCreating Product        1.952  0.05231 .  
## youth_activity_rcField Trip Speaker      0.162  0.87178    
## youth_activity_rcLab Activity            1.610  0.11001    
## youth_activity_rcProgram Staff Led       0.981  0.32796    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f ovr___ Cm_S_C y__BSA yt__CP y__FTS yt__LA
## gender_feml -0.228                                                 
## ovrll_pr_c_ -0.922 -0.030                                          
## Cmmnty_Sp_C -0.041  0.016  0.008                                   
## yth_ctv_BSA -0.070 -0.010 -0.028 -0.257                            
## yth_ctvt_CP -0.082  0.008 -0.025  0.049  0.362                     
## yth_ctv_FTS -0.008  0.010 -0.046 -0.406  0.333  0.189              
## yth_ctvt_LA -0.017 -0.016 -0.034 -0.228  0.263  0.190  0.226       
## yth_ctv_PSL -0.089 -0.024  0.002 -0.044  0.413  0.309  0.194  0.199

Predicting learning with gender interactions

learning_model_female <- lmer(learning ~ 
                                  gender_female + 
                                  overall_pre_competence_beliefs +
                                  Community_Space_Content +
                                  youth_activity_rc + 
                                  gender_female*youth_activity_rc +
                                  (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                              data = df)

summary(learning_model_female)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: 
## learning ~ gender_female + overall_pre_competence_beliefs + Community_Space_Content +  
##     youth_activity_rc + gender_female * youth_activity_rc + (1 |  
##     program_ID) + (1 | participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 6610.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.1461 -0.5641  0.1169  0.5737  2.8443 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.009958 0.09979 
##  participant_ID (Intercept) 0.402090 0.63411 
##  program_ID     (Intercept) 0.000000 0.00000 
##  Residual                   0.711799 0.84368 
## Number of obs: 2473, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                        Estimate Std. Error
## (Intercept)                                           2.530e+00  2.054e-01
## gender_female                                        -1.784e-01  1.152e-01
## overall_pre_competence_beliefs                        7.694e-02  6.129e-02
## Community_Space_Content                               7.430e-02  5.901e-02
## youth_activity_rcBasic Skills Activity                7.178e-02  7.652e-02
## youth_activity_rcCreating Product                     3.822e-02  7.738e-02
## youth_activity_rcField Trip Speaker                  -3.035e-02  1.292e-01
## youth_activity_rcLab Activity                         1.724e-01  1.495e-01
## youth_activity_rcProgram Staff Led                   -2.973e-02  9.182e-02
## gender_female:youth_activity_rcBasic Skills Activity  2.154e-01  9.991e-02
## gender_female:youth_activity_rcCreating Product       1.260e-01  1.038e-01
## gender_female:youth_activity_rcField Trip Speaker     9.710e-02  1.783e-01
## gender_female:youth_activity_rcLab Activity          -4.078e-03  1.849e-01
## gender_female:youth_activity_rcProgram Staff Led      1.664e-01  1.169e-01
##                                                              df t value
## (Intercept)                                           1.892e+02  12.315
## gender_female                                         2.799e+02  -1.548
## overall_pre_competence_beliefs                        1.824e+02   1.255
## Community_Space_Content                               1.607e+02   1.259
## youth_activity_rcBasic Skills Activity                5.005e+02   0.938
## youth_activity_rcCreating Product                     6.342e+02   0.494
## youth_activity_rcField Trip Speaker                   2.072e+02  -0.235
## youth_activity_rcLab Activity                         4.326e+02   1.153
## youth_activity_rcProgram Staff Led                    6.057e+02  -0.324
## gender_female:youth_activity_rcBasic Skills Activity  2.354e+03   2.156
## gender_female:youth_activity_rcCreating Product       2.295e+03   1.214
## gender_female:youth_activity_rcField Trip Speaker     2.337e+03   0.545
## gender_female:youth_activity_rcLab Activity           2.043e+03  -0.022
## gender_female:youth_activity_rcProgram Staff Led      2.364e+03   1.423
##                                                      Pr(>|t|)    
## (Intercept)                                            <2e-16 ***
## gender_female                                          0.1227    
## overall_pre_competence_beliefs                         0.2110    
## Community_Space_Content                                0.2099    
## youth_activity_rcBasic Skills Activity                 0.3487    
## youth_activity_rcCreating Product                      0.6215    
## youth_activity_rcField Trip Speaker                    0.8145    
## youth_activity_rcLab Activity                          0.2496    
## youth_activity_rcProgram Staff Led                     0.7462    
## gender_female:youth_activity_rcBasic Skills Activity   0.0312 *  
## gender_female:youth_activity_rcCreating Product        0.2248    
## gender_female:youth_activity_rcField Trip Speaker      0.5860    
## gender_female:youth_activity_rcLab Activity            0.9824    
## gender_female:youth_activity_rcProgram Staff Led       0.1547    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Predicting learning with competence interactions

learning_model_competence <- lmer(learning ~ 
                                      gender_female + 
                                      overall_pre_competence_beliefs +
                                      Community_Space_Content +
                                      youth_activity_rc + 
                                      overall_pre_competence_beliefs*youth_activity_rc +
                                      (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                                  data = df)

summary(learning_model_competence)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: 
## learning ~ gender_female + overall_pre_competence_beliefs + Community_Space_Content +  
##     youth_activity_rc + overall_pre_competence_beliefs * youth_activity_rc +  
##     (1 | program_ID) + (1 | participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 6617.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.1585 -0.5640  0.1210  0.5813  2.7626 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.01195  0.1093  
##  participant_ID (Intercept) 0.39893  0.6316  
##  program_ID     (Intercept) 0.00000  0.0000  
##  Residual                   0.71129  0.8434  
## Number of obs: 2473, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                                         Estimate
## (Intercept)                                                            2.490e+00
## gender_female                                                         -7.711e-02
## overall_pre_competence_beliefs                                         7.206e-02
## Community_Space_Content                                                8.873e-02
## youth_activity_rcBasic Skills Activity                                 2.541e-01
## youth_activity_rcCreating Product                                      7.938e-02
## youth_activity_rcField Trip Speaker                                   -3.983e-01
## youth_activity_rcLab Activity                                          6.318e-01
## youth_activity_rcProgram Staff Led                                    -1.318e-02
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity -2.233e-02
## overall_pre_competence_beliefs:youth_activity_rcCreating Product       9.215e-03
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker     1.199e-01
## overall_pre_competence_beliefs:youth_activity_rcLab Activity          -1.400e-01
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led      2.470e-02
##                                                                       Std. Error
## (Intercept)                                                            2.226e-01
## gender_female                                                          1.023e-01
## overall_pre_competence_beliefs                                         6.815e-02
## Community_Space_Content                                                6.026e-02
## youth_activity_rcBasic Skills Activity                                 2.026e-01
## youth_activity_rcCreating Product                                      2.057e-01
## youth_activity_rcField Trip Speaker                                    4.017e-01
## youth_activity_rcLab Activity                                          4.371e-01
## youth_activity_rcProgram Staff Led                                     2.308e-01
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity  6.209e-02
## overall_pre_competence_beliefs:youth_activity_rcCreating Product       6.313e-02
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker     1.159e-01
## overall_pre_competence_beliefs:youth_activity_rcLab Activity           1.288e-01
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led      7.271e-02
##                                                                               df
## (Intercept)                                                            2.619e+02
## gender_female                                                          1.779e+02
## overall_pre_competence_beliefs                                         2.790e+02
## Community_Space_Content                                                1.674e+02
## youth_activity_rcBasic Skills Activity                                 1.501e+03
## youth_activity_rcCreating Product                                      2.023e+03
## youth_activity_rcField Trip Speaker                                    8.477e+02
## youth_activity_rcLab Activity                                          1.425e+03
## youth_activity_rcProgram Staff Led                                     1.567e+03
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity  2.032e+03
## overall_pre_competence_beliefs:youth_activity_rcCreating Product       2.289e+03
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker     1.235e+03
## overall_pre_competence_beliefs:youth_activity_rcLab Activity           1.551e+03
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led      1.945e+03
##                                                                       t value
## (Intercept)                                                            11.185
## gender_female                                                          -0.754
## overall_pre_competence_beliefs                                          1.057
## Community_Space_Content                                                 1.472
## youth_activity_rcBasic Skills Activity                                  1.254
## youth_activity_rcCreating Product                                       0.386
## youth_activity_rcField Trip Speaker                                    -0.992
## youth_activity_rcLab Activity                                           1.445
## youth_activity_rcProgram Staff Led                                     -0.057
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity  -0.360
## overall_pre_competence_beliefs:youth_activity_rcCreating Product        0.146
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker      1.035
## overall_pre_competence_beliefs:youth_activity_rcLab Activity           -1.087
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led       0.340
##                                                                       Pr(>|t|)
## (Intercept)                                                             <2e-16
## gender_female                                                            0.452
## overall_pre_competence_beliefs                                           0.291
## Community_Space_Content                                                  0.143
## youth_activity_rcBasic Skills Activity                                   0.210
## youth_activity_rcCreating Product                                        0.700
## youth_activity_rcField Trip Speaker                                      0.322
## youth_activity_rcLab Activity                                            0.149
## youth_activity_rcProgram Staff Led                                       0.954
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity    0.719
## overall_pre_competence_beliefs:youth_activity_rcCreating Product         0.884
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker       0.301
## overall_pre_competence_beliefs:youth_activity_rcLab Activity             0.277
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led        0.734
##                                                                          
## (Intercept)                                                           ***
## gender_female                                                            
## overall_pre_competence_beliefs                                           
## Community_Space_Content                                                  
## youth_activity_rcBasic Skills Activity                                   
## youth_activity_rcCreating Product                                        
## youth_activity_rcField Trip Speaker                                      
## youth_activity_rcLab Activity                                            
## youth_activity_rcProgram Staff Led                                       
## overall_pre_competence_beliefs:youth_activity_rcBasic Skills Activity    
## overall_pre_competence_beliefs:youth_activity_rcCreating Product         
## overall_pre_competence_beliefs:youth_activity_rcField Trip Speaker       
## overall_pre_competence_beliefs:youth_activity_rcLab Activity             
## overall_pre_competence_beliefs:youth_activity_rcProgram Staff Led        
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

March 22 Analysis - Final Models and descriptives

Correlations

Correlation Function

#correlation table function
corstarsl <- function(x) { 
    require(Hmisc) 
    x <- as.matrix(x) 
    R <- rcorr(x)$r 
    p <- rcorr(x)$P 
    
    ## define notions for significance levels; spacing is important.
    mystars <- ifelse(p < .001, "***", ifelse(p < .01, "** ", ifelse(p < .05, "*  ", "   ")))
    
    ## trunctuate the matrix that holds the correlations to two decimal
    R <- format(round(cbind(rep(-1.11, ncol(x)), R), 2))[,-1] 
    
    ## build a new matrix that includes the correlations with their apropriate stars 
    Rnew <- matrix(paste(R, mystars, sep=""), ncol=ncol(x)) 
    diag(Rnew) <- paste(diag(R), " ", sep="") 
    rownames(Rnew) <- colnames(x) 
    colnames(Rnew) <- paste(colnames(x), "", sep="") 
    
    ## remove upper triangle
    Rnew <- as.matrix(Rnew)
    Rnew[upper.tri(Rnew, diag = TRUE)] <- ""
    Rnew <- as.data.frame(Rnew) 
    
    ## remove last column and return the matrix (which is now a data frame)
    Rnew <- cbind(Rnew[1:length(Rnew)-1])
    return(Rnew) 
}

Correlations

Stemie_Corr <- select(df, overall_engagement, challenge, relevance, learning, overall_pre_competence_beliefs)
corstarsl(Stemie_Corr)
## Warning: package 'Hmisc' was built under R version 3.4.3
##                                overall_engagement challenge relevance
## overall_engagement                                                   
## challenge                                 0.32***                    
## relevance                                 0.68***   0.39***          
## learning                                  0.69***   0.30***   0.65***
## overall_pre_competence_beliefs            0.08***  -0.12***   0.03   
##                                learning
## overall_engagement                     
## challenge                              
## relevance                              
## learning                               
## overall_pre_competence_beliefs  0.09***

Descriptives

psych::describe(df$overall_engagement)
##    vars    n mean   sd median trimmed  mad min max range  skew kurtosis
## X1    1 2970 2.87 0.87      3    2.94 1.11   1   4     3 -0.42    -0.65
##      se
## X1 0.02
psych::describe(df$challenge)
##    vars    n mean   sd median trimmed  mad min max range skew kurtosis
## X1    1 2970 2.27 1.12      2    2.21 1.48   1   4     3 0.27    -1.31
##      se
## X1 0.02
psych::describe(df$relevance)
##    vars    n mean   sd median trimmed  mad min max range  skew kurtosis
## X1    1 2970 2.58 0.96   2.67     2.6 0.99   1   4     3 -0.09    -1.02
##      se
## X1 0.02
psych::describe(df$learning)
##    vars    n mean   sd median trimmed  mad min max range  skew kurtosis
## X1    1 2969 2.77 1.06      3    2.84 1.48   1   4     3 -0.35    -1.12
##      se
## X1 0.02
psych::describe(df$overall_pre_competence_beliefs)
##    vars    n mean   sd median trimmed  mad min max range  skew kurtosis
## X1    1 2730 3.13 0.81   3.33    3.23 0.99   1   4     3 -0.85     0.04
##      se
## X1 0.02

Group mean centering

library(dplyr)
df <- df %>%
    group_by(participant_ID) %>%
    mutate(challenge_group = challenge - mean(challenge),
           relevance_group = relevance - mean(relevance),
           learning_group = learning - mean(learning))

Predicting engagement with gender interactions

engagement_model_gender_final <- lmer(overall_engagement ~ 
                                          gender_female +
                                          challenge_group + 
                                          relevance_group + 
                                          learning_group + 
                                          scale(overall_pre_competence_beliefs, scale=FALSE) +
                                          Community_Space_Content +
                                          gender_female*challenge_group +
                                          gender_female*relevance_group +
                                          gender_female*learning_group + 
                                          (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                                      data = df)

summary(engagement_model_gender_final)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: 
## overall_engagement ~ gender_female + challenge_group + relevance_group +  
##     learning_group + scale(overall_pre_competence_beliefs, scale = FALSE) +  
##     Community_Space_Content + gender_female * challenge_group +  
##     gender_female * relevance_group + gender_female * learning_group +  
##     (1 | program_ID) + (1 | participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 4114
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.8978 -0.5366  0.0339  0.5229  3.9133 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.017166 0.1310  
##  participant_ID (Intercept) 0.347724 0.5897  
##  program_ID     (Intercept) 0.008427 0.0918  
##  Residual                   0.220988 0.4701  
## Number of obs: 2555, groups:  
## beep_ID_new, 237; participant_ID, 179; program_ID, 9
## 
## Fixed effects:
##                                                        Estimate Std. Error
## (Intercept)                                             2.90276    0.07356
## gender_female                                          -0.08075    0.09223
## challenge_group                                         0.05978    0.01656
## relevance_group                                         0.39133    0.02528
## learning_group                                          0.27142    0.02028
## scale(overall_pre_competence_beliefs, scale = FALSE)    0.08389    0.05623
## Community_Space_Content                                -0.06722    0.03655
## gender_female:challenge_group                          -0.04551    0.02360
## gender_female:relevance_group                          -0.08697    0.03443
## gender_female:learning_group                            0.01622    0.02661
##                                                              df t value
## (Intercept)                                            19.00000  39.462
## gender_female                                         175.40000  -0.876
## challenge_group                                      2354.20000   3.611
## relevance_group                                      2338.50000  15.481
## learning_group                                       2338.60000  13.386
## scale(overall_pre_competence_beliefs, scale = FALSE)  126.60000   1.492
## Community_Space_Content                               216.10000  -1.839
## gender_female:challenge_group                        2339.70000  -1.928
## gender_female:relevance_group                        2334.60000  -2.526
## gender_female:learning_group                         2336.40000   0.610
##                                                      Pr(>|t|)    
## (Intercept)                                           < 2e-16 ***
## gender_female                                        0.382468    
## challenge_group                                      0.000311 ***
## relevance_group                                       < 2e-16 ***
## learning_group                                        < 2e-16 ***
## scale(overall_pre_competence_beliefs, scale = FALSE) 0.138185    
## Community_Space_Content                              0.067296 .  
## gender_female:challenge_group                        0.053929 .  
## gender_female:relevance_group                        0.011597 *  
## gender_female:learning_group                         0.542219    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f chlln_ rlvnc_ lrnng_ s(_s=F Cm_S_C gndr_fml:c_
## gender_feml -0.641                                                      
## challng_grp -0.005  0.002                                               
## relevnc_grp  0.001  0.000 -0.085                                        
## learnng_grp  0.000  0.001 -0.102 -0.462                                 
## s(___,s=FAL  0.037 -0.028  0.000 -0.002  0.001                          
## Cmmnty_Sp_C -0.110  0.007  0.012 -0.009 -0.012 -0.010                   
## gndr_fml:c_  0.007 -0.005 -0.689  0.059  0.075  0.002 -0.035            
## gndr_fml:r_  0.003  0.000  0.060 -0.730  0.339  0.000 -0.028 -0.110     
## gndr_fml:l_  0.001 -0.003  0.084  0.348 -0.760  0.000  0.006 -0.102     
##             gndr_fml:r_
## gender_feml            
## challng_grp            
## relevnc_grp            
## learnng_grp            
## s(___,s=FAL            
## Cmmnty_Sp_C            
## gndr_fml:c_            
## gndr_fml:r_            
## gndr_fml:l_ -0.450
rand(engagement_model_gender_final)
## Analysis of Random effects Table:
##                  Chi.sq Chi.DF p.value    
## program_ID        0.511      1     0.5    
## participant_ID 1715.421      1  <2e-16 ***
## beep_ID_new      52.301      1   5e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Rengagement<-r2glmm::r2beta(engagement_model_gender_final, method = "nsj")
Rengagement
##                                                  Effect   Rsq upper.CL
## 1                                                 Model 0.212    0.241
## 4                                       relevance_group 0.035    0.051
## 5                                        learning_group 0.027    0.040
## 6  scale(overall_pre_competence_beliefs, scale = FALSE) 0.008    0.016
## 2                                         gender_female 0.003    0.008
## 3                                       challenge_group 0.002    0.007
## 7                               Community_Space_Content 0.001    0.005
## 9                         gender_female:relevance_group 0.001    0.005
## 8                         gender_female:challenge_group 0.001    0.004
## 10                         gender_female:learning_group 0.000    0.002
##    lower.CL
## 1     0.187
## 4     0.023
## 5     0.016
## 6     0.002
## 2     0.000
## 3     0.000
## 7     0.000
## 9     0.000
## 8     0.000
## 10    0.000
sjPlot::sjp.int(engagement_model_gender_final, type = "eff")

Predicting challenge with activities

challenge_model_final <- lmer(challenge ~ 
                                  gender_female + 
                                  scale(overall_pre_competence_beliefs, scale=FALSE) +
                                  Community_Space_Content +
                                  youth_activity_rc + 
                                  (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                              data = df)

summary(challenge_model_final)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: 
## challenge ~ gender_female + scale(overall_pre_competence_beliefs,  
##     scale = FALSE) + Community_Space_Content + youth_activity_rc +  
##     (1 | program_ID) + (1 | participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 6561.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8804 -0.6343 -0.0339  0.5665  3.3306 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.06010  0.2452  
##  participant_ID (Intercept) 0.46579  0.6825  
##  program_ID     (Intercept) 0.01458  0.1207  
##  Residual                   0.65855  0.8115  
## Number of obs: 2474, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                       Estimate Std. Error
## (Intercept)                                            2.32619    0.09745
## gender_female                                         -0.24095    0.11062
## scale(overall_pre_competence_beliefs, scale = FALSE)  -0.12249    0.06811
## Community_Space_Content                                0.20156    0.07608
## youth_activity_rcBasic Skills Activity                 0.03632    0.07055
## youth_activity_rcCreating Product                      0.32834    0.06898
## youth_activity_rcField Trip Speaker                   -0.27165    0.14565
## youth_activity_rcLab Activity                          0.07836    0.13397
## youth_activity_rcProgram Staff Led                    -0.14343    0.07986
##                                                             df t value
## (Intercept)                                           22.19000  23.871
## gender_female                                        174.27000  -2.178
## scale(overall_pre_competence_beliefs, scale = FALSE) 133.55000  -1.798
## Community_Space_Content                              184.93000   2.649
## youth_activity_rcBasic Skills Activity               194.87000   0.515
## youth_activity_rcCreating Product                    210.82000   4.760
## youth_activity_rcField Trip Speaker                  133.87000  -1.865
## youth_activity_rcLab Activity                        152.93000   0.585
## youth_activity_rcProgram Staff Led                   180.60000  -1.796
##                                                      Pr(>|t|)    
## (Intercept)                                           < 2e-16 ***
## gender_female                                         0.03075 *  
## scale(overall_pre_competence_beliefs, scale = FALSE)  0.07439 .  
## Community_Space_Content                               0.00877 ** 
## youth_activity_rcBasic Skills Activity                0.60730    
## youth_activity_rcCreating Product                     3.6e-06 ***
## youth_activity_rcField Trip Speaker                   0.06436 .  
## youth_activity_rcLab Activity                         0.55948    
## youth_activity_rcProgram Staff Led                    0.07418 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f s(_s=F Cm_S_C y__BSA yt__CP y__FTS yt__LA
## gender_feml -0.583                                                 
## s(___,s=FAL  0.044 -0.036                                          
## Cmmnty_Sp_C -0.078  0.011  0.009                                   
## yth_ctv_BSA -0.257 -0.008 -0.023 -0.272                            
## yth_ctvt_CP -0.280  0.008 -0.016  0.033  0.375                     
## yth_ctv_FTS -0.127  0.008 -0.033 -0.391  0.320  0.189              
## yth_ctvt_LA -0.128 -0.011 -0.022 -0.220  0.255  0.188  0.205       
## yth_ctv_PSL -0.235 -0.020  0.004 -0.054  0.410  0.311  0.187  0.194
rand(challenge_model_final)
## Analysis of Random effects Table:
##                 Chi.sq Chi.DF p.value    
## program_ID       0.572      1     0.4    
## participant_ID 810.059      1  <2e-16 ***
## beep_ID_new     50.220      1   1e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Rchallenge<-r2glmm::r2beta(challenge_model_final, method = "nsj")
Rchallenge
##                                                 Effect   Rsq upper.CL
## 1                                                Model 0.043    0.063
## 2                                        gender_female 0.012    0.022
## 6                    youth_activity_rcCreating Product 0.011    0.020
## 3 scale(overall_pre_competence_beliefs, scale = FALSE) 0.008    0.016
## 4                              Community_Space_Content 0.004    0.011
## 7                  youth_activity_rcField Trip Speaker 0.002    0.008
## 9                   youth_activity_rcProgram Staff Led 0.002    0.007
## 8                        youth_activity_rcLab Activity 0.000    0.003
## 5               youth_activity_rcBasic Skills Activity 0.000    0.003
##   lower.CL
## 1    0.031
## 2    0.005
## 6    0.004
## 3    0.002
## 4    0.001
## 7    0.000
## 9    0.000
## 8    0.000
## 5    0.000

Predicting relevance with activities

relevance_model_final <- lmer(relevance ~ 
                                  gender_female + 
                                  scale(overall_pre_competence_beliefs, scale=FALSE) +
                                  Community_Space_Content +
                                  youth_activity_rc + 
                                  (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                              data = df)

summary(relevance_model_final)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: 
## relevance ~ gender_female + scale(overall_pre_competence_beliefs,  
##     scale = FALSE) + Community_Space_Content + youth_activity_rc +  
##     (1 | program_ID) + (1 | participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 5375.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8799 -0.5198  0.0240  0.5733  4.0732 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.008112 0.09006 
##  participant_ID (Intercept) 0.478767 0.69193 
##  program_ID     (Intercept) 0.010293 0.10145 
##  Residual                   0.410223 0.64049 
## Number of obs: 2474, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                       Estimate Std. Error
## (Intercept)                                            2.59451    0.08803
## gender_female                                         -0.24514    0.10890
## scale(overall_pre_competence_beliefs, scale = FALSE)   0.05636    0.06641
## Community_Space_Content                                0.14332    0.04670
## youth_activity_rcBasic Skills Activity                 0.09519    0.04348
## youth_activity_rcCreating Product                      0.20051    0.04315
## youth_activity_rcField Trip Speaker                    0.15841    0.08455
## youth_activity_rcLab Activity                          0.04009    0.07951
## youth_activity_rcProgram Staff Led                     0.11707    0.04878
##                                                             df t value
## (Intercept)                                           22.97000  29.474
## gender_female                                        176.89000  -2.251
## scale(overall_pre_competence_beliefs, scale = FALSE) 124.14000   0.849
## Community_Space_Content                              181.27000   3.069
## youth_activity_rcBasic Skills Activity               189.58000   2.189
## youth_activity_rcCreating Product                    230.25000   4.647
## youth_activity_rcField Trip Speaker                  115.88000   1.874
## youth_activity_rcLab Activity                        140.29000   0.504
## youth_activity_rcProgram Staff Led                   180.82000   2.400
##                                                      Pr(>|t|)    
## (Intercept)                                           < 2e-16 ***
## gender_female                                         0.02561 *  
## scale(overall_pre_competence_beliefs, scale = FALSE)  0.39769    
## Community_Space_Content                               0.00248 ** 
## youth_activity_rcBasic Skills Activity                0.02980 *  
## youth_activity_rcCreating Product                    5.67e-06 ***
## youth_activity_rcField Trip Speaker                   0.06351 .  
## youth_activity_rcLab Activity                         0.61492    
## youth_activity_rcProgram Staff Led                    0.01741 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f s(_s=F Cm_S_C y__BSA yt__CP y__FTS yt__LA
## gender_feml -0.634                                                 
## s(___,s=FAL  0.040 -0.030                                          
## Cmmnty_Sp_C -0.060  0.011  0.006                                   
## yth_ctv_BSA -0.172 -0.006 -0.017 -0.267                            
## yth_ctvt_CP -0.188  0.005 -0.014  0.049  0.361                     
## yth_ctv_FTS -0.088  0.003 -0.025 -0.406  0.337  0.189              
## yth_ctvt_LA -0.088 -0.009 -0.018 -0.226  0.262  0.188  0.225       
## yth_ctv_PSL -0.157 -0.015  0.002 -0.052  0.419  0.306  0.196  0.200
rand(relevance_model_final)
## Analysis of Random effects Table:
##                  Chi.sq Chi.DF p.value    
## program_ID        0.448      1    0.50    
## participant_ID 1359.529      1  <2e-16 ***
## beep_ID_new       4.263      1    0.04 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Rrelevance<-r2glmm::r2beta(relevance_model_final, method = "nsj")
Rrelevance
##                                                 Effect   Rsq upper.CL
## 1                                                Model 0.029    0.046
## 2                                        gender_female 0.016    0.027
## 6                    youth_activity_rcCreating Product 0.005    0.013
## 4                              Community_Space_Content 0.003    0.008
## 3 scale(overall_pre_competence_beliefs, scale = FALSE) 0.002    0.007
## 9                   youth_activity_rcProgram Staff Led 0.002    0.006
## 5               youth_activity_rcBasic Skills Activity 0.001    0.006
## 7                  youth_activity_rcField Trip Speaker 0.001    0.005
## 8                        youth_activity_rcLab Activity 0.000    0.002
##   lower.CL
## 1    0.020
## 2    0.008
## 6    0.001
## 4    0.000
## 3    0.000
## 9    0.000
## 5    0.000
## 7    0.000
## 8    0.000

Predicting learning with activities

learning_model_final <- lmer(learning ~ 
                                 gender_female + 
                                 scale(overall_pre_competence_beliefs, scale=FALSE) +
                                 Community_Space_Content +
                                 youth_activity_rc + 
                                 (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                             data = df)

summary(learning_model_final)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: learning ~ gender_female + scale(overall_pre_competence_beliefs,  
##     scale = FALSE) + Community_Space_Content + youth_activity_rc +  
##     (1 | program_ID) + (1 | participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 6604.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.1852 -0.5625  0.1224  0.5818  2.7914 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.01084  0.1041  
##  participant_ID (Intercept) 0.39930  0.6319  
##  program_ID     (Intercept) 0.00000  0.0000  
##  Residual                   0.71153  0.8435  
## Number of obs: 2473, groups:  
## beep_ID_new, 228; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                       Estimate Std. Error
## (Intercept)                                            2.71559    0.07885
## gender_female                                         -0.07685    0.10225
## scale(overall_pre_competence_beliefs, scale = FALSE)   0.07299    0.06109
## Community_Space_Content                                0.08146    0.05930
## youth_activity_rcBasic Skills Activity                 0.18533    0.05551
## youth_activity_rcCreating Product                      0.10821    0.05544
## youth_activity_rcField Trip Speaker                    0.01733    0.10710
## youth_activity_rcLab Activity                          0.16330    0.10143
## youth_activity_rcProgram Staff Led                     0.06118    0.06235
##                                                             df t value
## (Intercept)                                          228.02000  34.439
## gender_female                                        177.61000  -0.752
## scale(overall_pre_competence_beliefs, scale = FALSE) 182.55000   1.195
## Community_Space_Content                              160.88000   1.374
## youth_activity_rcBasic Skills Activity               167.20000   3.339
## youth_activity_rcCreating Product                    203.74000   1.952
## youth_activity_rcField Trip Speaker                  100.16000   0.162
## youth_activity_rcLab Activity                        121.53000   1.610
## youth_activity_rcProgram Staff Led                   159.90000   0.981
##                                                      Pr(>|t|)    
## (Intercept)                                           < 2e-16 ***
## gender_female                                         0.45327    
## scale(overall_pre_competence_beliefs, scale = FALSE)  0.23371    
## Community_Space_Content                               0.17144    
## youth_activity_rcBasic Skills Activity                0.00104 ** 
## youth_activity_rcCreating Product                     0.05231 .  
## youth_activity_rcField Trip Speaker                   0.87178    
## youth_activity_rcLab Activity                         0.11001    
## youth_activity_rcProgram Staff Led                    0.32796    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f s(_s=F Cm_S_C y__BSA yt__CP y__FTS yt__LA
## gender_feml -0.662                                                 
## s(___,s=FAL  0.042 -0.030                                          
## Cmmnty_Sp_C -0.085  0.016  0.008                                   
## yth_ctv_BSA -0.249 -0.010 -0.028 -0.257                            
## yth_ctvt_CP -0.271  0.008 -0.025  0.049  0.362                     
## yth_ctv_FTS -0.133  0.010 -0.046 -0.406  0.333  0.189              
## yth_ctvt_LA -0.126 -0.016 -0.034 -0.228  0.263  0.190  0.226       
## yth_ctv_PSL -0.225 -0.024  0.002 -0.044  0.413  0.309  0.194  0.199
rand(learning_model_final)
## Analysis of Random effects Table:
##                Chi.sq Chi.DF p.value    
## program_ID       0.00      1     1.0    
## participant_ID 681.42      1  <2e-16 ***
## beep_ID_new      2.27      1     0.1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Rlearning<-r2glmm::r2beta(learning_model_final, method = "nsj")
Rlearning
##                                                 Effect   Rsq upper.CL
## 1                                                Model 0.011    0.024
## 5               youth_activity_rcBasic Skills Activity 0.004    0.010
## 3 scale(overall_pre_competence_beliefs, scale = FALSE) 0.003    0.009
## 2                                        gender_female 0.001    0.006
## 6                    youth_activity_rcCreating Product 0.001    0.006
## 8                        youth_activity_rcLab Activity 0.001    0.005
## 4                              Community_Space_Content 0.001    0.004
## 9                   youth_activity_rcProgram Staff Led 0.000    0.003
## 7                  youth_activity_rcField Trip Speaker 0.000    0.002
##   lower.CL
## 1    0.007
## 5    0.001
## 3    0.000
## 2    0.000
## 6    0.000
## 8    0.000
## 4    0.000
## 9    0.000
## 7    0.000

Reliability for engagement

#engagement_reliability <- select(df, hard_working, concentrating, enjoy, interest)
#cronbach(engagement_reliability)

Reliability for relevance

#relevance_reliability <- select(df, use_outside, future_goals, important)
#cronbach(relevance_reliability)

Manova of challenge, relevance, and learning by activity. Post hocs included.

fit<-manova(cbind(df$challenge, df$relevance, df$learning) ~ df$youth_activity_rc, data = df)
summary(fit, test="Pillai")
##                        Df   Pillai approx F num Df den Df   Pr(>F)    
## df$youth_activity_rc    5 0.030931   5.8568     15   8433 2.94e-12 ***
## Residuals            2811                                             
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary.aov(fit)
##  Response 1 :
##                        Df Sum Sq Mean Sq F value    Pr(>F)    
## df$youth_activity_rc    5   65.2 13.0424  10.648 3.747e-10 ***
## Residuals            2811 3443.0  1.2248                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Response 2 :
##                        Df  Sum Sq Mean Sq F value    Pr(>F)    
## df$youth_activity_rc    5   23.12  4.6233  5.0325 0.0001354 ***
## Residuals            2811 2582.44  0.9187                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Response 3 :
##                        Df Sum Sq Mean Sq F value   Pr(>F)   
## df$youth_activity_rc    5   17.3  3.4600   3.077 0.008963 **
## Residuals            2811 3160.9  1.1245                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 153 observations deleted due to missingness
TukeyHSD(aov(df$challenge ~ df$youth_activity_rc))
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = df$challenge ~ df$youth_activity_rc)
## 
## $`df$youth_activity_rc`
##                                                 diff        lwr
## Basic Skills Activity-Other               0.02110436 -0.1415982
## Creating Product-Other                    0.31258581  0.1443279
## Field Trip Speaker-Other                 -0.19033816 -0.4812618
## Lab Activity-Other                        0.04214047 -0.2536218
## Program Staff Led-Other                  -0.13619106 -0.3211765
## Creating Product-Basic Skills Activity    0.29148145  0.1094862
## Field Trip Speaker-Basic Skills Activity -0.21144253 -0.5105214
## Lab Activity-Basic Skills Activity        0.02103611 -0.2827514
## Program Staff Led-Basic Skills Activity  -0.15729542 -0.3548585
## Field Trip Speaker-Creating Product      -0.50292398 -0.8050610
## Lab Activity-Creating Product            -0.27044534 -0.5772441
## Program Staff Led-Creating Product       -0.44877687 -0.6509396
## Lab Activity-Field Trip Speaker           0.23247863 -0.1554019
## Program Staff Led-Field Trip Speaker      0.05414710 -0.2576150
## Program Staff Led-Lab Activity           -0.17833153 -0.4946136
##                                                  upr     p adj
## Basic Skills Activity-Other               0.18380690 0.9991000
## Creating Product-Other                    0.48084370 0.0000019
## Field Trip Speaker-Other                  0.10058552 0.4236949
## Lab Activity-Other                        0.33790269 0.9985829
## Program Staff Led-Other                   0.04879434 0.2877274
## Creating Product-Basic Skills Activity    0.47347674 0.0000755
## Field Trip Speaker-Basic Skills Activity  0.08763632 0.3332668
## Lab Activity-Basic Skills Activity        0.32482363 0.9999588
## Program Staff Led-Basic Skills Activity   0.04026765 0.2065564
## Field Trip Speaker-Creating Product      -0.20078699 0.0000320
## Lab Activity-Creating Product             0.03635339 0.1203417
## Program Staff Led-Creating Product       -0.24661415 0.0000000
## Lab Activity-Field Trip Speaker           0.62035920 0.5257331
## Program Staff Led-Field Trip Speaker      0.36590926 0.9963503
## Program Staff Led-Lab Activity            0.13795054 0.5933632
pairwise.t.test(df$challenge, df$youth_activity_rc, p.adj = "bonf")
## 
##  Pairwise comparisons using t tests with pooled SD 
## 
## data:  df$challenge and df$youth_activity_rc 
## 
##                       Other   Basic Skills Activity Creating Product
## Basic Skills Activity 1.00    -                     -               
## Creating Product      1.9e-06 7.7e-05               -               
## Field Trip Speaker    0.93    0.66                  3.3e-05         
## Lab Activity          1.00    1.00                  0.18            
## Program Staff Led     0.54    0.35                  4.3e-09         
##                       Field Trip Speaker Lab Activity
## Basic Skills Activity -                  -           
## Creating Product      -                  -           
## Field Trip Speaker    -                  -           
## Lab Activity          1.00               -           
## Program Staff Led     1.00               1.00        
## 
## P value adjustment method: bonferroni
TukeyHSD(aov(df$relevance ~ df$youth_activity_rc))
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = df$relevance ~ df$youth_activity_rc)
## 
## $`df$youth_activity_rc`
##                                                 diff         lwr
## Basic Skills Activity-Other               0.06784634 -0.07301535
## Creating Product-Other                    0.24106280  0.09539150
## Field Trip Speaker-Other                  0.12686527 -0.12500543
## Lab Activity-Other                       -0.03885173 -0.29491145
## Program Staff Led-Other                   0.10193917 -0.05821418
## Creating Product-Basic Skills Activity    0.17321647  0.01565185
## Field Trip Speaker-Basic Skills Activity  0.05901894 -0.19991219
## Lab Activity-Basic Skills Activity       -0.10669806 -0.36970579
## Program Staff Led-Basic Skills Activity   0.03409284 -0.13694978
## Field Trip Speaker-Creating Product      -0.11419753 -0.37577628
## Lab Activity-Creating Product            -0.27991453 -0.54552924
## Program Staff Led-Creating Product       -0.13912363 -0.31414846
## Lab Activity-Field Trip Speaker          -0.16571700 -0.50152929
## Program Staff Led-Field Trip Speaker     -0.02492610 -0.29483795
## Program Staff Led-Lab Activity            0.14079090 -0.13303412
##                                                  upr     p adj
## Basic Skills Activity-Other               0.20870802 0.7430174
## Creating Product-Other                    0.38673411 0.0000366
## Field Trip Speaker-Other                  0.37873597 0.7047328
## Lab Activity-Other                        0.21720800 0.9980828
## Program Staff Led-Other                   0.26209252 0.4560414
## Creating Product-Basic Skills Activity    0.33078109 0.0214667
## Field Trip Speaker-Basic Skills Activity  0.31795006 0.9870965
## Lab Activity-Basic Skills Activity        0.15630966 0.8571654
## Program Staff Led-Basic Skills Activity   0.20513545 0.9930359
## Field Trip Speaker-Creating Product       0.14738122 0.8145751
## Lab Activity-Creating Product            -0.01429982 0.0320020
## Program Staff Led-Creating Product        0.03590120 0.2081337
## Lab Activity-Field Trip Speaker           0.17009529 0.7226974
## Program Staff Led-Field Trip Speaker      0.24498576 0.9998291
## Program Staff Led-Lab Activity            0.41461592 0.6859489
pairwise.t.test(df$relevance, df$youth_activity_rc, p.adj = "bonf")
## 
##  Pairwise comparisons using t tests with pooled SD 
## 
## data:  df$relevance and df$youth_activity_rc 
## 
##                       Other   Basic Skills Activity Creating Product
## Basic Skills Activity 1.000   -                     -               
## Creating Product      3.7e-05 0.026                 -               
## Field Trip Speaker    1.000   1.000                 1.000           
## Lab Activity          1.000   1.000                 0.040           
## Program Staff Led     1.000   1.000                 0.352           
##                       Field Trip Speaker Lab Activity
## Basic Skills Activity -                  -           
## Creating Product      -                  -           
## Field Trip Speaker    -                  -           
## Lab Activity          1.000              -           
## Program Staff Led     1.000              1.000       
## 
## P value adjustment method: bonferroni
TukeyHSD(aov(df$learning ~ df$youth_activity_rc))
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = df$learning ~ df$youth_activity_rc)
## 
## $`df$youth_activity_rc`
##                                                  diff         lwr
## Basic Skills Activity-Other               0.169703433  0.01383560
## Creating Product-Other                    0.171775426  0.01049817
## Field Trip Speaker-Other                 -0.026610306 -0.30531306
## Lab Activity-Other                        0.121822742 -0.16151530
## Program Staff Led-Other                   0.081736069 -0.09547859
## Creating Product-Basic Skills Activity    0.002071993 -0.17235899
## Field Trip Speaker-Basic Skills Activity -0.196313739 -0.48282907
## Lab Activity-Basic Skills Activity       -0.047880691 -0.33890691
## Program Staff Led-Basic Skills Activity  -0.087967365 -0.27723133
## Field Trip Speaker-Creating Product      -0.198385732 -0.48787944
## Lab Activity-Creating Product            -0.049952684 -0.34391158
## Program Staff Led-Creating Product       -0.090039357 -0.28378254
## Lab Activity-Field Trip Speaker           0.148433048 -0.22315368
## Program Staff Led-Field Trip Speaker      0.108346375 -0.19031948
## Program Staff Led-Lab Activity           -0.040086674 -0.34308257
##                                                 upr     p adj
## Basic Skills Activity-Other              0.32557127 0.0235955
## Creating Product-Other                   0.33305268 0.0290459
## Field Trip Speaker-Other                 0.25209244 0.9997986
## Lab Activity-Other                       0.40516078 0.8241730
## Program Staff Led-Other                  0.25895073 0.7766871
## Creating Product-Basic Skills Activity   0.17650298 1.0000000
## Field Trip Speaker-Basic Skills Activity 0.09020160 0.3694812
## Lab Activity-Basic Skills Activity       0.24314553 0.9971775
## Program Staff Led-Basic Skills Activity  0.10129660 0.7709579
## Field Trip Speaker-Creating Product      0.09110798 0.3692974
## Lab Activity-Creating Product            0.24400621 0.9967088
## Program Staff Led-Creating Product       0.10370383 0.7710404
## Lab Activity-Field Trip Speaker          0.52001978 0.8650428
## Program Staff Led-Field Trip Speaker     0.40701223 0.9063684
## Program Staff Led-Lab Activity           0.26290922 0.9990095
pairwise.t.test(df$learning, df$youth_activity_rc, p.adj = "bonf")
## 
##  Pairwise comparisons using t tests with pooled SD 
## 
## data:  df$learning and df$youth_activity_rc 
## 
##                       Other Basic Skills Activity Creating Product
## Basic Skills Activity 0.029 -                     -               
## Creating Product      0.036 1.000                 -               
## Field Trip Speaker    1.000 0.762                 0.762           
## Lab Activity          1.000 1.000                 1.000           
## Program Staff Led     1.000 1.000                 1.000           
##                       Field Trip Speaker Lab Activity
## Basic Skills Activity -                  -           
## Creating Product      -                  -           
## Field Trip Speaker    -                  -           
## Lab Activity          1.000              -           
## Program Staff Led     1.000              1.000       
## 
## P value adjustment method: bonferroni

March 30 Analysis - No Class Content Variable

Predicting engagement with gender interactions

engagement_model_gender_final_2 <- lmer(overall_engagement ~ 
                                            gender_female +
                                            challenge_group + 
                                            relevance_group + 
                                            learning_group + 
                                            scale(overall_pre_competence_beliefs, scale=FALSE) +
                                            gender_female*challenge_group +
                                            gender_female*relevance_group +
                                            gender_female*learning_group + 
                                            (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                                        data = df)

summary(engagement_model_gender_final_2)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: 
## overall_engagement ~ gender_female + challenge_group + relevance_group +  
##     learning_group + scale(overall_pre_competence_beliefs, scale = FALSE) +  
##     gender_female * challenge_group + gender_female * relevance_group +  
##     gender_female * learning_group + (1 | program_ID) + (1 |  
##     participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 4330.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9057 -0.5411  0.0379  0.5222  4.0440 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.017397 0.13190 
##  participant_ID (Intercept) 0.348175 0.59006 
##  program_ID     (Intercept) 0.005726 0.07567 
##  Residual                   0.220266 0.46932 
## Number of obs: 2710, groups:  
## beep_ID_new, 248; participant_ID, 179; program_ID, 9
## 
## Fixed effects:
##                                                        Estimate Std. Error
## (Intercept)                                             2.88661    0.07070
## gender_female                                          -0.07706    0.09169
## challenge_group                                         0.06575    0.01595
## relevance_group                                         0.39061    0.02391
## learning_group                                          0.27450    0.01950
## scale(overall_pre_competence_beliefs, scale = FALSE)    0.07917    0.05558
## gender_female:challenge_group                          -0.04597    0.02275
## gender_female:relevance_group                          -0.08155    0.03296
## gender_female:learning_group                            0.01058    0.02559
##                                                              df t value
## (Intercept)                                            19.80000  40.828
## gender_female                                         175.30000  -0.840
## challenge_group                                      2507.40000   4.122
## relevance_group                                      2496.60000  16.338
## learning_group                                       2487.20000  14.079
## scale(overall_pre_competence_beliefs, scale = FALSE)  118.90000   1.424
## gender_female:challenge_group                        2486.10000  -2.021
## gender_female:relevance_group                        2490.20000  -2.474
## gender_female:learning_group                         2481.50000   0.413
##                                                      Pr(>|t|)    
## (Intercept)                                           < 2e-16 ***
## gender_female                                          0.4018    
## challenge_group                                      3.88e-05 ***
## relevance_group                                       < 2e-16 ***
## learning_group                                        < 2e-16 ***
## scale(overall_pre_competence_beliefs, scale = FALSE)   0.1570    
## gender_female:challenge_group                          0.0434 *  
## gender_female:relevance_group                          0.0134 *  
## gender_female:learning_group                           0.6793    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f chlln_ rlvnc_ lrnng_ s(_s=F gndr_fml:c_
## gender_feml -0.663                                               
## challng_grp -0.001  0.000                                        
## relevnc_grp  0.000  0.000 -0.091                                 
## learnng_grp  0.000 -0.001 -0.113 -0.460                          
## s(___,s=FAL  0.035 -0.026  0.001  0.000  0.000                   
## gndr_fml:c_  0.000  0.000 -0.687  0.064  0.083  0.000            
## gndr_fml:r_  0.000  0.000  0.064 -0.722  0.332  0.000 -0.120     
## gndr_fml:l_  0.000  0.000  0.092  0.347 -0.760  0.000 -0.111     
##             gndr_fml:r_
## gender_feml            
## challng_grp            
## relevnc_grp            
## learnng_grp            
## s(___,s=FAL            
## gndr_fml:c_            
## gndr_fml:r_            
## gndr_fml:l_ -0.443
rand(engagement_model_gender_final_2)
## Analysis of Random effects Table:
##                  Chi.sq Chi.DF p.value    
## program_ID        0.268      1     0.6    
## participant_ID 1850.109      1  <2e-16 ***
## beep_ID_new      56.392      1   6e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Rengagement_2<-r2glmm::r2beta(engagement_model_gender_final_2, method = "nsj")
Rengagement_2
##                                                 Effect   Rsq upper.CL
## 1                                                Model 0.217    0.245
## 4                                      relevance_group 0.037    0.052
## 5                                       learning_group 0.028    0.041
## 6 scale(overall_pre_competence_beliefs, scale = FALSE) 0.007    0.014
## 2                                        gender_female 0.002    0.008
## 3                                      challenge_group 0.002    0.008
## 8                        gender_female:relevance_group 0.001    0.005
## 7                        gender_female:challenge_group 0.001    0.004
## 9                         gender_female:learning_group 0.000    0.002
##   lower.CL
## 1    0.193
## 4    0.025
## 5    0.017
## 6    0.002
## 2    0.000
## 3    0.000
## 8    0.000
## 7    0.000
## 9    0.000
x<-sjPlot::sjp.int(engagement_model_gender_final_2, type = "eff")

x[[1]][[1]] + 
    xlab("Challenge") +
    ylab("Engagement") + 
    ggtitle("Interaction Between Gender and Challenge on Engagement") +
    scale_color_discrete(name="",
        labels=c("Male", "Female"))

x[[1]][[2]] + 
    xlab("Relevance") +
    ylab("Engagement") + 
    ggtitle("Interaction Between Gender and Relevance on Engagement") +
    scale_color_discrete(name="",
        labels=c("Male", "Female"))

Predicting challenge with activities

challenge_model_final_2 <- lmer(challenge ~ 
                                    gender_female + 
                                    scale(overall_pre_competence_beliefs, scale=FALSE) +
                                    youth_activity_rc + 
                                    (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                                data = df)

summary(challenge_model_final_2)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: 
## challenge ~ gender_female + scale(overall_pre_competence_beliefs,  
##     scale = FALSE) + youth_activity_rc + (1 | program_ID) + (1 |  
##     participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 6807.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9164 -0.6406 -0.0343  0.5573  3.4151 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.05880  0.2425  
##  participant_ID (Intercept) 0.47418  0.6886  
##  program_ID     (Intercept) 0.02675  0.1635  
##  Residual                   0.65529  0.8095  
## Number of obs: 2575, groups:  
## beep_ID_new, 235; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                       Estimate Std. Error
## (Intercept)                                            2.34167    0.10399
## gender_female                                         -0.24392    0.11162
## scale(overall_pre_competence_beliefs, scale = FALSE)  -0.12057    0.06949
## youth_activity_rcBasic Skills Activity                 0.08786    0.06622
## youth_activity_rcCreating Product                      0.33751    0.06716
## youth_activity_rcField Trip Speaker                   -0.10755    0.13215
## youth_activity_rcLab Activity                          0.16549    0.12924
## youth_activity_rcProgram Staff Led                    -0.13468    0.07716
##                                                             df t value
## (Intercept)                                           19.50000  22.519
## gender_female                                        174.07000  -2.185
## scale(overall_pre_competence_beliefs, scale = FALSE) 153.12000  -1.735
## youth_activity_rcBasic Skills Activity               203.20000   1.327
## youth_activity_rcCreating Product                    214.46000   5.026
## youth_activity_rcField Trip Speaker                  131.48000  -0.814
## youth_activity_rcLab Activity                        156.00000   1.280
## youth_activity_rcProgram Staff Led                   182.64000  -1.745
##                                                      Pr(>|t|)    
## (Intercept)                                          2.00e-15 ***
## gender_female                                          0.0302 *  
## scale(overall_pre_competence_beliefs, scale = FALSE)   0.0847 .  
## youth_activity_rcBasic Skills Activity                 0.1861    
## youth_activity_rcCreating Product                    1.06e-06 ***
## youth_activity_rcField Trip Speaker                    0.4172    
## youth_activity_rcLab Activity                          0.2023    
## youth_activity_rcProgram Staff Led                     0.0826 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f s(_s=F y__BSA yt__CP y__FTS yt__LA
## gender_feml -0.554                                          
## s(___,s=FAL  0.043 -0.038                                   
## yth_ctv_BSA -0.258 -0.003 -0.019                            
## yth_ctvt_CP -0.249  0.009 -0.014  0.389                     
## yth_ctv_FTS -0.146  0.009 -0.025  0.230  0.213              
## yth_ctvt_LA -0.131 -0.005 -0.016  0.197  0.191  0.127       
## yth_ctv_PSL -0.218 -0.013  0.004  0.405  0.309  0.181  0.177
rand(challenge_model_final_2)
## Analysis of Random effects Table:
##                Chi.sq Chi.DF p.value    
## program_ID       1.69      1     0.2    
## participant_ID 865.08      1  <2e-16 ***
## beep_ID_new     51.29      1   8e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Rchallenge_2<-r2glmm::r2beta(challenge_model_final_2, method = "nsj")
Rchallenge_2
##                                                 Effect   Rsq upper.CL
## 1                                                Model 0.039    0.057
## 2                                        gender_female 0.012    0.022
## 5                    youth_activity_rcCreating Product 0.011    0.021
## 3 scale(overall_pre_competence_beliefs, scale = FALSE) 0.008    0.016
## 8                   youth_activity_rcProgram Staff Led 0.002    0.006
## 7                        youth_activity_rcLab Activity 0.001    0.005
## 4               youth_activity_rcBasic Skills Activity 0.001    0.005
## 6                  youth_activity_rcField Trip Speaker 0.000    0.003
##   lower.CL
## 1    0.028
## 2    0.005
## 5    0.005
## 3    0.002
## 8    0.000
## 7    0.000
## 4    0.000
## 6    0.000

Predicting relevance with activities

relevance_model_final_2 <- lmer(relevance ~ 
                                    gender_female + 
                                    scale(overall_pre_competence_beliefs, scale=FALSE) +
                                    youth_activity_rc + 
                                    (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                                data = df)

summary(relevance_model_final_2)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: 
## relevance ~ gender_female + scale(overall_pre_competence_beliefs,  
##     scale = FALSE) + youth_activity_rc + (1 | program_ID) + (1 |  
##     participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 5584.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9174 -0.5193  0.0221  0.5771  4.0731 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.008748 0.09353 
##  participant_ID (Intercept) 0.480982 0.69353 
##  program_ID     (Intercept) 0.013358 0.11558 
##  Residual                   0.410634 0.64081 
## Number of obs: 2575, groups:  
## beep_ID_new, 235; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                       Estimate Std. Error
## (Intercept)                                            2.61442    0.08988
## gender_female                                         -0.25061    0.10908
## scale(overall_pre_competence_beliefs, scale = FALSE)   0.05558    0.06686
## youth_activity_rcBasic Skills Activity                 0.13273    0.04141
## youth_activity_rcCreating Product                      0.19636    0.04242
## youth_activity_rcField Trip Speaker                    0.26210    0.07719
## youth_activity_rcLab Activity                          0.09932    0.07770
## youth_activity_rcProgram Staff Led                     0.14665    0.04758
##                                                             df t value
## (Intercept)                                           21.72000  29.087
## gender_female                                        176.36000  -2.297
## scale(overall_pre_competence_beliefs, scale = FALSE) 131.84000   0.831
## youth_activity_rcBasic Skills Activity               203.27000   3.206
## youth_activity_rcCreating Product                    230.10000   4.630
## youth_activity_rcField Trip Speaker                  113.42000   3.395
## youth_activity_rcLab Activity                        143.86000   1.278
## youth_activity_rcProgram Staff Led                   181.13000   3.082
##                                                      Pr(>|t|)    
## (Intercept)                                           < 2e-16 ***
## gender_female                                        0.022767 *  
## scale(overall_pre_competence_beliefs, scale = FALSE) 0.407330    
## youth_activity_rcBasic Skills Activity               0.001566 ** 
## youth_activity_rcCreating Product                    6.13e-06 ***
## youth_activity_rcField Trip Speaker                  0.000945 ***
## youth_activity_rcLab Activity                        0.203201    
## youth_activity_rcProgram Staff Led                   0.002378 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f s(_s=F y__BSA yt__CP y__FTS yt__LA
## gender_feml -0.624                                          
## s(___,s=FAL  0.040 -0.031                                   
## yth_ctv_BSA -0.184 -0.002 -0.015                            
## yth_ctvt_CP -0.177  0.006 -0.013  0.379                     
## yth_ctv_FTS -0.111  0.007 -0.023  0.246  0.223              
## yth_ctvt_LA -0.097 -0.004 -0.016  0.203  0.195  0.143       
## yth_ctv_PSL -0.155 -0.011  0.002  0.414  0.306  0.193  0.184
rand(relevance_model_final_2)
## Analysis of Random effects Table:
##                 Chi.sq Chi.DF p.value    
## program_ID        0.71      1    0.40    
## participant_ID 1411.39      1  <2e-16 ***
## beep_ID_new       5.09      1    0.02 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Rrelevance_2<-r2glmm::r2beta(relevance_model_final_2, method = "nsj")
Rrelevance_2
##                                                 Effect   Rsq upper.CL
## 1                                                Model 0.027    0.043
## 2                                        gender_female 0.017    0.028
## 5                    youth_activity_rcCreating Product 0.005    0.012
## 6                  youth_activity_rcField Trip Speaker 0.003    0.009
## 4               youth_activity_rcBasic Skills Activity 0.003    0.008
## 8                   youth_activity_rcProgram Staff Led 0.002    0.008
## 3 scale(overall_pre_competence_beliefs, scale = FALSE) 0.002    0.007
## 7                        youth_activity_rcLab Activity 0.000    0.004
##   lower.CL
## 1    0.018
## 2    0.008
## 5    0.001
## 6    0.000
## 4    0.000
## 8    0.000
## 3    0.000
## 7    0.000

Predicting learning with activities

learning_model_final_2 <- lmer(learning ~ 
                                   gender_female + 
                                   scale(overall_pre_competence_beliefs, scale=FALSE) +
                                   youth_activity_rc + 
                                   (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                               data = df)

summary(learning_model_final_2)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: learning ~ gender_female + scale(overall_pre_competence_beliefs,  
##     scale = FALSE) + youth_activity_rc + (1 | program_ID) + (1 |  
##     participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 6851.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2150 -0.5656  0.1266  0.5831  2.7867 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev. 
##  beep_ID_new    (Intercept) 9.800e-03 9.899e-02
##  participant_ID (Intercept) 4.012e-01 6.334e-01
##  program_ID     (Intercept) 3.547e-13 5.955e-07
##  Residual                   7.089e-01 8.420e-01
## Number of obs: 2574, groups:  
## beep_ID_new, 235; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                       Estimate Std. Error
## (Intercept)                                            2.72558    0.07801
## gender_female                                         -0.07634    0.10199
## scale(overall_pre_competence_beliefs, scale = FALSE)   0.07506    0.06097
## youth_activity_rcBasic Skills Activity                 0.21054    0.05215
## youth_activity_rcCreating Product                      0.11284    0.05363
## youth_activity_rcField Trip Speaker                    0.07216    0.09576
## youth_activity_rcLab Activity                          0.19405    0.09719
## youth_activity_rcProgram Staff Led                     0.06627    0.05978
##                                                             df t value
## (Intercept)                                          221.07000  34.937
## gender_female                                        176.50000  -0.748
## scale(overall_pre_competence_beliefs, scale = FALSE) 181.46000   1.231
## youth_activity_rcBasic Skills Activity               180.48000   4.037
## youth_activity_rcCreating Product                    206.00000   2.104
## youth_activity_rcField Trip Speaker                   97.63000   0.754
## youth_activity_rcLab Activity                        125.18000   1.997
## youth_activity_rcProgram Staff Led                   160.93000   1.109
##                                                      Pr(>|t|)    
## (Intercept)                                           < 2e-16 ***
## gender_female                                          0.4552    
## scale(overall_pre_competence_beliefs, scale = FALSE)   0.2199    
## youth_activity_rcBasic Skills Activity               7.98e-05 ***
## youth_activity_rcCreating Product                      0.0366 *  
## youth_activity_rcField Trip Speaker                    0.4529    
## youth_activity_rcLab Activity                          0.0480 *  
## youth_activity_rcProgram Staff Led                     0.2693    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f s(_s=F y__BSA yt__CP y__FTS yt__LA
## gender_feml -0.669                                          
## s(___,s=FAL  0.042 -0.030                                   
## yth_ctv_BSA -0.268 -0.005 -0.027                            
## yth_ctvt_CP -0.259  0.011 -0.025  0.378                     
## yth_ctv_FTS -0.172  0.017 -0.047  0.246  0.223              
## yth_ctvt_LA -0.141 -0.010 -0.032  0.206  0.197  0.144       
## yth_ctv_PSL -0.224 -0.018  0.003  0.410  0.309  0.194  0.185
rand(learning_model_final_2)
## Analysis of Random effects Table:
##                  Chi.sq Chi.DF p.value    
## program_ID     2.73e-12      1     1.0    
## participant_ID 7.19e+02      1  <2e-16 ***
## beep_ID_new    1.99e+00      1     0.2    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Rlearning_2<-r2glmm::r2beta(learning_model_final_2, method = "nsj")
Rlearning_2
##                                                 Effect   Rsq upper.CL
## 1                                                Model 0.011    0.023
## 4               youth_activity_rcBasic Skills Activity 0.005    0.012
## 3 scale(overall_pre_competence_beliefs, scale = FALSE) 0.003    0.009
## 5                    youth_activity_rcCreating Product 0.001    0.006
## 7                        youth_activity_rcLab Activity 0.001    0.006
## 2                                        gender_female 0.001    0.006
## 8                   youth_activity_rcProgram Staff Led 0.000    0.003
## 6                  youth_activity_rcField Trip Speaker 0.000    0.003
##   lower.CL
## 1    0.006
## 4    0.001
## 3    0.000
## 5    0.000
## 7    0.000
## 2    0.000
## 8    0.000
## 6    0.000

Predicting engagement with activities

engagement_model_final_21 <- lmer(overall_engagement ~ 
                                   gender_female + 
                                   scale(overall_pre_competence_beliefs, scale=FALSE) +
                                   youth_activity_rc + 
                                   (1|program_ID) + (1|participant_ID) + (1|beep_ID_new),
                               data = df)

summary(engagement_model_final_21)
## Linear mixed model fit by REML t-tests use Satterthwaite approximations
##   to degrees of freedom [lmerMod]
## Formula: 
## overall_engagement ~ gender_female + scale(overall_pre_competence_beliefs,  
##     scale = FALSE) + youth_activity_rc + (1 | program_ID) + (1 |  
##     participant_ID) + (1 | beep_ID_new)
##    Data: df
## 
## REML criterion at convergence: 5399.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.1618 -0.5064  0.0642  0.5746  3.7718 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  beep_ID_new    (Intercept) 0.02451  0.1566  
##  participant_ID (Intercept) 0.33229  0.5764  
##  program_ID     (Intercept) 0.01135  0.1066  
##  Residual                   0.37894  0.6156  
## Number of obs: 2575, groups:  
## beep_ID_new, 235; participant_ID, 180; program_ID, 9
## 
## Fixed effects:
##                                                        Estimate Std. Error
## (Intercept)                                            2.839440   0.079411
## gender_female                                         -0.073587   0.092054
## scale(overall_pre_competence_beliefs, scale = FALSE)   0.087106   0.056715
## youth_activity_rcBasic Skills Activity                 0.076927   0.046851
## youth_activity_rcCreating Product                      0.137974   0.047626
## youth_activity_rcField Trip Speaker                    0.133098   0.091759
## youth_activity_rcLab Activity                          0.120945   0.090443
## youth_activity_rcProgram Staff Led                     0.008682   0.054364
##                                                              df t value
## (Intercept)                                           21.130000  35.756
## gender_female                                        177.580000  -0.799
## scale(overall_pre_competence_beliefs, scale = FALSE) 138.070000   1.536
## youth_activity_rcBasic Skills Activity               218.860000   1.642
## youth_activity_rcCreating Product                    235.010000   2.897
## youth_activity_rcField Trip Speaker                  136.310000   1.451
## youth_activity_rcLab Activity                        164.440000   1.337
## youth_activity_rcProgram Staff Led                   196.230000   0.160
##                                                      Pr(>|t|)    
## (Intercept)                                           < 2e-16 ***
## gender_female                                         0.42514    
## scale(overall_pre_competence_beliefs, scale = FALSE)  0.12686    
## youth_activity_rcBasic Skills Activity                0.10203    
## youth_activity_rcCreating Product                     0.00412 ** 
## youth_activity_rcField Trip Speaker                   0.14921    
## youth_activity_rcLab Activity                         0.18299    
## youth_activity_rcProgram Staff Led                    0.87328    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) gndr_f s(_s=F y__BSA yt__CP y__FTS yt__LA
## gender_feml -0.597                                          
## s(___,s=FAL  0.043 -0.034                                   
## yth_ctv_BSA -0.238 -0.003 -0.019                            
## yth_ctvt_CP -0.230  0.008 -0.015  0.386                     
## yth_ctv_FTS -0.139  0.009 -0.027  0.234  0.216              
## yth_ctvt_LA -0.122 -0.005 -0.017  0.199  0.192  0.131       
## yth_ctv_PSL -0.200 -0.013  0.004  0.408  0.308  0.184  0.179
rand(engagement_model_final_21)
## Analysis of Random effects Table:
##                  Chi.sq Chi.DF p.value    
## program_ID        0.824      1     0.4    
## participant_ID 1080.598      1  <2e-16 ***
## beep_ID_new      35.740      1   2e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Rengagement_21<-r2glmm::r2beta(engagement_model_final_21, method = "nsj")
Rengagement_21
##                                                 Effect   Rsq upper.CL
## 1                                                Model 0.014    0.027
## 3 scale(overall_pre_competence_beliefs, scale = FALSE) 0.006    0.014
## 5                    youth_activity_rcCreating Product 0.003    0.009
## 2                                        gender_female 0.002    0.007
## 4               youth_activity_rcBasic Skills Activity 0.001    0.005
## 6                  youth_activity_rcField Trip Speaker 0.001    0.005
## 7                        youth_activity_rcLab Activity 0.001    0.004
## 8                   youth_activity_rcProgram Staff Led 0.000    0.002
##   lower.CL
## 1    0.008
## 3    0.002
## 5    0.000
## 2    0.000
## 4    0.000
## 6    0.000
## 7    0.000
## 8    0.000
vars_by_activity<-df%>%
    group_by(youth_activity_rc) %>%
    summarise_at(vars(challenge, relevance, learning), funs (mean(., na.rm=TRUE)))
vars_by_activity
## # A tibble: 7 x 4
##   youth_activity_rc     challenge relevance learning
##   <fct>                     <dbl>     <dbl>    <dbl>
## 1 Other                      2.23      2.50     2.69
## 2 Basic Skills Activity      2.26      2.57     2.86
## 3 Creating Product           2.55      2.74     2.86
## 4 Field Trip Speaker         2.04      2.62     2.66
## 5 Lab Activity               2.28      2.46     2.81
## 6 Program Staff Led          2.10      2.60     2.77
## 7 <NA>                       2.18      2.59     2.63
# d <- df %>%
#     ungroup() %>% 
#     select(youth_activity_rc, challenge) %>% 
#     group_by(youth_activity_rc) %>% 
#     summarize(mean_challenge = mean(challenge, na.rm = T)) %>% 
#     filter(!is.na(youth_activity_rc)) %>% 
#     ggplot(aes(x = youth_activity_rc, y = mean_challenge)) +
#     geom_col()

df %>% 
    ungroup() %>% 
    select(youth_activity_rc, challenge, relevance, learning) %>% 
    gather(key, val, -youth_activity_rc) %>% 
    filter(!is.na(youth_activity_rc)) %>% 
    ggplot(aes(x = reorder(youth_activity_rc, val), y = val, fill=youth_activity_rc)) +
    scale_fill_hue(l=40) +
    theme(legend.position = "none") +
    stat_summary(fun.y = mean, geom = "bar") + 
    stat_summary(fun.data = mean_se, geom="errorbar") +
    facet_wrap("key") +
    theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
    xlab("Youth Activity") +
    ylab("Mean") + 
    ggtitle("Means of Outcomes by Youth Activity")
## Warning: Removed 1 rows containing non-finite values (stat_summary).

## Warning: Removed 1 rows containing non-finite values (stat_summary).

#vars_by_activity<-df%>%
    #group_by(youth_activity_rc) %>%
    #summarise_at(vars(challenge, relevance, learning), funs (mean(., na.rm=TRUE)))

# vars_by_activity %>%
# gather(key, val, -youth_activity_rc) %>%
# filter(!is.na(youth_activity_rc)) %>%
# ggplot(ggplot2::aes(x=youth_activity_rc, y=val, fill=key)) +
# geom_col(position="dodge")