Description

library(afex) ## to run anova
## Loading required package: lme4
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## ************
## Welcome to afex. For support visit: http://afex.singmann.science/
## - Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
## - Methods for calculating p-values with mixed(): 'S', 'KR', 'LRT', and 'PB'
## - 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
## - NEWS: emmeans() for ANOVA models now uses model = 'multivariate' as default.
## - Get and set global package options with: afex_options()
## - Set orthogonal sum-to-zero contrasts globally: set_sum_contrasts()
## - For example analyses see: browseVignettes("afex")
## ************
## 
## Attaching package: 'afex'
## The following object is masked from 'package:lme4':
## 
##     lmer
library(ggstatsplot)

#73 subs collected thru pavlovia
summary.all %>% ungroup() %>% summarise(n_distinct(participant))
## # A tibble: 1 × 1
##   `n_distinct(participant)`
##                       <int>
## 1                        73
grouped_ggwithinstats(
  data            = session3.pretty.filtered.facescene %>% 
  mutate(across(pairType, recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")),
  subject.id = participant,
  x               = hierarchy,
  y               = meanPerf,
  type            = "parametric",
  xlab            = "Condition",
  grouping.var    = pairType,
  outlier.label = NULL,
  bf.message = FALSE,
  annotation.args = list(
title = "Version 1"))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.

grouped_ggwithinstats(
  data            = rbind(session3.pretty.filtered.shape,session3.pretty.filtered.noshape) %>% 
  mutate(across(pairType, recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")),
  subject.id = participant,
  x               = hierarchy,
  y               = meanPerf,
  type            = "parametric",
  xlab            = "Condition",
  grouping.var    = pairType,
  outlier.label = NULL,
  bf.message = FALSE,annotation.args = list(
title = "Version 3"))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.

grouped_ggwithinstats(
  data            = session3.pretty.filtered.scenes %>% 
  mutate(across(pairType, recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")),
  subject.id = participant,
  x               = hierarchy,
  y               = meanPerf,
  type            = "parametric",
  xlab            = "Condition",
  grouping.var    = pairType,
  outlier.label = NULL,
  bf.message = FALSE,
  annotation.args = list(
title = "Version 2"))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.

LMM

load("awareness_score_scenes.Rdata")
load("awareness_score_facescene.Rdata")
load("awareness_score_shape.Rdata")
load("awareness_score_obj.Rdata")

load("session3_pretty_filtered_obj.Rdata")

lmm.scenes <- bind_rows(session3.pretty.filtered.scenes %>% 
  mutate(across(pairType, dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3) ,rbind(session1.avgs.scenes, session2.avgs.scenes) %>% filter(participant %in% session3.pretty.filtered.scenes$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="scene") %>% select(-awareness) %>% left_join(awareness_score.scenes, c("participant"="code")) %>% mutate(participant=paste0("scn",participant), timeelapsed = timeelapsed*60)
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.facescene <- bind_rows(session3.pretty.filtered.facescene %>% 
  mutate(across(pairType, dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.facescene, session2.avgs.facescene) %>% filter(participant %in% session3.pretty.filtered.facescene$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="facescene") %>% select(-awareness) %>% left_join(awareness_score.facescene, c("participant"="code")) %>% mutate(participant=paste0("fsc",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.shape <- bind_rows(session3.pretty.filtered.shape %>% 
  mutate(across(pairType, dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.shape, session2.avgs.shape) %>% filter(participant %in% session3.pretty.filtered.shape$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="obj") %>% select(-awareness) %>% left_join(awareness_score.shape, c("participant"="code")) %>% mutate(participant=paste0("o_s",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
# save(session3.pretty.filtered.obj, file = "session3_pretty_filtered_obj.Rdata")
#load("session3_pretty_filtered_obj.Rdata")

lmm.noshape <- bind_rows(session3.pretty.filtered.obj %>% 
  mutate(across(pairType, dplyr::recode, '24'= "inf", '25'= "inf", '35'="inf",'16'= "anchor"))  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.obj, session2.avgs.obj) %>% filter(participant %in% session3.pretty.filtered.obj$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="obj") %>% select(-awareness) %>% left_join(awareness_score.obj, c("participant"="code")) %>% mutate(participant=paste0("o_ns",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.combined <- bind_rows(lmm.scenes,lmm.facescene,lmm.shape,lmm.noshape)

s1s2.im <- lmm.combined %>% filter(session %in% c(1,2)) 
lmm.combined.wide <-  lmm.combined %>% filter(session == 3) %>% left_join(.,s1s2.im,by=c("participant"="participant","hierarchy"="hierarchy"))

glimpse(lmm.combined)
## Rows: 584
## Columns: 9
## Groups: participant, pairType [219]
## $ participant <chr> "scnBIHKJQY", "scnBIHKJQY", "scnBIHKJQY", "scnGYEDWMN", "s…
## $ pairType    <chr> "anchor", "inf", "premise", "anchor", "inf", "premise", "a…
## $ hierarchy   <chr> "H1", "H1", "H1", "H1", "H1", "H1", "H1", "H1", "H1", "H1"…
## $ meanPerf    <dbl> 0.8750000, 0.1250000, 0.5750000, 0.6250000, 0.3333333, 0.4…
## $ session     <dbl> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3…
## $ blockcount  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ stimuli     <chr> "scene", "scene", "scene", "scene", "scene", "scene", "sce…
## $ awareness   <dbl> 8, 8, 8, 8, 8, 8, 3, 3, 3, 5, 5, 5, 11, 11, 11, 7, 7, 7, 8…
## $ timeelapsed <dbl> 186.9333, 186.9333, 186.9333, 204.5167, 204.5167, 204.5167…
library(lme4)
library(lmerTest)
## 
## Attaching package: 'lmerTest'
## 
## The following object is masked from 'package:lme4':
## 
##     lmer
## 
## The following object is masked from 'package:stats':
## 
##     step
# new attempt : with wide

m1 <- lmer(meanPerf.x ~ 1 + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x == "inf"), REML=FALSE)

m2 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x == "inf"))

m3 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x == "inf"))

tab_model(m1,m2,m3)
  meanPerf.x meanPerf.x meanPerf.x
Predictors Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.54 0.49 – 0.59 <0.001 0.20 -0.02 – 0.43 0.072 0.05 -0.22 – 0.33 0.696
hierarchy [H2] -0.08 -0.16 – 0.00 0.051 0.28 -0.13 – 0.68 0.179
meanPerf y 0.50 0.20 – 0.79 0.001 0.71 0.34 – 1.08 <0.001
hierarchy [H2] × meanPerf
y
-0.46 -0.98 – 0.05 0.078
Random Effects
σ2 0.06 0.05 0.05
τ00 0.01 participant 0.02 participant 0.02 participant
ICC 0.18 0.29 0.32
N 73 participant 73 participant 73 participant
Observations 146 146 146
Marginal R2 / Conditional R2 0.000 / 0.180 0.077 / 0.342 0.094 / 0.380
plot_model(m2, type="pred", terms = c("meanPerf.y","hierarchy"))

# new attempt : with wide; without below chance immediate premise performers // affects two participants

m1 <- lmer(meanPerf.x ~ 1 + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x == "inf", meanPerf.y>0.5), REML=FALSE)

m2 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x == "inf",meanPerf.y>0.5))

m3 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x == "inf",meanPerf.y>0.5))

anova(m1,m2,m3)
## refitting model(s) with ML (instead of REML)
## Data: lmm.combined.wide %>% filter(pairType.x == "inf", meanPerf.y >  ...
## Models:
## m1: meanPerf.x ~ 1 + (1 | participant)
## m2: meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant)
## m3: meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant)
##    npar    AIC    BIC  logLik deviance  Chisq Df Pr(>Chisq)   
## m1    3 37.478 46.127 -15.739   31.479                        
## m2    5 31.720 46.134 -10.860   21.720 9.7583  2   0.007603 **
## m3    6 33.210 50.507 -10.605   21.210 0.5101  1   0.475083   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(m1,m2,m3)
  meanPerf.x meanPerf.x meanPerf.x
Predictors Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.56 0.50 – 0.61 <0.001 0.23 -0.06 – 0.51 0.115 0.14 -0.22 – 0.51 0.431
hierarchy [H2] -0.11 -0.19 – -0.03 0.008 0.07 -0.44 – 0.58 0.781
meanPerf y 0.49 0.13 – 0.86 0.008 0.60 0.13 – 1.07 0.013
hierarchy [H2] × meanPerf
y
-0.23 -0.86 – 0.41 0.483
Random Effects
σ2 0.06 0.05 0.05
τ00 0.02 participant 0.03 participant 0.03 participant
ICC 0.28 0.40 0.40
N 71 participant 71 participant 71 participant
Observations 132 132 132
Marginal R2 / Conditional R2 0.000 / 0.280 0.068 / 0.442 0.070 / 0.447
plot_model(m2, type="pred", terms = c("meanPerf.y","hierarchy"))

Looking into Distance effects

load("awareness_score_scenes.Rdata")
load("awareness_score_facescene.Rdata")
load("awareness_score_shape.Rdata")
load("awareness_score_obj.Rdata")

load("session3_pretty_filtered_obj.Rdata")

lmm.scenes <- bind_rows(session3.pretty.filtered.scenes %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3) ,rbind(session1.avgs.scenes, session2.avgs.scenes) %>% filter(participant %in% session3.pretty.filtered.scenes$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="scene") %>% select(-awareness) %>% left_join(awareness_score.scenes, c("participant"="code")) %>% mutate(participant=paste0("scn",participant), timeelapsed = timeelapsed*60)
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.facescene <- bind_rows(session3.pretty.filtered.facescene  %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.facescene, session2.avgs.facescene) %>% filter(participant %in% session3.pretty.filtered.facescene$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="facescene") %>% select(-awareness) %>% left_join(awareness_score.facescene, c("participant"="code")) %>% mutate(participant=paste0("fsc",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.shape <- bind_rows(session3.pretty.filtered.shape %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.shape, session2.avgs.shape) %>% filter(participant %in% session3.pretty.filtered.shape$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="obj") %>% select(-awareness) %>% left_join(awareness_score.shape, c("participant"="code")) %>% mutate(participant=paste0("o_s",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
# save(session3.pretty.filtered.obj, file = "session3_pretty_filtered_obj.Rdata")
#load("session3_pretty_filtered_obj.Rdata")

lmm.noshape <- bind_rows(session3.pretty.filtered.obj %>% group_by(participant,pairType, awareness) %>% summarise(H1 = mean(H1), H2 = mean(H2)) %>% gather(hierarchy, meanPerf, c("H1","H2")) %>% mutate(session=3), rbind(session1.avgs.obj, session2.avgs.obj) %>% filter(participant %in% session3.pretty.filtered.obj$participant) %>% group_by(participant,session,blockcount) %>% summarise(premise=mean(key_resp_im.corr)) %>% gather(pairType, meanPerf, premise) %>% mutate(hierarchy=paste0("H",session))) %>% mutate(stimuli="obj") %>% select(-awareness) %>% left_join(awareness_score.obj, c("participant"="code")) %>% mutate(participant=paste0("o_ns",participant))
## `summarise()` has grouped output by 'participant', 'pairType'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'participant', 'session'. You can override
## using the `.groups` argument.
lmm.combined <- bind_rows(lmm.scenes,lmm.facescene,lmm.shape,lmm.noshape) 

s1s2.im <- lmm.combined %>% filter(session %in% c(1,2)) 
lmm.combined.wide <-  lmm.combined %>% filter(session == 3) %>% left_join(.,s1s2.im,by=c("participant"="participant","hierarchy"="hierarchy")) %>% filter(pairType.x != "premise")  %>% 
  mutate(Rank1 = as.numeric(str_sub(pairType.x, start = 1, end = 1)),
                   Rank2 = as.numeric(str_sub(pairType.x, start = 2, end = 2))) %>% mutate(distance = abs(Rank1-Rank2), totalrank=Rank1+Rank2)

glimpse(lmm.combined.wide)
## Rows: 584
## Columns: 20
## Groups: participant [73]
## $ participant   <chr> "scnBIHKJQY", "scnBIHKJQY", "scnBIHKJQY", "scnBIHKJQY", …
## $ pairType.x    <chr> "16", "24", "25", "35", "16", "24", "25", "35", "16", "2…
## $ hierarchy     <chr> "H1", "H1", "H1", "H1", "H1", "H1", "H1", "H1", "H1", "H…
## $ meanPerf.x    <dbl> 0.875, 0.125, 0.250, 0.000, 0.625, 0.000, 0.125, 0.875, …
## $ session.x     <dbl> 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,…
## $ blockcount.x  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
## $ stimuli.x     <chr> "scene", "scene", "scene", "scene", "scene", "scene", "s…
## $ awareness.x   <dbl> 8, 8, 8, 8, 8, 8, 8, 8, 3, 3, 3, 3, 5, 5, 5, 5, 11, 11, …
## $ timeelapsed.x <dbl> 186.9333, 186.9333, 186.9333, 186.9333, 204.5167, 204.51…
## $ pairType.y    <chr> "premise", "premise", "premise", "premise", "premise", "…
## $ meanPerf.y    <dbl> 0.5500, 0.5500, 0.5500, 0.5500, 0.5500, 0.5500, 0.5500, …
## $ session.y     <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
## $ blockcount.y  <dbl> 9, 9, 9, 9, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 8, 8, 8,…
## $ stimuli.y     <chr> "scene", "scene", "scene", "scene", "scene", "scene", "s…
## $ awareness.y   <dbl> 8, 8, 8, 8, 8, 8, 8, 8, 3, 3, 3, 3, 5, 5, 5, 5, 11, 11, …
## $ timeelapsed.y <dbl> 186.9333, 186.9333, 186.9333, 186.9333, 204.5167, 204.51…
## $ Rank1         <dbl> 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 2,…
## $ Rank2         <dbl> 6, 4, 5, 5, 6, 4, 5, 5, 6, 4, 5, 5, 6, 4, 5, 5, 6, 4, 5,…
## $ distance      <dbl> 5, 2, 3, 2, 5, 2, 3, 2, 5, 2, 3, 2, 5, 2, 3, 2, 5, 2, 3,…
## $ totalrank     <dbl> 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7, 8, 7, 6, 7,…
library(lme4)
library(lmerTest)

# new attempt : with wide

# IMPORTANT

m0 <- lmer(meanPerf.x ~ 1 + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x != "16"))

m1 <- lmer(meanPerf.x ~ hierarchy + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x != "16"))

m2 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x != "16"))

m3 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16"))

tab_model(m0,m1,m2,m3)
  meanPerf.x meanPerf.x meanPerf.x meanPerf.x
Predictors Estimates CI p Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.54 0.49 – 0.59 <0.001 0.56 0.50 – 0.62 <0.001 0.11 -0.09 – 0.31 0.265 -0.04 -0.27 – 0.19 0.726
hierarchy [H2] -0.04 -0.10 – 0.02 0.233 -0.09 -0.15 – -0.03 0.004 0.30 -0.03 – 0.62 0.072
meanPerf y 0.62 0.36 – 0.89 <0.001 0.84 0.53 – 1.15 <0.001
hierarchy [H2] × meanPerf
y
-0.50 -0.91 – -0.09 0.017
Random Effects
σ2 0.10 0.10 0.09 0.09
τ00 0.03 participant 0.03 participant 0.03 participant 0.04 participant
ICC 0.23 0.23 0.27 0.28
N 73 participant 73 participant 73 participant 73 participant
Observations 438 438 438 438
Marginal R2 / Conditional R2 0.000 / 0.226 0.003 / 0.228 0.070 / 0.322 0.080 / 0.336
m4 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + distance + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16"))

m5 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + distance + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16"))

m6 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + distance*hierarchy + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16"))

tab_model(m1,m2,m3, m4,m5,m6)
  meanPerf.x meanPerf.x meanPerf.x meanPerf.x meanPerf.x meanPerf.x
Predictors Estimates CI p Estimates CI p Estimates CI p Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.56 0.50 – 0.62 <0.001 0.11 -0.09 – 0.31 0.265 -0.04 -0.27 – 0.19 0.726 0.01 -0.24 – 0.25 0.956 -0.15 -0.42 – 0.12 0.287 -0.19 -0.50 – 0.11 0.214
hierarchy [H2] -0.04 -0.10 – 0.02 0.233 -0.09 -0.15 – -0.03 0.004 0.30 -0.03 – 0.62 0.072 -0.09 -0.15 – -0.03 0.004 0.30 -0.03 – 0.62 0.071 0.39 -0.04 – 0.82 0.074
meanPerf y 0.62 0.36 – 0.89 <0.001 0.84 0.53 – 1.15 <0.001 0.63 0.36 – 0.89 <0.001 0.84 0.53 – 1.15 <0.001 0.84 0.53 – 1.15 <0.001
hierarchy [H2] × meanPerf
y
-0.50 -0.91 – -0.09 0.017 -0.50 -0.91 – -0.09 0.016 -0.50 -0.91 – -0.09 0.017
distance 0.05 -0.02 – 0.11 0.144 0.05 -0.01 – 0.11 0.140 0.07 -0.02 – 0.15 0.133
hierarchy [H2] × distance -0.04 -0.16 – 0.08 0.514
Random Effects
σ2 0.10 0.09 0.09 0.09 0.09 0.09
τ00 0.03 participant 0.03 participant 0.04 participant 0.03 participant 0.04 participant 0.04 participant
ICC 0.23 0.27 0.28 0.27 0.28 0.28
N 73 participant 73 participant 73 participant 73 participant 73 participant 73 participant
Observations 438 438 438 438 438 438
Marginal R2 / Conditional R2 0.003 / 0.228 0.070 / 0.322 0.080 / 0.336 0.074 / 0.325 0.083 / 0.339 0.084 / 0.339
# distance doesn't improve LogLik

anova(m1,m2,m3,m4)
## refitting model(s) with ML (instead of REML)
## Data: lmm.combined.wide %>% filter(pairType.x != "16")
## Models:
## m1: meanPerf.x ~ hierarchy + (1 | participant)
## m2: meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant)
## m3: meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant)
## m4: meanPerf.x ~ hierarchy + meanPerf.y + distance + (1 | participant)
##    npar    AIC    BIC  logLik deviance   Chisq Df Pr(>Chisq)    
## m1    4 310.99 327.32 -151.50   302.99                          
## m2    5 292.57 312.98 -141.28   282.57 20.4228  1  6.208e-06 ***
## m3    6 288.82 313.31 -138.41   276.82  5.7452  1    0.01653 *  
## m4    6 292.41 316.90 -140.21   280.41  0.0000  0               
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot_model(m3, type="pred", terms = c("meanPerf.y","hierarchy"))

plot_model(m3, type="diag")
## Warning in checkMatrixPackageVersion(): Package version inconsistency detected.
## TMB was built with Matrix version 1.5.3
## Current Matrix version is 1.5.1
## Please re-install 'TMB' from source using install.packages('TMB', type = 'source') or ask CRAN for a binary version of 'TMB' matching CRAN's 'Matrix' package
## [[1]]
## `geom_smooth()` using formula = 'y ~ x'

## 
## [[2]]
## [[2]]$participant
## `geom_smooth()` using formula = 'y ~ x'

## 
## 
## [[3]]

## 
## [[4]]
## `geom_smooth()` using formula = 'y ~ x'

# new attempt : with wide; without below chance immediate premise performers // affects two participants

m1 <- lmer(meanPerf.x ~ 1 + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x != "16", meanPerf.y>0.5), REML=FALSE)

m2 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x != "16",meanPerf.y>0.5))

m3 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16",meanPerf.y>0.5))

m4 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + distance + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16",meanPerf.y>0.5))

m5 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + distance + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16",meanPerf.y>0.5))

m6 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + distance*hierarchy + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16",meanPerf.y>0.5))

tab_model(m1,m2,m3,m4,m5,m6)
  meanPerf.x meanPerf.x meanPerf.x meanPerf.x meanPerf.x meanPerf.x
Predictors Estimates CI p Estimates CI p Estimates CI p Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.56 0.51 – 0.61 <0.001 0.15 -0.10 – 0.40 0.245 0.06 -0.26 – 0.37 0.720 0.06 -0.23 – 0.35 0.695 -0.03 -0.38 – 0.31 0.849 -0.07 -0.45 – 0.31 0.708
hierarchy [H2] -0.12 -0.18 – -0.05 <0.001 0.09 -0.34 – 0.52 0.686 -0.12 -0.18 – -0.05 <0.001 0.09 -0.34 – 0.52 0.686 0.16 -0.36 – 0.68 0.538
meanPerf y 0.60 0.28 – 0.92 <0.001 0.72 0.31 – 1.12 0.001 0.60 0.28 – 0.92 <0.001 0.72 0.31 – 1.12 0.001 0.72 0.31 – 1.12 0.001
hierarchy [H2] × meanPerf
y
-0.26 -0.79 – 0.27 0.342 -0.26 -0.79 – 0.27 0.341 -0.26 -0.79 – 0.27 0.342
distance 0.04 -0.02 – 0.10 0.224 0.04 -0.02 – 0.10 0.224 0.06 -0.04 – 0.15 0.230
hierarchy [H2] × distance -0.03 -0.16 – 0.09 0.617
Random Effects
σ2 0.10 0.09 0.09 0.09 0.09 0.09
τ00 0.03 participant 0.04 participant 0.04 participant 0.04 participant 0.04 participant 0.04 participant
ICC 0.26 0.31 0.31 0.31 0.31 0.31
N 71 participant 71 participant 71 participant 71 participant 71 participant 71 participant
Observations 396 396 396 396 396 396
Marginal R2 / Conditional R2 0.000 / 0.261 0.055 / 0.350 0.057 / 0.353 0.058 / 0.352 0.059 / 0.355 0.059 / 0.354

Some descriptive plots

lmm.combined.wide %>% group_by(participant, hierarchy) %>% count()
## # A tibble: 146 × 3
## # Groups:   participant, hierarchy [146]
##    participant hierarchy     n
##    <chr>       <chr>     <int>
##  1 fscBTCQUV   H1            4
##  2 fscBTCQUV   H2            4
##  3 fscCERPNO   H1            4
##  4 fscCERPNO   H2            4
##  5 fscFOMAYQ   H1            4
##  6 fscFOMAYQ   H2            4
##  7 fscFTUDJP   H1            4
##  8 fscFTUDJP   H2            4
##  9 fscGLIBTX   H1            4
## 10 fscGLIBTX   H2            4
## # … with 136 more rows
lmm.combined.wide %>% filter(pairType.x != "16", meanPerf.y>0.5)  %>% group_by(participant, hierarchy) %>% count()
## # A tibble: 132 × 3
## # Groups:   participant, hierarchy [132]
##    participant hierarchy     n
##    <chr>       <chr>     <int>
##  1 fscBTCQUV   H1            3
##  2 fscBTCQUV   H2            3
##  3 fscCERPNO   H1            3
##  4 fscCERPNO   H2            3
##  5 fscFOMAYQ   H1            3
##  6 fscFOMAYQ   H2            3
##  7 fscFTUDJP   H1            3
##  8 fscFTUDJP   H2            3
##  9 fscGLIBTX   H1            3
## 10 fscGLIBTX   H2            3
## # … with 122 more rows
library(ggstatsplot)

tmp <- lmm.combined.wide %>% filter(pairType.x != "16") %>% filter(meanPerf.y>0.5)

grouped_ggwithinstats(
  data = lmm.combined.wide %>% filter(pairType.x != "16", participant %in% tmp$participant),
  x                = hierarchy,
  y                =  meanPerf.x,
  grouping.var     = pairType.x ,
  type             = "np",
  bf.message = FALSE
)

# IMPORTANT

# distant inference pair
m0 <- lmer(meanPerf.x ~ 1 + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x == "25"))

m1 <- lmer(meanPerf.x ~ hierarchy + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x == "25"))

m2 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x == "25"))

m3 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x == "25"))

