-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdataAnalysis.R
54 lines (39 loc) · 1.56 KB
/
dataAnalysis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
## load packages
library(tidyverse)#for loading data, visualization, ...
library(lmerTest)#load package for repeated measures ANOVA
library(emmeans)#post-hoc
## load data
setwd("C:/Users/ahren/Documents/repos/Intro-R-Psychoacoustics")
dataframe <- read_csv("dataForR.csv",
col_types = cols(
Subject = col_factor(),
Condition = col_factor(c("reference","processing1","processing2","processing3")),
ListenerType = col_factor(),
SRT = col_double()
)
)
## make sure that all datatypes are correct
dataframe
## make a plot
f <- ggplot(dataframe,aes(x=Condition,y=SRT,fill=ListenerType))
f+geom_col(position=position_dodge())
f+geom_boxplot()
f+geom_boxplot()+geom_jitter(width=.1,shape=4)
f+geom_boxplot()+geom_jitter(aes(colour=ListenerType),width=.1,shape=4)
f+geom_boxplot()+geom_jitter(aes(colour=ListenerType),width=.1,shape=4)+theme_bw()
f+geom_boxplot()+geom_jitter(aes(colour=ListenerType),width=.1,shape=4)+theme_bw()+labs(y="SRT [dB]",x="")
f+geom_boxplot()+geom_jitter(aes(colour=ListenerType),width=.1,shape=4)+
theme_bw()+labs(y="SRT [dB]",x="")+theme(text = element_text(size=16))
ggsave("plot.png")
## stats
model1 <- lmer(SRT ~ Condition*ListenerType + (1 | Subject), data = dataframe)
step_result <- step(model1)
step_result
model2 <- get_model(step_result)
anova(model2)
ranova(model2)
# multiple comparisons
emm <- emmeans(model2, ~ Condition,lmer.df = "satterthwaite")
test(emm)
pairs(emm)
pairs(emm, adjust="bonferroni")