-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
171 lines (137 loc) · 7.08 KB
/
README.Rmd
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
---
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# README
These are analysis operations and data for the study titled "Musical expertise better predictor of tension in harmonic intervals than psychoacoustics across North and South Indian listeners" by Imre Lahdelma, [Tuomas Eerola](https://tuomaseerola.github.io/), Nashra Ahmad, Martin Clayton, James Armitage, Budhaditya Bhattacharyya, and Niveshan Munsamy.
## Load data
```{r load_data, warning = FALSE, message = FALSE}
rm(list = ls())
library(ggplot2)
library(dplyr)
library(papaja)
options(dplyr.summarise.inform = FALSE)
df <- read.csv('data/indian_tension_ratings.csv')
knitr::kable(head(df),format = 'markdown')
```
**Brief explanation of columns**
* `omsi1indian` refers to participant's own decision of how they identify themselves as indian musicians according to OMSI 1-item question.
* `omsi1western` refers to participant's own decision of how they identify themselves as western musicians according to OMSI 1-item question.
* `gender` = Self-defined gender (Male/Female)
* `age` = Age in years
* `participant` = unique code for each participant
* `Expertise` = Number of questions correct in custom Indian classical music familiary questionnaire. Note that since Carnatic and Hindustani questionnaires have different number of questions, we use the proportion correct (`ExpertiseN`) as the index for the expertise.
* `tension_rating` = Rating of tension from 1 to 7 (7-point scale)
* `Group` = Carnatic, Hindustani or Indian non-musicians
* `musicianship` = variable inferred from `omsi1indian`
* `participant` = variable inferred from `omsi1western`
* `ExpertiseN` = Proportion of expertise questions correct (0-100)
## Describe participants
```{r describe_data, warning = FALSE, message = FALSE}
U<-as.character(unique(df$participant))
background <- NULL
for (k in 1:length(U)) {
tmp <- dplyr::filter(df,participant==U[k])
background<-rbind(background,tmp[1,])
}
SS <- summarise(group_by(background,Group),N=n(),ageM=mean(age,na.rm=TRUE),ageSE=sd(age,na.rm=TRUE)/sqrt(n()),expertiseM=mean(ExpertiseN,na.rm=TRUE),expertiseSE=sd(ExpertiseN,na.rm=TRUE)/sqrt(n()),female=sum(gender=='Female')/n()*100)
knitr::kable(SS,digits = 2,format = 'markdown')
m1 <- aov(ExpertiseN ~ Group, data=background)
a<-apa_print(summary(m1))
print(a$statistic)
print(TukeyHSD(m1))
```
## LMM analysis
### Are the Hindustani and Carnatic musicians tension ratings different from each other?
```{r LMM, warning = FALSE, message = FALSE}
library(lme4)
library(lmerTest)
library(emmeans)
library(effectsize)
# Put the intervals in the correct order in the factor
iv_labels <- c('m2','M2','m3','M3','P4','A4','P5','m6','M6','m7','M7','P8')
df$Interval<-factor(df$Interval,levels = iv_labels)
# Take only Carnatic and Hindustani Musicians
tmp<-dplyr::filter(df,Group=='Carnatic' | Group=='Hindustani')
tmp$Group<-factor(tmp$Group)
m1 <- lmer(tensionrating ~ Interval * Group + (1|participant), data=tmp)
print(anova(m1))
# No difference between the two expert groups nor interaction
```
### Differences between and within musicians and non-musicians?
```{r LMM2}
# Combine two musician groups and relabel everybody to musician/non-musician
df$Group2<-as.character(df$Group)
df$Group2[df$Group=='Carnatic']<-'Musicians'
df$Group2[df$Group=='Hindustani']<-'Musicians'
df$Group2[df$Group=='Indian - non-musicians']<-'Non-musicians'
df$Group2<-factor(df$Group2)
m1 <- lmer(tensionrating ~ Group2 * Interval + (1|participant),data = df)
print(anova(m1))
F_to_eta2(8.7738, 11, 757.09) # effect size
F_to_eta2(10.4117, 11, 757.09) # effect size
print(pairs(emmeans(m1,~ Group2|Interval))) # this for each interval
```
The comparison of intervals across musicians/non-musicians is also documented in the Figure 1.
#### Check discrimination of intervals within non-musicians
```{r LMM-nonmusicians}
m1 <- lmer(tensionrating ~ Interval + (1|participant),data = dplyr::filter(df,Group2=='Non-musicians'))
anova(m1)
F_to_epsilon2(4.5092, 11, 275) # effect size
# posthocs with multiple corrections
emm <- emmeans(m1,specs = pairwise ~ Interval,pbkrtest.limit = 4345, type = "response")
print(emm$contrasts)
# 7/66 comparison significant at p<.05 level
```
#### Check discrimination of intervals within musicians
```{r LMM-musicians}
m1 <- lmer(tensionrating ~ Interval + (1|participant),data = dplyr::filter(df,Group2=='Musicians'))
print(anova(m1))
F_to_epsilon2(17.848, 11, 482.16) # effect size
# posthocs with multiple corrections
emm <- emmeans(m1,specs = pairwise ~ Interval,pbkrtest.limit = 4345, type = "response")
emm$contrasts
# 34/66 comparison significant at p<.05 level
```
## Visualise tension ratings of both groups
```{r figure, fig.width=10.5,fig.height=7,warning=FALSE,message=FALSE,results='asis',fig.cap="Mean tension ratings for all intervals across expertise. Statistical significance testing based on LMM analysis and multiple comparison adjusted posthoc comparisons for between groups (upper part of the plot) and within groups (lower part of the plot), see text for statistical details."}
# take the means and 95% CIs
S <- df %>%
group_by(Interval,Group2) %>%
summarize(n=n(),M=mean(tensionrating,na.rm = TRUE),sd=sd(tensionrating,na.rm = TRUE)) %>%
mutate(se=sd/sqrt(n),LCI=M+qnorm(0.025)*se,UCI=M+qnorm(0.975)*se)
dval<-0.33
colnames(S)[2] <- 'Expertise'
fig_india <- ggplot(S,aes(Interval,M,color=Expertise,group=Expertise,linestyle=Expertise,shape=Expertise))+
geom_point(position=position_dodge(dval),size=4)+
geom_line(position=position_dodge(dval))+
geom_errorbar(aes(min=LCI, max=UCI),width=.2,position=position_dodge(dval)) +
scale_y_continuous(breaks = seq(1,7,by=1),limits = c(1,7),expand = c(0.005,0.005))+
scale_color_brewer(type = "div",palette = 'Set2')+
scale_shape_manual(values=c(19,17))+
ylab('Tension Rating (M ± 95% CI)')+
theme_bw()+
theme(legend.position="bottom")+
# Annotations take the statistics from analyses above
annotate("text",x = 1,y=5.87,label='italic(p)<.001',parse = TRUE,size=3)+
annotate("text",x = 4,y=5.87,label='italic(p)<.05',parse = TRUE,size=3)+
annotate("text",x = 5,y=5.87,label='italic(p)<.001',parse = TRUE,size=3)+
annotate("text",x = 7,y=5.87,label='italic(p)<0.01',parse = TRUE,size=3)+
annotate("text",x = 8,y=5.87,label='italic(p)<.05',parse = TRUE,size=3)+
annotate("text",x = 9,y=5.87,label='italic(p)<.001',parse = TRUE,size=3)+
annotate("text",x = 11,y=5.87,label='italic(p)<.05',parse = TRUE,size=3)+
annotate("text",x = 12,y=5.87,label='italic(p)<.01',parse = TRUE,size=3)+
annotate("text",x = 1,y=6.5,label='Between group comparisons',size=4,hjust=0)+
annotate("text",x = 1,y=2.5,label='Within group comparisons',size=4,hjust=0)+
annotate("text",x = 1.5,y=2.0,label='Musicians:~34/66~intervals~differ~at~italic(p)<.05',color=RColorBrewer::brewer.pal(3, 'Set2')[1],size=3,hjust=0,parse=TRUE)+
annotate("text",x = 1.5,y=1.5,label='Non-musicians:~7/66~intervals~differ~at~italic(p)<.05',color=RColorBrewer::brewer.pal(3, 'Set2')[2],size=3,hjust=0,parse=TRUE)+
ggtitle('Indian samples (N=71)')
print(fig_india)
```
#### Session information
R version and libraries.
```{r}
print(sessionInfo())
```