tab_model(m0,m1,m2,m3)
  meanPerf.x meanPerf.x meanPerf.x meanPerf.x
Predictors Estimates CI p Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.57 0.51 – 0.63 <0.001 0.60 0.52 – 0.68 <0.001 0.23 -0.04 – 0.51 0.096 0.09 -0.25 – 0.42 0.614
hierarchy [H2] -0.06 -0.16 – 0.04 0.208 -0.11 -0.21 – -0.01 0.032 0.25 -0.25 – 0.75 0.324
meanPerf y 0.52 0.15 – 0.88 0.007 0.72 0.26 – 1.18 0.002
hierarchy [H2] × meanPerf
y
-0.47 -1.11 – 0.17 0.151
Random Effects
σ2 0.09 0.09 0.08 0.08
τ00 0.03 participant 0.03 participant 0.03 participant 0.04 participant
ICC 0.23 0.24 0.29 0.31
N 73 participant 73 participant 73 participant 73 participant
Observations 146 146 146 146
Marginal R2 / Conditional R2 0.000 / 0.233 0.008 / 0.243 0.061 / 0.336 0.071 / 0.359
plot_model(m2, type="pred", terms = c("meanPerf.y","hierarchy"))

plot_model(m2, type="diag")
## [[1]]
## `geom_smooth()` using formula = 'y ~ x'

