rawdata = read.csv("MY_CBCL.csv") for(i in 1:ncol(rawdata)) { for (j in 1:nrow(rawdata)) { if(grepl("Not True", rawdata[j,i])){ rawdata[j,i] = 0 } if(rawdata[j,i] == "Somewhat/ Sometimes True"){ rawdata[j,i] = 1 } if(rawdata[j,i] == "Very True/Often True"){ rawdata[j,i] = 2 } if (rawdata[j,i] == ""){ rawdata[j,i] = 0 } } } emotionally_reactive = rawdata[,c(1,28,56,62,95,99,100,109,115,117)] anxious_depressed = rawdata[,c(17,43,47,53,58,82,104,107)] somatic_complaints = rawdata[,c(8,14,19,26,31,49,55,63,94,103,111)] withdrawn = rawdata[,c(9,11,30,75,81,84,85,116)] attention_problems = rawdata[,c(1,12,13,68,72,113)] aggressive_behavior = rawdata[,c(15,22,23,25,27,35,37,45,50,52,54,64,71,80,83,98,102,105,114)] internalizing_behaviors = cbind(emotionally_reactive,anxious_depressed,somatic_complaints,withdrawn) internalizing_behaviors$IBscore = NA for (i in 3:nrow(internalizing_behaviors)) { ind_IBscore = 0 for(j in 2:(ncol(internalizing_behaviors)-1)) { ind_IBscore = ind_IBscore + strtoi(internalizing_behaviors[i,j]) } if (i == 6){ internalizing_behaviors[i,38] = ind_IBscore / 35 } else if (i == 17){ internalizing_behaviors[i,38] = ind_IBscore / 32 } else { internalizing_behaviors[i,38] = ind_IBscore / 36 } } externalizing_behaviors = cbind(attention_problems,aggressive_behavior) externalizing_behaviors$EBscore = NA for (i in 3:nrow(externalizing_behaviors)) { ind_EBscore = 0 for(j in 2:(ncol(externalizing_behaviors)-1)) { ind_EBscore = ind_EBscore + strtoi(externalizing_behaviors[i,j]) } if (i == 17){ externalizing_behaviors[i,26] = ind_EBscore / 21 }else{ externalizing_behaviors[i,26] = ind_EBscore / 24 } } rawdata2 = read.csv("lure_discrimination_indices.csv") MST_score = rawdata2[,c(1,72,73,74)] problem_behaviors = cbind(externalizing_behaviors$EBscore,internalizing_behaviors$IBscore) all_scores = cbind(MST_score,problem_behaviors) df2 = all_scores[-4,] male=df2[c(-3,-6,-9,-10,-11,-12,-14,-15,-16,-18,-19),] female=df2[c(-5,-7,-8,-13,-17,-20),] colnames(all_scores) = c("ID","MST","Targets","Foils","EB","IB") MST = dplyr::pull(all_scores, 2) Targets_Hit= dplyr::pull(all_scores, 3) Foils_FA = dplyr::pull(all_scores, 4) EB = dplyr::pull(all_scores, 5) IB = dplyr::pull(all_scores, 6) colnames(df2) = c("ID","MST","Targets","Foils","EB","IB") MST2 = dplyr::pull(df2, 2) Targets_Hit2= dplyr::pull(df2, 3) Foils_FA2 = dplyr::pull(df2, 4) EB2 = dplyr::pull(df2, 5) IB2 = dplyr::pull(df2, 6) MSTf = dplyr::pull(female, 2) MSTm = dplyr::pull(male, 2) Targets_Hitf = dplyr::pull(female, 3) Targets_Hitm = dplyr::pull(male, 3) Foils_FAf = dplyr::pull(female, 4) Foils_FAm = dplyr::pull(male, 4) EBf = dplyr::pull(female, 5) EBm = dplyr::pull(male, 5) IBf = dplyr::pull(female, 6) IBm = dplyr::pull(male, 6) library(psych) library(ggplot2) library(ggthemes) library(rstatix) describe(MST) hist(MST) ggplot(data=all_scores, aes(all_scores$MST)) + geom_histogram() qplot(all_scores$MST, geom="histogram", binwidth=0.1, main="Histogram for MST Scores", xlab="MST Score", fill=I("blue"), col=I("red"), alpha=I(.2), xlim=c(-1.1,1.1)) describe(MST2) ggplot(data=df2, aes(df2$MST)) + geom_histogram() qplot(df2$MST, geom="histogram", binwidth=0.1, main="Histogram for LDI", xlab="LDI", fill=I("blue"), col=I("red"), alpha=I(.2), xlim=c(-1.1,1.1)) describe(MSTf) describe(MSTm) t.test(MSTf,MSTm) describe(Targets_Hit) hist(Targets_Hit) ggplot(data=all_scores, aes(all_scores$Targets)) + geom_histogram() qplot(all_scores$Targets, geom="histogram", binwidth=0.1, main="Histogram for Targets Hit", xlab="Targets Hit", fill=I("blue"), col=I("red"), alpha=I(.2), xlim=c(-0.1,1.1)) describe(Targets_Hit2) ggplot(data=df2, aes(df2$Targets)) + geom_histogram() qplot(df2$Targets, geom="histogram", binwidth=0.1, main="Histogram for Targets Hit", xlab="Targets Hit", fill=I("blue"), col=I("red"), alpha=I(.2), xlim=c(-0.1,1.1)) describe(Targets_Hitf) describe(Targets_Hitm) t.test(Targets_Hitf,Targets_Hitm) describe(Foils_FA) hist(Foils_FA) ggplot(data=all_scores, aes(all_scores$Foils)) + geom_histogram() qplot(all_scores$Foils, geom="histogram", binwidth=0.1, main="Histogram for Foils False Alarms", xlab="Foil FA", fill=I("blue"), col=I("red"), alpha=I(.2), xlim=c(-0.1,1.1)) describe(Foils_FA2) ggplot(data=df2, aes(df2$Foils)) + geom_histogram() qplot(df2$Foils, geom="histogram", binwidth=0.1, main="Histogram for Foils False Alarms", xlab="Foil FA", fill=I("blue"), col=I("red"), alpha=I(.2), xlim=c(-0.1,1.1)) describe(Foils_FAf) describe(Foils_FAm) t.test(Foils_FAf,Foils_FAm) describe(EB) hist(EB) ggplot(data=all_scores, aes(all_scores$EB)) + geom_histogram() qplot(all_scores$EB, geom="histogram", binwidth=0.1, main="Histogram for Externalizing Behavior Scores", xlab="Externalizing Behavior Score", fill=I("blue"), col=I("red"), alpha=I(.2), xlim=c(-0.1,2)) describe(EB2) ggplot(data=df2, aes(df2$EB)) + geom_histogram() qplot(df2$EB, geom="histogram", binwidth=0.1, main="Histogram for EB Scores", xlab="EB Score", fill=I("blue"), col=I("red"), alpha=I(.2), xlim=c(-0.1,2)) describe(EBf) describe(EBm) t.test(EBf,EBm) describe(IB) hist(IB) ggplot(data=all_scores, aes(all_scores$IB)) + geom_histogram() qplot(all_scores$IB, geom="histogram", binwidth=0.1, main="Histogram for IB Score", xlab="IB Score", fill=I("blue"), col=I("red"), alpha=I(.2), xlim=c(-0.1,2)) describe(IB2) ggplot(data=df2, aes(df2$IB)) + geom_histogram() qplot(df2$IB, geom="histogram", binwidth=0.1, main="Histogram for Internalizing Behavior Score", xlab="Internalizing Behavior Score", fill=I("blue"), col=I("red"), alpha=I(.2), xlim=c(-0.1,2)) describe(IBf) describe(IBm) t.test(IBf,IBm) library(ISwR) library(lm.beta) STAT1 = summary(lm(MST~IB, all_scores)) STAT1a = summary(lm(MST~IB, df2)) fit <- lm(MST~IB, df2) confint(fit, 'IB', level=0.95) STATfemale = summary(lm(MST~IB, female)) ggplot(all_scores, aes(x=IB, y=MST))+geom_point(color="paleturquoise3")+geom_smooth(method="lm", color="black")+xlab("Internal Behavior Score")+ylab("MST Score")+ggtitle("Memory and Internal Behavior")+theme(axis.title=element_text(size=10),plot.title=element_text(size=10)) ggplot(df2, aes(x=IB, y=MST))+geom_point(color="paleturquoise3")+geom_smooth(method="lm", color="black")+xlab("Internalizing Behavior Score")+ylab("Lure Discrimination Index")+ggtitle("Memory and Internalizing Behavior")+theme(axis.title=element_text(size=10),plot.title=element_text(size=8)) STAT2 = summary(lm(MST~EB, all_scores)) ggplot(all_scores, aes(x=EB, y=MST))+geom_point(color="paleturquoise3")+geom_smooth(method="lm", color="black")+xlab("External Behavior Score")+ylab("MST Score")+ggtitle("Memory and External Behavior")+theme(axis.title=element_text(size=10),plot.title=element_text(size=10)) STAT2a = summary(lm(MST~EB, df2)) ggplot(df2, aes(x=EB, y=MST))+geom_point(color="paleturquoise3")+geom_smooth(method="lm", color="black")+xlab("Externalizing Behavior Score")+ylab("Lure Discrimination Index")+ggtitle("Memory and Externalizing Behavior")+theme(axis.title=element_text(size=10),plot.title=element_text(size=8)) fit2 <- lm(MST~EB, df2) confint(fit2, 'EB', level=0.95) STAT3 = summary(lm(Targets~IB, all_scores)) ggplot(all_scores, aes(x=IB, y=Targets))+geom_point(color="paleturquoise3")+geom_smooth(method="lm", color="black")+xlab("Internal Behavior Score")+ylab("Targets Hit")+ggtitle("Targets Hit and Internal Behavior")+theme(axis.title=element_text(size=10),plot.title=element_text(size=10)) STAT3a = summary(lm(Targets~IB, df2)) ggplot(df2, aes(x=IB, y=Targets))+geom_point(color="paleturquoise3")+geom_smooth(method="lm", color="black")+xlab("Internalizing Behavior Score")+ylab("Targets Hit")+ggtitle("Targets Hit and Internalizing Behavior")+theme(axis.title=element_text(size=10),plot.title=element_text(size=8)) fit2 <- lm(Targets~IB, df2) confint(fit2, 'IB', level=0.95) STAT4 = summary(lm(Targets~EB, df2)) ggplot(df2, aes(x=EB, y=Targets))+geom_point(color="paleturquoise3")+geom_smooth(method="lm", color="black")+xlab("Externalizing Behavior Score")+ylab("Targets Hit")+ggtitle("Targets Hit and Externalizing Behavior")+theme(axis.title=element_text(size=10),plot.title=element_text(size=8)) fit2 <- lm(Targets~EB, df2) confint(fit2, 'EB', level=0.95) STAT5 = summary(lm(Foils~IB, all_scores)) ggplot(all_scores, aes(x=IB, y=Foils))+geom_point(color="paleturquoise3")+geom_smooth(method="lm", color="black")+xlab("Internal Behavior Score")+ylab("Foil FA")+ggtitle("Foil FA and Internal Behavior")+theme(axis.title=element_text(size=10),plot.title=element_text(size=10)) STAT5a = summary(lm(Foils~IB, df2)) ggplot(df2, aes(x=IB, y=Foils))+geom_point(color="paleturquoise3")+geom_smooth(method="lm", color="black")+xlab("Internalizing Behavior Score")+ylab("Foil FA")+ggtitle("Foil False Alarm and Internalizing Behavior")+theme(axis.title=element_text(size=10),plot.title=element_text(size=8)) fit2 <- lm(Foils~IB, df2) confint(fit2, 'IB', level=0.95) STAT6 = summary(lm(Foils~EB, all_scores)) ggplot(all_scores, aes(x=EB, y=Foils))+geom_point(color="paleturquoise3")+geom_smooth(method="lm", color="black")+xlab("External Behavior Score")+ylab("Foil FA")+ggtitle("Foil FA and External Behavior")+theme(axis.title=element_text(size=10),plot.title=element_text(size=10)) STAT6a = summary(lm(Foils~EB, df2)) fit2 <- lm(Foils~EB, df2) confint(fit2, 'EB', level=0.95)