#load required libraries library(ggplot2) library(lattice) library(stats) library(Matrix) library(car)#used for type III, Anova() library(ca) #correspondence analysis, ca() library(agricolae)#used for HSD.test() library(phia) library(FactoMineR)#multiple correspondence analysis, MCA() library(MASS) library(gdata) #used to rename some variables library(psych) #descriptive stats for table 1 library(plyr) #read in data file prepost.ms1 <- read.csv("manuscript1data.csv", na.strings="") str(prepost.ms1) ############################################################# #paired t-tests for table 1 ############################################################# names(prepost.ms1) table(prepost.ms1$Q2aPre,prepost.ms1$Q3aPre) Q3.pair <- na.omit(prepost.ms1[,c(21,22)]) t.test(Q3.pair$Q3aPre,Q3.pair$Q3aPost,paired=TRUE,alternative="less") describe(Q3.pair) Q4.pair <- na.omit(prepost.ms1[,c(23,24)]) t.test(Q4.pair$Q4aPre,Q4.pair$Q4aPost,paired=TRUE,alternative="less") describe(Q4.pair) Q5a.pair <- na.omit(prepost.ms1[,c(25,26)]) t.test(Q5a.pair$Q5aPre,Q5a.pair$Q5aPost,paired=TRUE,alternative="less") describe(Q5a.pair) Q5b.pair <- na.omit(prepost.ms1[,c(27,28)]) t.test(Q5b.pair$Q5bPre,Q5b.pair$Q5bPost,paired=TRUE,alternative="less") describe(Q5b.pair) Q5c.pair <- na.omit(prepost.ms1[,c(29,30)]) t.test(Q5c.pair$Q5cPre,Q5c.pair$Q5cPost,paired=TRUE,alternative="less") describe(Q5c.pair) Q5d.pair <- na.omit(prepost.ms1[,c(31,32)]) t.test(Q5d.pair$Q5dPre,Q5d.pair$Q5dPost,paired=TRUE,alternative="less") describe(Q5d.pair) Q5e.pair <- na.omit(prepost.ms1[,c(33,34)]) t.test(Q5e.pair$Q5ePre,Q5e.pair$Q5ePost,paired=TRUE,alternative="less") describe(Q5e.pair) Q8.pair <- na.omit(prepost.ms1[,c(35,36)]) t.test(Q8.pair$Q8Pre,Q8.pair$Q8Post,paired=TRUE,alternative="less") describe(Q8.pair) Q10a.pair <- na.omit(prepost.ms1[,c(41,42)]) t.test(Q10a.pair$Q10aPre,Q10a.pair$Q10aPost,paired=TRUE,alternative="less") describe(Q10a.pair) Q10b.pair <- na.omit(prepost.ms1[,c(46,47)]) t.test(Q10b.pair$OldQ10apre,Q10b.pair$OldQ10apost,paired=TRUE,alternative="less") describe(Q10b.pair) ############################################################# #Preparing data for rmANOVAs ############################################################# #make stacked variables for repeated measures anova make.rm<-function(constant,repeated,data,contrasts) { if(!missing(constant) && is.vector(constant)) { if(!missing(repeated) && is.vector(repeated)) { if(!missing(data)) { dd<-dim(data) replen<-length(repeated) if(missing(contrasts)) prepost<- ordered(sapply(paste("T",1:length(repeated),sep=""),rep,dd[1])) else prepost<-matrix(sapply(contrasts,rep,dd[1]),ncol=dim(contrasts)[2]) if(length(constant) == 1) cons.col<-rep(data[,constant],replen) else cons.col<-lapply(data[,constant],rep,replen) new.df<-data.frame(cons.col, repeated.question=as.vector(data.matrix(data[,repeated])), prepost) return(new.df) } } } cat("Usage: make.rm(constant, repeated, data [, contrasts])\n") cat("\tWhere 'constant' is a vector of indices of non-repeated data and\n") cat("\t'repeated' is a vector of indices of the repeated measures data.\n") } sciskill.sub <- na.omit(prepost.ms1[,c(1,2,3,5,7,9,11,13,15,17,19,21,22)]) sciskill<-make.rm(constant=c(1:11), repeated=c(12:13), data=sciskill.sub) confidence.sub <- na.omit(prepost.ms1[,c(1,2,3,5,7,9,11,13,15,17,19,23,24)]) confidence<-make.rm(constant=c(1:11), repeated=c(12:13), data=confidence.sub) inds.rsrch.sub <- na.omit(prepost.ms1[,c(1,2,3,5,7,9,11,13,15,17,19,25,26)]) inds.rsrch<-make.rm(constant=c(1:11), repeated=c(12:13), data=inds.rsrch.sub) mentor.rsrch.sub <- na.omit(prepost.ms1[,c(1,2,3,5,7,9,11,13,15,17,19,27,28)]) mentor.rsrch<-make.rm(constant=c(1:11), repeated=c(12:13), data=mentor.rsrch.sub) analyze.sub <- na.omit(prepost.ms1[,c(1,2,3,5,7,9,11,13,15,17,19,29,30)]) analyze<-make.rm(constant=c(1:11), repeated=c(12:13), data=analyze.sub) writeup.sub <- na.omit(prepost.ms1[,c(1,2,3,5,7,9,11,13,15,17,19,31,32)]) writeup<-make.rm(constant=c(1:11), repeated=c(12:13), data=writeup.sub) present.sub <- na.omit(prepost.ms1[,c(1,2,3,5,7,9,11,13,15,17,19,33,34)]) present<-make.rm(constant=c(1:11), repeated=c(12:13), data=present.sub) goals.sub <- na.omit(prepost.ms1[,c(1,2,3,5,7,9,11,13,15,17,19,35,36)]) goals<-make.rm(constant=c(1:11), repeated=c(12:13), data=goals.sub) enviro.sub <- na.omit(prepost.ms1[,c(1,2,3,5,7,9,11,13,15,17,19,41,42)]) enviro<-make.rm(constant=c(1:11), repeated=c(12:13), data=enviro.sub) STEM.sub <- na.omit(prepost.ms1[,c(1,2,3,5,7,9,11,13,15,17,19,46,47)]) STEM<-make.rm(constant=c(1:11), repeated=c(12:13), data=STEM.sub) #stacked variables for figure 11 sciskill.8sub <- na.omit(prepost.ms1[,c(1,2,35,21,22)]) sciskill8 <-make.rm(constant=c(1:3), repeated=c(4:5), data=sciskill.8sub) confidence.8sub <- na.omit(prepost.ms1[,c(1,2,35,23,24)]) confidence8 <-make.rm(constant=c(1:3), repeated=c(4:5), data=confidence.8sub) inds.rsrch.8sub <- na.omit(prepost.ms1[,c(1,2,35,25,26)]) inds.rsrch8 <-make.rm(constant=c(1:3), repeated=c(4:5), data=inds.rsrch.8sub) mentor.rsrch.8sub <- na.omit(prepost.ms1[,c(1,2,35,27,28)]) mentor.rsrch8 <-make.rm(constant=c(1:3), repeated=c(4:5), data=mentor.rsrch.8sub) analyze.8sub <- na.omit(prepost.ms1[,c(1,2,35,29,30)]) analyze8 <-make.rm(constant=c(1:3), repeated=c(4:5), data=analyze.8sub) writeup.8sub <- na.omit(prepost.ms1[,c(1,2,35,31,32)]) writeup8 <-make.rm(constant=c(1:3), repeated=c(4:5), data=writeup.8sub) present.8sub <- na.omit(prepost.ms1[,c(1,2,35,33,34)]) present8 <-make.rm(constant=c(1:3), repeated=c(4:5), data=present.8sub) ############################################################# #rmANOVA ############################################################# #Multiple Correspondence Analysis used to check for multicolinearity #restructure dataset for MCA survey1 <- prepost.ms1 survey1[c(1:2,4,6,8,10,12,14,16,18,20:55)] <- list(NULL) exp <- na.omit(survey1) exp [,1][exp [,1]==0] <- "No.Lab" exp [,1][exp [,1]==1] <- "Lab" exp [,2][exp [,2]==0] <- "No.Field" exp [,2][exp [,2]==1] <- "Field" exp [,3][exp [,3]==0] <- "No.Team" exp [,3][exp [,3]==1] <- "Team" exp [,4][exp [,4]==0] <- "No.Mentor" exp [,4][exp [,4]==1] <- "Mentor" exp [,5][exp [,5]==0] <- "No.Present" exp [,5][exp [,5]==1] <- "Present" exp [,6][exp [,6]==0] <- "No.Contribute" exp [,6][exp [,6]==1] <- "Contribute" exp [,7][exp [,7]==0] <- "No.Author" exp [,7][exp [,7]==1] <- "Author" exp [,8][exp [,8]==0] <- "No.Intern" exp [,8][exp [,8]==1] <- "Intern" exp [,9][exp [,9]==0] <- "No.Respect" exp [,9][exp [,9]==1] <- "Respect" exp <- as.data.frame(unclass(exp )) str(exp) res.mca = MCA(exp) ####### #Research Skills ####### total.mt.lm <- lm(cbind(sciskill, confidence, indsrsrch, mentorrsrch, analyze, writeup, present, goals) ~ (prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student)), total.mt) summary(total.mt.lm) total.mt.anova <- Anova(total.mt.lm, type="III", singular.ok = T) print(total.mt.anova) #Question 3a - Perception of their scientific skills #model using MiniTab stacking technique, fewer observations sciskill.mt.lm <- lm(repeated.question ~ prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student), sciskill.mt) summary(sciskill.mt.lm) sciskill.mt.anova <- Anova(sciskill.mt.lm, type="III", singular.ok = T) ##this is the exact output that I recieved from MiniTab print(sciskill.mt.anova) #model using revised stacking technique, 48 more observations #This new method will be continued from here on out sciskill.lm <- lm(repeated.question ~ prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student), sciskill) summary(sciskill.lm) sciskill.anova <- Anova(sciskill.lm, type="III", singular.ok = T) print(sciskill.anova) HSD.test(sciskill.lm,"prepost",console=TRUE) HSD.test(sciskill.lm,"as.factor(Q1aPre)",console=TRUE) HSD.test(sciskill.lm,"as.factor(Q2aPre)",console=TRUE) with(sciskill, interaction.plot(prepost, Q1aPre, repeated.question, ylim = c(1, 4), lty = c(1, 3), lwd = 2, ylab = "Scientific skills", xlab = "pre/post", trace.label = "Research Team", )) #Question 4a - Confidence in their scientific skills confidence.lm <- lm(repeated.question ~ Student + prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student), sciskill) confidence.anova <- Anova(confidence.lm, type="III", singular.ok = T) print(confidence.anova) HSD.test(confidence.lm,"prepost",console=TRUE) HSD.test(confidence.lm,"as.factor(Q1aPre)",console=TRUE) HSD.test(confidence.lm,"as.factor(Q2aPre)",console=TRUE) ####### #Interdisciplinary Research ####### #Question 5a - Ability to conduct interdisciplinary research with a resaerch team inds.rsrch.lm <- lm(repeated.question ~ Student + prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student), inds.rsrch) inds.rsrch.anova <- Anova(inds.rsrch.lm, type="III", singular.ok = T) print(inds.rsrch.anova) HSD.test(inds.rsrch.lm,"prepost",console=TRUE) HSD.test(inds.rsrch.lm,"as.factor(Q1aPre)",console=TRUE) HSD.test(inds.rsrch.lm,"as.factor(Q2aPre)",console=TRUE) #Question 5b - Ability to conduct research supervised by a mentor mentor.rsrch.lm <- lm(repeated.question ~ Student + prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student), mentor.rsrch) mentor.rsrch.anova <- Anova(mentor.rsrch.lm, type="III", singular.ok = T) print(mentor.rsrch.anova) HSD.test(mentor.rsrch.lm,"prepost",console=TRUE) HSD.test(mentor.rsrch.lm,"as.factor(Q2aPre)",console=TRUE) ####### #Creating Research Products ####### t.test(prepost.ms1$Q5cPre,prepost.ms1$Q5cPost,paired=TRUE) t.test(analyze.sub$Q5cPre, analyze.sub$Q5cPost, paired=TRUE) #Question 5c - Ability to analyze data analyze.lm <- lm(repeated.question ~ Student + prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student), analyze) analyze.anova <- Anova(analyze.lm, type="III", singular.ok = T) print(analyze.anova) HSD.test(analyze.lm,"as.factor(Q1aPre)",console=TRUE) HSD.test(analyze.lm,"as.factor(Q1cPre)",group=TRUE, console=TRUE) HSD.test(analyze.lm,"as.factor(Q1fPre)",console=TRUE) HSD.test(analyze.lm,"as.factor(Q2aPre)",console=TRUE) #Question 5d - Ability to write-up results writeup.lm <- lm(repeated.question ~ Student + prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student), writeup) writeup.anova <- Anova(writeup.lm, type="III", singular.ok = T) print(writeup.anova) HSD.test(writeup.lm,"as.factor(Q1aPre)",console=TRUE) HSD.test(writeup.lm,"as.factor(Q1fPre)",console=TRUE) #Question 5e - Ability to present results present.lm <- lm(repeated.question ~ Student + prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student), present) present.anova <- Anova(present.lm, type="III", singular.ok = T) print(present.anova) HSD.test(present.lm,"prepost",console=TRUE) HSD.test(present.lm,"as.factor(Q1ePre)",console=TRUE) HSD.test(present.lm,"as.factor(Q1fPre)",console=TRUE) HSD.test(present.lm,"as.factor(Q2aPre)",console=TRUE) ####### #Persistance in science ####### #Question 3a - Perception of their scientific skills sciskill.8.lm <- lm(repeated.question ~ Student + prepost + as.factor(Q8aPre) + prepost*as.factor(Q8aPre) +(1|Student), sciskill8) sciskill.8.anova <- Anova(sciskill.8.lm, type="III", singular.ok = T) print(sciskill.8.anova) HSD.test(sciskill.8.lm,"prepost",console=TRUE) HSD.test(sciskill.8.lm,"as.factor(Q8aPre)",console=TRUE) with(sciskill8, interaction.plot(prepost, as.factor(Q8aPre), repeated.question, ylim = c(1, 4), lty = c(1,2,3), lwd = 2, ylab = "Scientific skills", xlab = "pre/post", trace.label = "Clarity", )) #Question 4a - Confidence in their scientific skills confidence.8.lm <- lm(repeated.question ~ Student + prepost + Q8aPre + prepost*Q8aPre +(1|Student), confidence8) confidence.8.anova <- Anova(confidence.8.lm, type="III", singular.ok = T) print(confidence.8.anova) HSD.test(confidence.8.lm,"prepost",console=TRUE) HSD.test(confidence.8.lm,"Q8aPre",console=TRUE) #Interaction plot with(confidence8, interaction.plot(prepost, Q8aPre, repeated.question, ylim = c(1, 4), lty = c(1,2,3), lwd = 2, ylab = "Confidence in skills", xlab = "pre/post", trace.label = "Clarity", )) #Question 5a - Ability to conduct interdisciplinary research with a resaerch team inds.rsrch.8.lm <- lm(repeated.question ~ Student + prepost + Q8aPre + prepost*Q8aPre +(1|Student), inds.rsrch8) inds.rsrch.8.anova <- Anova(inds.rsrch.8.lm, type="III", singular.ok = T) print(inds.rsrch.8.anova) #Question 5b - Ability to conduct research supervised by a mentor mentor.rsrch.8.lm <- lm(repeated.question ~ Student + prepost + Q8aPre + prepost*Q8aPre +(1|Student), mentor.rsrch8) mentor.rsrch.8.anova <- Anova(mentor.rsrch.8.lm, type="III", singular.ok = T) print(mentor.rsrch.8.anova) HSD.test(mentor.rsrch.8.lm,"prepost",console=TRUE) #Question 5c - Ability to analyze data analyze.8.lm <- lm(repeated.question ~ Student + prepost + Q8aPre + prepost*Q8aPre +(1|Student), analyze8) analyze.8.anova <- Anova(analyze.8.lm, type="III", singular.ok = T) print(analyze.8.anova) HSD.test(analyze.8.lm,"prepost",console=TRUE) HSD.test(analyze.8.lm,"Q8aPre",console=TRUE) #Question 5d - Ability to write-up results writeup.8.lm <- lm(repeated.question ~ Student + prepost + Q8aPre + prepost*Q8aPre +(1|Student), writeup8) writeup.8.anova <- Anova(writeup.8.lm, type="III", singular.ok = T) print(writeup.8.anova) HSD.test(writeup.8.lm,"prepost",console=TRUE) HSD.test(writeup.8.lm,"Q8aPre",console=TRUE) #Interaction plot with(writeup8, interaction.plot(prepost, Q8aPre, repeated.question, ylim = c(1, 5), lty = c(1,2,3), lwd = 2, ylab = "Write-Up Scientific Results", xlab = "pre/post", trace.label = "Clarity", )) #Question 5e - Ability to present results present.8.lm <- lm(repeated.question ~ Student + prepost + as.factor(Q8aPre) + prepost*as.factor(Q8aPre) +(1|Student), present8) present.8.anova <- Anova(present.8.lm, type="III", singular.ok = T) print(present.8.anova) HSD.test(present.8.lm,"prepost",console=TRUE) HSD.test(present.8.lm,"as.factor(Q8aPre)",console=TRUE) with(writeup8, interaction.plot(prepost, as.factor(Q8aPre), repeated.question, ylim = c(1, 5), lty = c(1,2,3), lwd = 2, ylab = "Write-Up Scientific Results", xlab = "pre/post", trace.label = "Clarity", )) enviro.lm <- lm(repeated.question ~ Student + prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student), enviro) enviro.anova <- Anova(enviro.lm, type="III", singular.ok = T) print(enviro.anova) HSD.test(enviro.lm,"as.factor(Q1bPre)",console=TRUE) STEM.lm <- lm(repeated.question ~ Student + prepost + as.factor(Q1aPre) + as.factor(Q1bPre) + as.factor(Q1cPre) + as.factor(Q1dPre) + as.factor(Q1ePre) + as.factor(Q1fPre) + as.factor(Q1gPre) + as.factor(Q1hPre) + as.factor(Q2aPre) + as.factor(prepost)*as.factor(Q1aPre) + as.factor(prepost)*as.factor(Q1bPre) + as.factor(prepost)*as.factor(Q1cPre) + as.factor(prepost)*as.factor(Q1dPre) + as.factor(prepost)*as.factor(Q1ePre) + as.factor(prepost)*as.factor(Q1fPre) + as.factor(prepost)*as.factor(Q1gPre) + as.factor(prepost)*as.factor(Q1hPre) + as.factor(prepost)*as.factor(Q2aPre) + (1|Student), STEM) STEM.anova <- Anova(STEM.lm, type="III", singular.ok = T) print(STEM.anova) with(STEM, interaction.plot(STEM, as.factor(Q5dPre), repeated.question, ylim = c(1, 5), lty = c(1,2,3), lwd = 2, ylab = "STEM Research Field", xlab = "pre/post", trace.label = "Liklihood", )) Q10a.pair <- na.omit(prepost.ms1[,c(41,42,5)]) Q10a.field <- Q10a.pair[Q10a.pair$Q1bPre %in% 1,] Q10a.nofield <- Q10a.pair[Q10a.pair$Q1bPre %in% 0,] t.test(Q10a.field$Q10aPre,Q10a.field$Q10aPost,paired=TRUE,alternative="less") describe(Q10a.field) t.test(Q10a.nofield$Q10aPre,Q10a.nofield$Q10aPost,paired=TRUE,alternative="less") describe(Q10a.nofield) Q10b.pair <- na.omit(prepost.ms1[,c(46,47)]) t.test(Q10b.pair$OldQ10apre,Q10b.pair$OldQ10apost,paired=TRUE,alternative="less") describe(Q10b.pair) ############################################################# #Correspondence Analysis - Long term career plans ############################################################# names(prepost.ms1) summary(Q9) str(Q9) Q9 <- droplevels(na.omit(prepost.ms1[38:39])) mytable <- table(Q9$Q9aPre,Q9$Q9aPost) # create a 2 way table prop.table(mytable, 1) # row percentages prop.table(mytable, 2) # column percentages fit <- ca(mytable) print(fit) # basic results summary(fit) # extended results plot(fit, mass = TRUE, contrib = "absolute", map = "rowgreen", arrows = c(FALSE, TRUE)) # asymmetric map plot(fit, xlab="Profession (39.8%)", ylab="Career path directly after graduation (27.9%)" ,mass=TRUE) # symmetric map - we are interested in this plot over the asymentrical