setwd("file location") Michelle=read.csv("ZL.Michelle.AllRatings.csv") Michelle2=read.csv("ZM.Michelle.AllRatings2.csv") Grace=read.csv("ZL.Grace.AllRatings.csv") Neal=read.csv("ZL.Neal.AllRatings.csv") Emily=read.csv("ZM.Emily.AllRatings.csv") Emily2=read.csv("ZN.Emily.AllRatings2.csv") Kristen=read.csv("ZM.Kristen.AllRatings.csv") Kristen2=read.csv("ZN.Kristen.AllRatings2.csv") Kristen3=read.csv("ZP.Kristen.AllRatings3.csv") Ashley=read.csv("ZN.Ashley.AllRatings.csv") Ashley2=read.csv("ZP.Ashley.AllRatings2.csv") bind1=rbind(Michelle, Michelle2) bind2=rbind(bind1,Grace) bind3=rbind(bind2,Neal) bind4=rbind(bind3,Emily) bind5=rbind(bind4,Emily2) bind6=rbind(bind5,Kristen) bind7=rbind(bind6,Kristen2) bind8=rbind(bind7,Kristen3) bind9=rbind(bind8,Ashley) bind10=rbind(bind9,Ashley2) rawdata=bind10 num_observations <- as.data.frame(table(rawdata$Monkey_ID)) names(num_observations)[1] <- "Monkey_ID" icc <- merge(rawdata,num_observations,by="Monkey_ID") names(icc) items=c(names(icc[9:62])) source('file location', chdir = TRUE) iccresults=icc3.reliability(icc[icc$Freq!=1,], items, "Monkey_ID", "Rater_Name") sd(iccresults$icc3k) range(icc$Freq) attach(rawdata) agg=aggregate(rawdata, by=list(Monkey_ID), FUN = mean, na.rm = TRUE) detach(rawdata) aggitems=c(names(agg[c(10:43,45:63)])) library(psych) library(paran) persitems=c(names(rawdata[c(9:42,44:60,62)])) fa.parallel(rawdata[persitems],n.obs=NULL,fm="minres",fa="both",main="Parallel Analysis Scree Plots", n.iter=20,error.bars=FALSE,se.bars=FALSE,SMC=FALSE,ylabel=NULL,show.legend=TRUE, sim=TRUE,quant=.95,cor="cor",use="pairwise",plot=TRUE,correct=.5) pc_4_varimax <- principal(rawdata[persitems], nfactors=4, rotate = "varimax") print(pc_4_varimax, sort=T) pc_4_promax <- principal(rawdata[persitems], nfactors=4, rotate = "promax") print(pc_4_promax, sort=T) pc_5_varimax <- principal(rawdata[persitems], nfactors=5, rotate = "varimax") print(pc_5_varimax, sort=T) pc_5_promax <- principal(rawdata[persitems], nfactors=5, rotate = "promax") print(pc_5_promax, sort=T) pc_6_varimax <- principal(rawdata[persitems], nfactors=6, rotate = "varimax") print(pc_6_varimax, sort=T) pc_6_promax <- principal(rawdata[persitems], nfactors=6, rotate = "promax") print(pc_6_promax, sort=T) library("GPArotation") #Comparison with FA fa_5_varimax=fa(rawdata[persitems],nfactors = 5,rotate = "varimax") print(fa_5_varimax, sort=T) factor.congruence(fa_5_varimax, pc_5_varimax) SWBitems=c(names(rawdata[c(5:8)])) iccswbresults=icc3.reliability(icc[icc$Freq!=1,], SWBitems, "Monkey_ID", "Rater_Name") sd(iccswbresults$icc3k) fa.parallel(rawdata[SWBitems],n.obs=NULL,fm="minres",fa="both",main="Parallel Analysis Scree Plots", n.iter=20,error.bars=FALSE,se.bars=FALSE,SMC=FALSE,ylabel=NULL,show.legend=TRUE, sim=TRUE,quant=.95,cor="cor",use="pairwise",plot=TRUE,correct=.5) swbstructure <- principal(rawdata[SWBitems], nfactors=1, rotate = "none") print(swbstructure, sort=T) Infant=agg attach(agg) Infant$Openness4=(Curious + Inquisitive +Active +Impulsive +Playful +Reckless +Distractible +Thoughtless +Disorganized + Inventive +Persistent +Innovative +Individualistic -Timid -Cautious -Lazy -Fearful -Depressed -Sensitive +48)/19 Infant$Assertiveness4=(Aggressive +Bullying +Dominant +Defiant +Stingy +Manipulative +Jealous +Irritable -Gentle -Submissive +16)/10 Infant$Anxiety4= (Excitable +Anxious +Autistic +Vulnerable +Erratic -Cool -Stable -Decisive -Intelligent -Unemotional +40)/10 Infant$Friendliness4=(Affectionate +Helpful +Sympathetic +Protective +Sociable +Friendly +Dependent -Independent -Solitary +16)/9 Infant$Openness5= (Curious + Active + Inquisitive +Playful +Impulsive +Reckless +Distractible +Innovative +Inventive +Thoughtless +Persistent +Individualistic -Lazy -Depressed -Timid -Cautious +32)/16 Infant$Assertiveness5=(Aggressive +Bullying +Dominant +Defiant +Stingy +Manipulative +Jealous +Irritable -Gentle -Submissive +16)/10 Infant$Anxiety5=( Anxious + Fearful + Excitable + Autistic +Vulnerable -Cool -Stable -Unemotional +24)/8 Infant$Friendliness5=(Affectionate +Helpful +Sympathetic +Protective +Sociable +Dependent +Friendly -Independent -Solitary +16)/9 Infant$Intellect5=(Decisive +Intelligent +Predictable -Disorganized -Clumsy -Erratic + 24)/6 Infant$Openness6=(Active +Curious +Inquisitive +Playful +Impulsive +Distractible +Reckless +Thoughtless +Disorganized +Inventive +Persistent +Individualistic -Lazy -Depressed -Timid -Cautious -Solitary -Sensitive +48)/18 Infant$Assertiveness6=(Aggressive +Bullying +Dominant +Stingy +Defiant +Manipulative +Jealous +Irritable -Gentle -Submissive +16)/10 Infant$Anxiety6=(Anxious +Excitable +Fearful +Autistic +Vulnerable -Cool -Stable -Unemotional +24)/8 Infant$Friendliness6=(Affectionate +Helpful +Sympathetic +Protective +Sociable +Dependent +Friendly -Independent +8)/8 Infant$Predictability6=(Predictable -Erratic -Clumsy +16)/3 Infant$Intellect6=(Intelligent +Decisive +Innovative -Quitting +8)/4 Infant$Confidence6A=(Stable -Fearful -Submissive -Timid -Cautious -Distractible -Disorganized -Dependent -Vulnerable +64)/9 Infant$Openness6A=(Inquisitive +Thoughtless +Innovative +Inventive +Curious +Impulsive)/6 Infant$Dominance6A=(Bullying +Stingy +Aggressive +Irritable +Manipulative +Defiant +Excitable +Reckless +Dominant +Independent +Individualistic -Gentle +8)/12 Infant$Friendliness6A=(Helpful +Friendly +Affectionate +Sociable +Sensitive +Protective +Sympathetic +Intelligent +Persistent +Decisive -Depressed -Solitary +16)/12 Infant$Activity6A=(Active +Playful -Conventional -Predictable -Lazy -Clumsy +32)/6 Infant$Anxious6A=(Quitting +Anxious +Erratic +Jealous -Cool -Unemotional +16)/6 Infant$SWBScore=(Well.Being1 +Well.Being2 +Well.Being3 +Well.Being4)/4 detach(agg) personalitycorr=corr.test(Infant[64:78],Infant[79:84], method= "pearson") personalitycorr$ci swbcorr=corr.test(Infant[64:84],Infant[85], method= "pearson") swbcorr$ci ###Interrater reliability of five component structure components=rawdata attach(components) components$Openness5= (Curious + Active + Inquisitive +Playful +Impulsive +Reckless +Distractible +Innovative +Inventive +Thoughtless +Persistent +Individualistic -Lazy -Depressed -Timid -Cautious +32)/16 components$Assertiveness5=(Aggressive +Bullying +Dominant +Defiant +Stingy +Manipulative +Jealous +Irritable -Gentle -Submissive +16)/10 components$Anxiety5=( Anxious + Fearful + Excitable + Autistic +Vulnerable -Cool -Stable -Unemotional +24)/8 components$Friendliness5=(Affectionate +Helpful +Sympathetic +Protective +Sociable +Dependent +Friendly -Independent -Solitary +16)/9 components$Intellect5=(Decisive +Intelligent +Predictable -Disorganized -Clumsy -Erratic + 24)/6 detach(components) num_observationsCom <- as.data.frame(table(components$Monkey_ID)) names(num_observationsCom)[1] <- "Monkey_ID" iccCom <- merge(components,num_observationsCom,by="Monkey_ID") names(iccCom) items=c(names(icc[63:67])) source('file location', chdir = TRUE) iccresultsCom=icc3.reliability(iccCom[iccCom$Freq!=1,], items, "Monkey_ID", "Rater_Name") mean(iccresultsCom$icc31) sd(iccresultsCom$icc31) range(iccresultsCom$icc3k)