CAT_Test <- read.delim("Data/CAT_Test.txt")
#Condition
CAT_Test$Condition <- as.factor(CAT_Test$Condition)
contrast <- cbind(c(+0.5, -0.5)) # Condition 1, Condition 2
colnames (contrast) <- c("-Condition2+Condition1")
contrasts (CAT_Test$Condition) <- contrast
contrasts(CAT_Test$Condition)
## -Condition2+Condition1
## Condition 1 0.5
## Condition 2 -0.5
#Group
CAT_Test$Group <- as.factor(CAT_Test$Group)
contrast <- cbind(c(-0.5, +0.5)) # DLD, TD
colnames (contrast) <- c("-DLD+TD")
contrasts (CAT_Test$Group) <- contrast
contrasts(CAT_Test$Group)
## -DLD+TD
## DLD -0.5
## TD 0.5
#Age
CAT_Test$Age_months <- scale(CAT_Test["Age_months"],center=T,scale=F)
CAT_Test$Odds[CAT_Test$Item%in% c(1,3,5,7)] <- T
CAT_Test$Odds[CAT_Test$Item%in% c(2,4,6,8)] <- F
CAT_Test.odds <- subset(CAT_Test, Odds==T)
CAT_Test.even <- subset(CAT_Test, Odds==F)
Run two separate models with odd and even test items
model.odds <- glmer(AnswerStimD2~Condition*Group*Age_months+(1|Subject), data=CAT_Test.odds, family = binomial, control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e5)))
model.even <- glmer(AnswerStimD2~Condition*Group*Age_months+(1|Subject), data=CAT_Test.even, family = binomial,
control=glmerControl(optimizer="bobyqa", optCtrl=list(maxfun=2e5)))
ranef.odds <- as.data.frame(ranef(model.odds))
ranef.odds <- subset(ranef.odds,term == "(Intercept)")
ranef.odds <- ranef.odds[3:4]
colnames(ranef.odds) <- c("Subject", "AnswerD2_Odds")
ranef.even <- as.data.frame(ranef(model.even))
ranef.even <- subset(ranef.even,term == "(Intercept)")
ranef.even <- ranef.even[3:4]
colnames(ranef.even) <- c("Subject", "AnswerD2_Even")
splithalf <- merge(ranef.odds, ranef.even, by = c("Subject"))
rm(ranef.even)
rm(ranef.odds)
#Uncorrected correlation
cor.uncorrected <- cor.test(splithalf$AnswerD2_Odds, splithalf$AnswerD2_Even, method = "pearson")
cor.uncorrected
##
## Pearson's product-moment correlation
##
## data: splithalf$AnswerD2_Odds and splithalf$AnswerD2_Even
## t = 4.8233, df = 48, p-value = 1.468e-05
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.3484215 0.7331138
## sample estimates:
## cor
## 0.5713576
#Spearman-Brown corrected correlation
reliability <- (2 * cor.uncorrected$estimate) / (1 + cor.uncorrected$estimate)
reliability
## cor
## 0.7272153
#Confidence interval
reliability.CI <- (2 * cor.uncorrected$conf.int) / (1 + cor.uncorrected$conf.int)
reliability.CI
## [1] 0.5167842 0.8460077
## attr(,"conf.level")
## [1] 0.95
Split-half reliability: 0.73 [CI: 0.52 … 0.85]
plot(splithalf$AnswerD2_Odds~splithalf$AnswerD2_Even)
abline(lm(splithalf$AnswerD2_Odds~splithalf$AnswerD2_Even))