library(ordinal) ratings = read.csv('Ratings_Exp3.csv',header=TRUE) # Remove subject who had very low English proficiency according to Vernon-Warden test ratings = ratings[ratings$Subject != 17,] # Get condition means and by-subject SEs means = data.frame(Aspect = c("Comprehensibility","Comprehensibility","Acceptability","Acceptability"), Language = c("Dutch","English","Dutch","English"), V0 = c(mean(ratings[ratings$Grammaticality=="gram" & ratings$Language=="nl",]$Comprehensibility,na.rm=TRUE), mean(ratings[ratings$Grammaticality=="gram" & ratings$Language=="en",]$Comprehensibility,na.rm=TRUE), mean(ratings[ratings$Grammaticality=="gram" & ratings$Language=="nl",]$Acceptability,na.rm=TRUE), mean(ratings[ratings$Grammaticality=="gram" & ratings$Language=="en",]$Acceptability,na.rm=TRUE)), V0 = c(mean(ratings[ratings$Grammaticality=="ungram" & ratings$Language=="nl",]$Comprehensibility,na.rm=TRUE), mean(ratings[ratings$Grammaticality=="ungram" & ratings$Language=="en",]$Comprehensibility,na.rm=TRUE), mean(ratings[ratings$Grammaticality=="ungram" & ratings$Language=="nl",]$Acceptability,na.rm=TRUE), mean(ratings[ratings$Grammaticality=="ungram" & ratings$Language=="en",]$Acceptability,na.rm=TRUE))) subj_id = unique(ratings$Subject) nr_subj = length(subj_id) subj_mean = matrix(nrow=8,ncol=nr_subj) p = 1 for (s in subj_id) { subj_mean[1,p] = mean(ratings[ratings$Subject==s & ratings$Grammaticality=="gram" & ratings$Language=="nl",]$Comprehensibility,na.rm=TRUE) subj_mean[2,p] = mean(ratings[ratings$Subject==s & ratings$Grammaticality=="gram" & ratings$Language=="en",]$Comprehensibility,na.rm=TRUE) subj_mean[3,p] = mean(ratings[ratings$Subject==s & ratings$Grammaticality=="gram" & ratings$Language=="nl",]$Acceptability,na.rm=TRUE) subj_mean[4,p] = mean(ratings[ratings$Subject==s & ratings$Grammaticality=="gram" & ratings$Language=="en",]$Acceptability,na.rm=TRUE) subj_mean[5,p] = mean(ratings[ratings$Subject==s & ratings$Grammaticality=="ungram" & ratings$Language=="nl",]$Comprehensibility,na.rm=TRUE) subj_mean[6,p] = mean(ratings[ratings$Subject==s & ratings$Grammaticality=="ungram" & ratings$Language=="en",]$Comprehensibility,na.rm=TRUE) subj_mean[7,p] = mean(ratings[ratings$Subject==s & ratings$Grammaticality=="ungram" & ratings$Language=="nl",]$Acceptability,na.rm=TRUE) subj_mean[8,p] = mean(ratings[ratings$Subject==s & ratings$Grammaticality=="ungram" & ratings$Language=="en",]$Acceptability,na.rm=TRUE) p = p+1 } SEs = data.frame(Aspect = c("Comprehensibility","Comprehensibility","Acceptability","Acceptability"), Language = c("Dutch","English","Dutch","English"), V0 = c(sd(subj_mean[1,])/sqrt(nr_subj),sd(subj_mean[2,])/sqrt(nr_subj),sd(subj_mean[3,])/sqrt(nr_subj),sd(subj_mean[4,])/sqrt(nr_subj)), V2 = c(sd(subj_mean[5,])/sqrt(nr_subj),sd(subj_mean[6,])/sqrt(nr_subj),sd(subj_mean[7,])/sqrt(nr_subj),sd(subj_mean[8,])/sqrt(nr_subj))) # Turn scores into ordinal variable ratings$Acceptability = ordered(ratings$Acceptability) ratings$Comprehensibility = ordered(ratings$Comprehensibility) # Turn subject and item numbers into factors ratings$Subject = as.factor(ratings$Subject) ratings$Item = as.factor(ratings$Item) # Run ordinal mixed-effects analyses with interaction between Grammaticality and Language model_acceptability = clmm(Acceptability ~ Language*Grammaticality + (1+Language+Grammaticality|Subject) + (1+Language+Grammaticality|Item), data=ratings) model_comprehensibility = clmm(Comprehensibility ~ Language*Grammaticality + (1+Language+Grammaticality|Subject) + (1+Language+Grammaticality|Item), data=ratings) rm(ratings,subj_id,subj_mean,nr_subj,p,s) save.image('Exp3.RData')