1 Read Data

dta <- read.csv("C:/Users/ASUS/Desktop/data/visual_search.csv", header = T)
head(dta)
##   Participant      Dx Set.Size      RT
## 1        9129 Control        1  786.50
## 2        9051 Control        1  935.83
## 3        9126 Control        1  750.83
## 4       9171* Control        1 1129.50
## 5        9176 Control        1 1211.33
## 6        9167 Control        1 1178.83
dta$Participant <- factor(dta$Participant)
dta$Dx <- factor(dta$Dx)

2 Visdualization 01

library(ggplot2)
 ggplot(dta, aes(Set.Size, RT)) +
   geom_line(aes(group = Participant), col = "black")+
geom_point(alpha=0.5)+
    stat_smooth(aes(group=Dx), method="lm", formula= y ~ x)+
     geom_smooth(method = "lm", se = F, lwd = .6)+
 facet_wrap(~ Dx, nrow = 1) +
 labs(x = "Set Size", y="Resonse Time")+ 
   theme(axis.text.x = element_text(size = 6))
## `geom_smooth()` using formula 'y ~ x'

3 Analysis

library(lme4)
## Loading required package: Matrix
summary(m0 <- lmer(RT~Set.Size*Dx+(Set.Size|Participant), data=dta))
## boundary (singular) fit: see ?isSingular
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Set.Size * Dx + (Set.Size | Participant)
##    Data: dta
## 
## REML criterion at convergence: 2186.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7577 -0.3130 -0.0750  0.3117  6.1372 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev. Corr
##  Participant (Intercept) 657489.0 810.86       
##              Set.Size       407.4  20.18   1.00
##  Residual                772445.8 878.89       
## Number of obs: 132, groups:  Participant, 33
## 
## Fixed effects:
##                    Estimate Std. Error t value
## (Intercept)         2078.75     270.97   7.672
## Set.Size              73.49      11.40   6.446
## DxControl          -1106.05     366.89  -3.015
## Set.Size:DxControl   -21.74      15.44  -1.408
## 
## Correlation of Fixed Effects:
##             (Intr) Set.Sz DxCntr
## Set.Size    -0.071              
## DxControl   -0.739  0.053       
## St.Sz:DxCnt  0.053 -0.739 -0.071
## convergence code: 0
## boundary (singular) fit: see ?isSingular
m0<- lmer(RT ~ Set.Size + Dx + Set.Size*Dx + (Set.Size|Participant), dta)
## boundary (singular) fit: see ?isSingular
summary(m0)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Set.Size + Dx + Set.Size * Dx + (Set.Size | Participant)
##    Data: dta
## 
## REML criterion at convergence: 2186.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7577 -0.3130 -0.0750  0.3117  6.1372 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev. Corr
##  Participant (Intercept) 657489.0 810.86       
##              Set.Size       407.4  20.18   1.00
##  Residual                772445.8 878.89       
## Number of obs: 132, groups:  Participant, 33
## 
## Fixed effects:
##                    Estimate Std. Error t value
## (Intercept)         2078.75     270.97   7.672
## Set.Size              73.49      11.40   6.446
## DxControl          -1106.05     366.89  -3.015
## Set.Size:DxControl   -21.74      15.44  -1.408
## 
## Correlation of Fixed Effects:
##             (Intr) Set.Sz DxCntr
## Set.Size    -0.071              
## DxControl   -0.739  0.053       
## St.Sz:DxCnt  0.053 -0.739 -0.071
## convergence code: 0
## boundary (singular) fit: see ?isSingular

4 Visdualization 02

ggplot(dta, aes(Set.Size, RT, shape=Dx, linetype=Dx)) +
  geom_smooth(method='lm', formula= y~x, se=FALSE)+
 stat_summary(fun="mean", geom="line") +
 stat_summary(fun="mean", geom="point") +
 stat_summary(fun.dta=mean_se, 
              geom="errorbar", 
              linetype="solid", width=0.5) +
 scale_shape_manual(values = c(1, 2, 16)) +labs(x="Set.Size", 
      y="Reaction time", 
      linetype="Group", shape="Group") +
 scale_x_continuous(breaks=seq(0,30,by=10))+
 theme_minimal()+
 theme(legend.justification=c(0.1, 1), 
       legend.position=c(0.1, 1),
       legend.background=element_rect(fill="white", 
                                      color="black"))
## Warning: Ignoring unknown parameters: fun.dta
## No summary function supplied, defaulting to `mean_se()`

5 Visdualtion 3

plot(m0, resid(., type="pearson") ~ fitted(.)|Dx, 
     xlab="Fitted values", ylab= "Pearson residuals",
      layout=c(2,1), pch=20, cex=.8,
     abline=0, lty=3)