library(ordinal) ratings = read.csv('Ratings_Exp2.csv',header=TRUE) # Remove dyslexic subjects and subjects who did not respond to at least two items in each condition to_remove = c(7,13,38,42,87) # dyslexic to_remove = c(to_remove,1,2,5:9,11,12,15,17:19,28:74,76,78,79,82:84,97,98,100:106,108,112,117:119,121:126) # did not respond to enough items for (s in to_remove) { ratings = ratings[ratings$Subject != s,] } # Get condition means and by-subject SEs means = data.frame(Aspect = c("Comprehensibility","Acceptability"), V0 = c(mean(ratings[ratings$Condition=="0",]$Comprehensibility,na.rm=TRUE),mean(ratings[ratings$Condition=="0",]$Acceptability,na.rm=TRUE)), V1 = c(mean(ratings[ratings$Condition=="1",]$Comprehensibility,na.rm=TRUE),mean(ratings[ratings$Condition=="1",]$Acceptability,na.rm=TRUE)), V2 = c(mean(ratings[ratings$Condition=="2",]$Comprehensibility,na.rm=TRUE),mean(ratings[ratings$Condition=="2",]$Acceptability,na.rm=TRUE)), V3 = c(mean(ratings[ratings$Condition=="3",]$Comprehensibility,na.rm=TRUE),mean(ratings[ratings$Condition=="3",]$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$Condition=="0",]$Comprehensibility,na.rm=TRUE) subj_mean[2,p] = mean(ratings[ratings$Subject==s & ratings$Condition=="1",]$Comprehensibility,na.rm=TRUE) subj_mean[3,p] = mean(ratings[ratings$Subject==s & ratings$Condition=="2",]$Comprehensibility,na.rm=TRUE) subj_mean[4,p] = mean(ratings[ratings$Subject==s & ratings$Condition=="3",]$Comprehensibility,na.rm=TRUE) subj_mean[5,p] = mean(ratings[ratings$Subject==s & ratings$Condition=="0",]$Acceptability,na.rm=TRUE) subj_mean[6,p] = mean(ratings[ratings$Subject==s & ratings$Condition=="1",]$Acceptability,na.rm=TRUE) subj_mean[7,p] = mean(ratings[ratings$Subject==s & ratings$Condition=="2",]$Acceptability,na.rm=TRUE) subj_mean[8,p] = mean(ratings[ratings$Subject==s & ratings$Condition=="3",]$Acceptability,na.rm=TRUE) p = p+1 } SEs = data.frame(Aspect = c("Comprehensibility","Acceptability"), V0 = c(sd(subj_mean[1,])/sqrt(nr_subj),sd(subj_mean[5,])/sqrt(nr_subj)), V1 = c(sd(subj_mean[2,])/sqrt(nr_subj),sd(subj_mean[6,])/sqrt(nr_subj)), V2 = c(sd(subj_mean[3,])/sqrt(nr_subj),sd(subj_mean[7,])/sqrt(nr_subj)), V3 = c(sd(subj_mean[4,])/sqrt(nr_subj),sd(subj_mean[8,])/sqrt(nr_subj))) # Turn subject, item and condition numbers into factors ratings$Subject = as.factor(ratings$Subject) ratings$Item = as.factor(ratings$Item) ratings$Condition = as.factor(ratings$Condition) # Turn scores into ordinal variable ratings$Acceptability = ordered(ratings$Acceptability) ratings$Comprehensibility = ordered(ratings$Comprehensibility) # Run ordinal mixed-effects analyses model_acceptability = clmm(Acceptability ~ Condition + (1+Condition|Subject) + (1+Condition|Item), data=ratings) model_comprehensibility = clmm(Comprehensibility ~ Condition + (1+Condition|Subject) + (1+Condition|Item), data=ratings) rm(ratings,subj_id,subj_mean,nr_subj,p,s) save.image('Exp2.RData')