## 
## [[2]]
## [[2]]$participant
## `geom_smooth()` using formula = 'y ~ x'

## 
## 
## [[3]]

## 
## [[4]]
## `geom_smooth()` using formula = 'y ~ x'

# BD inference pair
m0 <- lmer(meanPerf.x ~ 1 + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x == "24"))

m1 <- lmer(meanPerf.x ~ hierarchy + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x == "24"))

m2 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x == "24"))

m3 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x == "24"))

tab_model(m0,m1,m2,m3)
  meanPerf.x meanPerf.x meanPerf.x meanPerf.x
Predictors Estimates CI p Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.52 0.46 – 0.59 <0.001 0.55 0.47 – 0.64 <0.001 0.35 0.05 – 0.65 0.024 0.14 -0.25 – 0.52 0.476
hierarchy [H2] -0.06 -0.18 – 0.06 0.326 -0.09 -0.21 – 0.04 0.172 0.41 -0.20 – 1.01 0.184
meanPerf y 0.29 -0.11 – 0.69 0.154 0.58 0.06 – 1.10 0.030
hierarchy [H2] × meanPerf
y
-0.64 -1.42 – 0.13 0.102
Random Effects
σ2 0.13 0.13 0.13 0.12
τ00 0.00 participant 0.00 participant 0.01 participant 0.01 participant
ICC 0.04 0.04 0.07 0.10
N 73 participant 73 participant 73 participant 73 participant
Observations 146 146 146 146
Marginal R2 / Conditional R2 0.000 / 0.036 0.006 / 0.042 0.021 / 0.086 0.038 / 0.131
grouped_ggbetweenstats(
  data = lmm.combined.wide %>% filter(pairType.x != "16"),
  x                = pairType.x,
  y                =  meanPerf.x,
  grouping.var     = hierarchy ,
  type             = "p",
  bf.message = FALSE
)

