File: /Volumes/BL-PSY-gunderson_lab/Main/Studies/2024_manynumbers_pilot_firsthalf/scripts/mn_ef.Rmd

Databases

Heart and Flowers

Figure

Analyses

model_hf <- glmer(accuracy ~ Block* (enter_age)
                               + (1|participant_id),
              data = hf_dataframe, family = binomial, 
              control = glmerControl(optimizer = "bobyqa"))
#summary(model_hf)
tab_model(model_hf)
  accuracy
Predictors Odds Ratios CI p
(Intercept) 6.04 6.02 – 6.06 <0.001
Block [2] 0.00 0.00 – 0.00 <0.001
enter age 1.22 1.21 – 1.22 <0.001
Block [2] × enter age 4.18 4.16 – 4.19 <0.001
Random Effects
σ2 3.29
τ00 participant_id 1.32
ICC 0.29
N participant_id 19
Observations 456
Marginal R2 / Conditional R2 0.203 / 0.431
Anova(model_hf, type = 3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
## 
## Response: accuracy
##                    Chisq Df            Pr(>Chisq)    
## (Intercept)       983128  1 < 0.00000000000000022 ***
## Block           16100146  1 < 0.00000000000000022 ***
## enter_age          11870  1 < 0.00000000000000022 ***
## Block:enter_age   622615  1 < 0.00000000000000022 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
means_model_hf = emmeans(model_hf, pairwise ~ Block|enter_age, mult.name = "Block", at = list(enter_age= c(3,4,5)))
summary(means_model_hf, infer=c(TRUE,TRUE), null=0, type = "response", adjust = "none")
## $emmeans
## enter_age = 3:
##  Block   prob        SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  1     0.9162 0.0004410 Inf    0.9153    0.9171  0.5 416.394  <.0001
##  2     0.3564 0.0018614 Inf    0.3528    0.3601  0.5 -72.817  <.0001
## 
## enter_age = 4:
##  Block   prob        SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  1     0.9302 0.0004863 Inf    0.9292    0.9311  0.5 345.769  <.0001
##  2     0.7383 0.0020443 Inf    0.7343    0.7423  0.5  98.023  <.0001
## 
## enter_age = 5:
##  Block   prob        SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  1     0.9420 0.0005061 Inf    0.9410    0.9430  0.5 300.952  <.0001
##  2     0.9349 0.0007960 Inf    0.9334    0.9365  0.5 203.682  <.0001
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the logit scale 
## Tests are performed on the logit scale 
## 
## $contrasts
## enter_age = 3:
##  contrast        odds.ratio     SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  Block1 / Block2      19.74 0.1131 Inf     19.52     19.96    1 520.438  <.0001
## 
## enter_age = 4:
##  contrast        odds.ratio     SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  Block1 / Block2       4.72 0.0353 Inf      4.65      4.79    1 207.775  <.0001
## 
## enter_age = 5:
##  contrast        odds.ratio     SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  Block1 / Block2       1.13 0.0104 Inf      1.11      1.15    1  13.256  <.0001
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log odds ratio scale 
## Tests are performed on the log odds ratio scale

DCCS

MN032 was removed because they failed the pre-switch (shape) condition (accuracy < .80)

Figure

## , ,  = 3
## 
##         
##          color shape
##   failed     1     1
##   passed     3     3
## 
## , ,  = 4
## 
##         
##          color shape
##   failed     2     0
##   passed     4     6
## 
## , ,  = 5
## 
##         
##          color shape
##   failed     2     0
##   passed     7     9

Analyses

#dccs_dataframe$age_factor = as.factor(as.numeric(dccs_dataframe$enter_age))
dccs_dataframe= subset(dccs_dataframe, participant!="mn032")
model_dccs <- glmer(accuracy ~ condition 
                                * enter_age
                               + (1|participant),
              data = dccs_dataframe, family = binomial, 
              control=glmerControl(optimizer="bobyqa",optCtrl=list(maxfun=2e5)))
#summary(model_dccs)
tab_model(model_dccs)
  accuracy
Predictors Odds Ratios CI p
(Intercept) 0.45 0.45 – 0.45 <0.001
condition [shape] 6.41 1.35 – 30.50 0.020
enter age 2.48 2.47 – 2.49 <0.001
condition [shape] × enter
age
1.96 1.96 – 1.97 <0.001
Random Effects
σ2 3.29
τ00 participant 11.59
ICC 0.78
N participant 18
Observations 358
Marginal R2 / Conditional R2 0.308 / 0.847
Anova(model_dccs, type = 3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
## 
## Response: accuracy
##                           Chisq Df           Pr(>Chisq)    
## (Intercept)         341816.1065  1 < 0.0000000000000002 ***
## condition                5.4555  1              0.01951 *  
## enter_age           450620.1429  1 < 0.0000000000000002 ***
## condition:enter_age 249002.5868  1 < 0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
means_model_dccs = emmeans(model_dccs, pairwise ~ condition|enter_age, mult.name = "condition", at = list(enter_age= c(3,4,5)))
summary(means_model_dccs, infer=c(TRUE,TRUE), null=0, type = "response", adjust = "none")
## $emmeans
## enter_age = 3:
##  condition    prob          SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  color     0.87373 0.000472109 Inf   0.87280   0.87465  0.5 452.037  <.0001
##  shape     0.99703 0.002353719 Inf   0.98604   0.99937  0.5   7.312  <.0001
## 
## enter_age = 4:
##  condition    prob          SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  color     0.94494 0.000290288 Inf   0.94437   0.94551  0.5 509.502  <.0001
##  shape     0.99939 0.000485538 Inf   0.99710   0.99987  0.5   9.302  <.0001
## 
## enter_age = 5:
##  condition    prob          SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  color     0.97705 0.000154745 Inf   0.97674   0.97735  0.5 543.634  <.0001
##  shape     0.99987 0.000099785 Inf   0.99940   0.99997  0.5  11.291  <.0001
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the logit scale 
## Tests are performed on the logit scale 
## 
## $contrasts
## enter_age = 3:
##  contrast      odds.ratio      SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  color / shape    0.02059 0.01638 Inf   0.00433    0.0979    1  -4.881  <.0001
## 
## enter_age = 4:
##  contrast      odds.ratio      SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  color / shape    0.01049 0.00834 Inf   0.00221    0.0499    1  -5.729  <.0001
## 
## enter_age = 5:
##  contrast      odds.ratio      SE  df asymp.LCL asymp.UCL null z.ratio p.value
##  color / shape    0.00534 0.00425 Inf   0.00112    0.0254    1  -6.577  <.0001
## 
## Confidence level used: 0.95 
## Intervals are back-transformed from the log odds ratio scale 
## Tests are performed on the log odds ratio scale
#plot(ggpredict(model_dccs,  terms=c("enter_age","condition")))

Given-N Task

given_data2 = given_hc_dataframe
given_data2 = given_data2[,c(57,24:47)]
na_strings <- c("21", "22")

given_data3 = given_data2 %>%
  replace_with_na_all(condition = ~.x %in% na_strings)

given_data3_gather = gather(given_data3, "trial", "response", -participant)
given_data3_gather = given_data3_gather %>%
  left_join(given_trials, by = "trial")

given_data3_gather$accuracy = ifelse(given_data3_gather$number == given_data3_gather$response, 1,0)

given_data3_gather$subject_id = given_data3_gather$participant
given_data3_gather$demographics_pid = given_data3_gather$participant
given_data3_gather$Query = given_data3_gather$number
given_data3_gather$Response = given_data3_gather$response
given_data3_gather_overall = aggregate(accuracy ~  participant, given_data3_gather, mean)

Correlations

##                    hf_congruent hf_incongruent Pre-Switch\nShape
## hf_congruent               1.00           0.26              0.04
## hf_incongruent             0.26           1.00              0.06
## Pre-Switch\nShape          0.04           0.06              1.00
## Post-Switch\nColor         0.08           0.34             -0.01
## demographics_age           0.20           0.73              0.04
## highestcount_score         0.07           0.37              0.23
## given_accuracy             0.34           0.56              0.24
##                    Post-Switch\nColor demographics_age highestcount_score
## hf_congruent                     0.08             0.20               0.07
## hf_incongruent                   0.34             0.73               0.37
## Pre-Switch\nShape               -0.01             0.04               0.23
## Post-Switch\nColor               1.00             0.27               0.31
## demographics_age                 0.27             1.00               0.77
## highestcount_score               0.31             0.77               1.00
## given_accuracy                   0.37             0.79               0.70
##                    given_accuracy
## hf_congruent                 0.34
## hf_incongruent               0.56
## Pre-Switch\nShape            0.24
## Post-Switch\nColor           0.37
## demographics_age             0.79
## highestcount_score           0.70
## given_accuracy               1.00
## 
## n
##                    hf_congruent hf_incongruent Pre-Switch\nShape
## hf_congruent                 19             19                18
## hf_incongruent               19             19                18
## Pre-Switch\nShape            18             18                18
## Post-Switch\nColor           18             18                18
## demographics_age             19             19                18
## highestcount_score           19             19                18
## given_accuracy               19             19                18
##                    Post-Switch\nColor demographics_age highestcount_score
## hf_congruent                       18               19                 19
## hf_incongruent                     18               19                 19
## Pre-Switch\nShape                  18               18                 18
## Post-Switch\nColor                 18               18                 18
## demographics_age                   18               19                 19
## highestcount_score                 18               19                 19
## given_accuracy                     18               19                 19
##                    given_accuracy
## hf_congruent                   19
## hf_incongruent                 19
## Pre-Switch\nShape              18
## Post-Switch\nColor             18
## demographics_age               19
## highestcount_score             19
## given_accuracy                 19
## 
## P
##                    hf_congruent hf_incongruent Pre-Switch\nShape
## hf_congruent                    0.2750         0.8867           
## hf_incongruent     0.2750                      0.8211           
## Pre-Switch\nShape  0.8867       0.8211                          
## Post-Switch\nColor 0.7432       0.1691         0.9651           
## demographics_age   0.4121       0.0004         0.8658           
## highestcount_score 0.7863       0.1141         0.3571           
## given_accuracy     0.1520       0.0132         0.3339           
##                    Post-Switch\nColor demographics_age highestcount_score
## hf_congruent       0.7432             0.4121           0.7863            
## hf_incongruent     0.1691             0.0004           0.1141            
## Pre-Switch\nShape  0.9651             0.8658           0.3571            
## Post-Switch\nColor                    0.2764           0.2039            
## demographics_age   0.2764                              0.0001            
## highestcount_score 0.2039             0.0001                             
## given_accuracy     0.1359             0.0000           0.0008            
##                    given_accuracy
## hf_congruent       0.1520        
## hf_incongruent     0.0132        
## Pre-Switch\nShape  0.3339        
## Post-Switch\nColor 0.1359        
## demographics_age   0.0000        
## highestcount_score 0.0008        
## given_accuracy