pacman::p_load(WWGbook, tidyverse, lme4, nlme, merTools)
dta <- read.csv("visual_search.csv")
str(dta)## '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 ...
## 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
## '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 ...
theme_set(theme_bw(base_size = 10))
#
ggplot(dta, aes(Set.Size, RT)) +
geom_line(aes(group = Participant), alpha = .5) +
stat_smooth(aes(group = Dx), method = "lm", formula = y ~ x) +
geom_point(alpha = 0.5) +
facet_wrap( ~ Dx) +
labs(x = "Set size", y = "Reaction Time (ms)")# set dodge amount
pd <- position_dodge(width=.2)
# As same sa teacher
ggplot(dta, aes(Set.Size, RT, shape = Dx, linetype = Dx)) +
stat_smooth(method='lm', formula= y~x, geom = "line", position = pd) +
stat_summary(fun = mean, geom = "point", position = pd) +
stat_summary(fun.data = mean_se, geom = "errorbar",
position = pd, linetype = "solid", width = 0.5) +
scale_shape_manual(values = c(1, 2, 16)) +
labs(x = "Set size", y = "Reaction Time (ms)", linetype = "Group", shape = "Group") +
theme(legend.justification = c(0, 1), legend.position = c(0, 1),
legend.background = element_rect(fill = "white", color = "black")) # model
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Set.Size | Participant
## Data: dta
##
## 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 t value
## (Intercept) 1301.7 200.8 6.482