Looking into Total rank

# new attempt : with wide

m0 <- lmer(meanPerf.x ~ 1 + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x != "16"))

m1 <- lmer(meanPerf.x ~ hierarchy + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x != "16"))

m2 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x != "16"))

m3 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16"))

tab_model(m0,m1,m2,m3)
  meanPerf.x meanPerf.x meanPerf.x meanPerf.x
Predictors Estimates CI p Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.54 0.49 – 0.59 <0.001 0.56 0.50 – 0.62 <0.001 0.11 -0.09 – 0.31 0.265 -0.04 -0.27 – 0.19 0.726
hierarchy [H2] -0.04 -0.10 – 0.02 0.233 -0.09 -0.15 – -0.03 0.004 0.30 -0.03 – 0.62 0.072
meanPerf y 0.62 0.36 – 0.89 <0.001 0.84 0.53 – 1.15 <0.001
hierarchy [H2] × meanPerf
y
-0.50 -0.91 – -0.09 0.017
Random Effects
σ2 0.10 0.10 0.09 0.09
τ00 0.03 participant 0.03 participant 0.03 participant 0.04 participant
ICC 0.23 0.23 0.27 0.28
N 73 participant 73 participant 73 participant 73 participant
Observations 438 438 438 438
Marginal R2 / Conditional R2 0.000 / 0.226 0.003 / 0.228 0.070 / 0.322 0.080 / 0.336
m4 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + totalrank + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16"))

