1 Description

Response times in a conjunction visual search task tend to increase linearly as a function of the number of objects in the display (called “set size”). For example, when looking for a green letter “Y” among green “X’s” and brown “Y’s,” search times are expected to rise as the number of letters on the screen increases. A group of 15 aphasic participants and 18 control participants performed a conjunction visual search task and theis data were recorded.

2 Input Data

# Loading package
pacman::p_load(tidyverse, afex, segmented, foreign, haven, lme4, lmerTest, ggplot2, Rmisc, car)

# data input
dta1 <- read.csv("C:/Users/HANK/Desktop/HOMEWORK/visual_search.csv")

head(dta1)
##   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
dta1 <- dta1 %>%
  mutate(Participant = factor(Participant), 
         Dx = factor(Dx))
         
str(dta1)
## 'data.frame':    132 obs. of  4 variables:
##  $ Participant: Factor w/ 33 levels "0042","0044",..: 19 16 18 25 28 22 24 23 26 27 ...
##  $ Dx         : Factor w/ 2 levels "Aphasic","Control": 2 2 2 2 2 2 2 2 2 2 ...
##  $ Set.Size   : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ RT         : num  786 936 751 1130 1211 ...
dta1_stat <- summarySEwithin(dta1, 
                        measurevar="RT",
                        betweenvars = "Dx",
                        withinvars="Set.Size",
                        idvar="Participant", 
                        na.rm=FALSE, conf.interval=.95)
## Automatically converting the following non-factors to factors: Set.Size

3 plot

ggplot(dta1, aes(Set.Size, RT)) +
  geom_line(aes(group = Participant), alpha = .2) +
  stat_smooth(method = "lm", 
              formula = y ~ x, 
              se = TRUE, 
              lwd = rel(.5)) +
  geom_point (size = rel(.5)) +
  facet_wrap ( ~ Dx) +
  labs(x = "Set size", 
       y = "Reaction time (ms)")

4 LMER

summary(m0_r <- lmer(RT ~ Set.Size | Participant, data = dta1))
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Set.Size | Participant
##    Data: dta1
## 
## REML criterion at convergence: 2260.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5482 -0.4199 -0.0351  0.2632  6.0022 
## 
## Random effects:
##  Groups      Name        Variance Std.Dev. Corr
##  Participant (Intercept) 909394   953.6        
##              Set.Size      3982    63.1    0.61
##  Residual                810733   900.4        
## Number of obs: 132, groups:  Participant, 33
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  1301.69     200.81   31.99   6.482 2.71e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(m0 <- lm(RT ~ Set.Size*Dx, data = dta1))
## 
## Call:
## lm(formula = RT ~ Set.Size * Dx, data = dta1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3869.8  -651.7  -198.2   300.1  9020.1 
## 
## Coefficients:
##                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         2078.75     271.72   7.650 4.23e-12 ***
## Set.Size              73.49      16.02   4.588 1.05e-05 ***
## DxControl          -1106.05     367.92  -3.006  0.00318 ** 
## Set.Size:DxControl   -21.74      21.69  -1.002  0.31813    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1388 on 128 degrees of freedom
## Multiple R-squared:  0.3404, Adjusted R-squared:  0.325 
## F-statistic: 22.02 on 3 and 128 DF,  p-value: 1.456e-11

5 Residuals plots

plot(m0_r, resid(., scaled=TRUE) ~ fitted(.) | Dx, 
     xlab="Fitted values", ylab= "Pearson residuals",
     abline=0, lty=3)