m5 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + totalrank + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16"))

m6 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + totalrank*hierarchy + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16"))

tab_model(m1,m2,m3, m4,m5,m6)
  meanPerf.x meanPerf.x meanPerf.x meanPerf.x meanPerf.x meanPerf.x
Predictors Estimates CI p Estimates CI p Estimates CI p Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.56 0.50 – 0.62 <0.001 0.11 -0.09 – 0.31 0.265 -0.04 -0.27 – 0.19 0.726 0.10 -0.22 – 0.41 0.554 -0.06 -0.40 – 0.28 0.731 0.07 -0.34 – 0.49 0.738
hierarchy [H2] -0.04 -0.10 – 0.02 0.233 -0.09 -0.15 – -0.03 0.004 0.30 -0.03 – 0.62 0.072 -0.09 -0.15 – -0.03 0.004 0.30 -0.03 – 0.62 0.072 0.04 -0.55 – 0.62 0.904
meanPerf y 0.62 0.36 – 0.89 <0.001 0.84 0.53 – 1.15 <0.001 0.62 0.36 – 0.89 <0.001 0.84 0.52 – 1.15 <0.001 0.84 0.52 – 1.15 <0.001
hierarchy [H2] × meanPerf
y
-0.50 -0.91 – -0.09 0.017 -0.50 -0.91 – -0.09 0.017 -0.50 -0.91 – -0.09 0.017
totalrank 0.00 -0.03 – 0.04 0.885 0.00 -0.03 – 0.04 0.885 -0.02 -0.07 – 0.03 0.523
hierarchy [H2] ×
totalrank
0.04 -0.03 – 0.11 0.295
Random Effects
σ2 0.10 0.09 0.09 0.09 0.09 0.09
τ00 0.03 participant 0.03 participant 0.04 participant 0.03 participant 0.04 participant 0.04 participant
ICC 0.23 0.27 0.28 0.27 0.28 0.28
N 73 participant 73 participant 73 participant 73 participant 73 participant 73 participant
Observations 438 438 438 438 438 438
Marginal R2 / Conditional R2 0.003 / 0.228 0.070 / 0.322 0.080 / 0.336 0.070 / 0.321 0.080 / 0.335 0.081 / 0.336
# distance doesn't improve LogLik

anova(m1,m2,m3,m4)
## refitting model(s) with ML (instead of REML)
## Data: lmm.combined.wide %>% filter(pairType.x != "16")
## Models:
## m1: meanPerf.x ~ hierarchy + (1 | participant)
## m2: meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant)
## m3: meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant)
## m4: meanPerf.x ~ hierarchy + meanPerf.y + totalrank + (1 | participant)
##    npar    AIC    BIC  logLik deviance   Chisq Df Pr(>Chisq)    
## m1    4 310.99 327.32 -151.50   302.99                          
## m2    5 292.57 312.98 -141.28   282.57 20.4228  1  6.208e-06 ***
## m3    6 288.82 313.31 -138.41   276.82  5.7452  1    0.01653 *  
## m4    6 294.55 319.04 -141.27   282.55  0.0000  0               
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot_model(m3, type="pred", terms = c("meanPerf.y","hierarchy"))

# new attempt : with wide; without below chance immediate premise performers // affects two participants

m1 <- lmer(meanPerf.x ~ 1 + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x != "16", meanPerf.y>0.5), REML=FALSE)

m2 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + (1 | participant), data = lmm.combined.wide %>% filter(pairType.x != "16",meanPerf.y>0.5))

m3 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16",meanPerf.y>0.5))

m4 <- lmer(meanPerf.x ~ hierarchy + meanPerf.y + distance + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16",meanPerf.y>0.5))

m5 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + distance + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16",meanPerf.y>0.5))

m6 <- lmer(meanPerf.x ~ hierarchy * meanPerf.y + distance*hierarchy + (1 | participant) , data = lmm.combined.wide %>% filter(pairType.x != "16",meanPerf.y>0.5))

tab_model(m1,m2,m3,m4,m5,m6)
  meanPerf.x meanPerf.x meanPerf.x meanPerf.x meanPerf.x meanPerf.x
Predictors Estimates CI p Estimates CI p Estimates CI p Estimates CI p Estimates CI p Estimates CI p
(Intercept) 0.56 0.51 – 0.61 <0.001 0.15 -0.10 – 0.40 0.245 0.06 -0.26 – 0.37 0.720 0.06 -0.23 – 0.35 0.695 -0.03 -0.38 – 0.31 0.849 -0.07 -0.45 – 0.31 0.708
hierarchy [H2] -0.12 -0.18 – -0.05 <0.001 0.09 -0.34 – 0.52 0.686 -0.12 -0.18 – -0.05 <0.001 0.09 -0.34 – 0.52 0.686 0.16 -0.36 – 0.68 0.538
meanPerf y 0.60 0.28 – 0.92 <0.001 0.72 0.31 – 1.12 0.001 0.60 0.28 – 0.92 <0.001 0.72 0.31 – 1.12 0.001 0.72 0.31 – 1.12 0.001
hierarchy [H2] × meanPerf
y
-0.26 -0.79 – 0.27 0.342 -0.26 -0.79 – 0.27 0.341 -0.26 -0.79 – 0.27 0.342
distance 0.04 -0.02 – 0.10 0.224 0.04 -0.02 – 0.10 0.224 0.06 -0.04 – 0.15 0.230
hierarchy [H2] × distance -0.03 -0.16 – 0.09 0.617
Random Effects
σ2 0.10 0.09 0.09 0.09 0.09 0.09
τ00 0.03 participant 0.04 participant 0.04 participant 0.04 participant 0.04 participant 0.04 participant
ICC 0.26 0.31 0.31 0.31 0.31 0.31
N 71 participant 71 participant 71 participant 71 participant 71 participant 71 participant
Observations 396 396 396 396 396 396
Marginal R2 / Conditional R2 0.000 / 0.261 0.055 / 0.350 0.057 / 0.353 0.058 / 0.352 0.059 / 0.355 0.059 / 0.354