anova(md) anova(mds) anova(msd) library(car) Anova(mds) drop1(mds,test="F") tg1 <- aov(len~supp+as.factor(dose),data=ToothGrowth) summary(tg1) Anova(tg1) tg2 <- aov(len~supp*as.factor(dose),data=ToothGrowth) tg2 <- aov(len~supp + as.factor(dose) + supp:as.factor(dose),data=ToothGrowth) tg2 summary(tg2) Anova(tg2) tg3 <- aov(len~supp:as.factor(dose),data=ToothGrowth) tg33 tg3 summary(tg3) Anova(tg3) anova(tg3,tg2) ##we can obtain complete tables of means. This gives the relative effects: model.tables(tg2) model.tables(tg3) ##this gives the absolute mean values model.tables(tg2,type="means") model.tables(tg3,type="means") ?Anova tg3 <- aov(len~supp:as.factor(dose),data=ToothGrowth) Anova(tg3) Anova(tg2) ##this gives the absolute mean values model.tables(tg2,type="means") model.tables(tg2) setwd("~/Dropbox/courses/5210-2020/web-5210/psy5210/Projects/Chapter19") ##Exercise Solution dat.raw <- read.table("tsp-all.txt",header=T) dat <- dat.raw[ dat.raw$subnum !="B1"&dat.raw$cycle>0,] dat$cycle <- as.factor(dat$cycle) contrasts(dat$cycle) <- contr.poly(levels(dat$cycle)) dat$mopp <- as.factor(dat$mopp) tab1 <- tapply(dat$eff,list(size=dat$numpos,cycle=dat$cycle),mean) matplot(c(10,20,30),tab1,type="o",pch=c(1:4),xlab="Problem size",ylab="Efficiency") legend(25,1.08,paste("Cycle", 1:4),lty=1:4,pch=1:4,col=1:4) matplot(c(10,20,30),tab1,type="o",pch=c(1:4),xlab="Problem size",ylab="Efficiency",lwd=2) legend(25,1.08,paste("Cycle", 1:4),lty=1:4,pch=1:4,col=1:4) ##Build and test the ANCOVA models: tsp0 <- aov(eff~numpos,data=dat) tsp1 <- aov(eff~numpos+cycle,data=dat) tsp2 <- aov(eff~numpos*cycle,data=dat) tsp3 <- aov(eff~test+subnum+cycle+(mopp),data=dat) Anova(tsp3) Anova(tsp1) Anova(tsp2, type="II") #test the interaction Anova(tsp2,type="III") #test the interaction ##These don't differ: Anova(tsp1, type="II") #test the interaction Anova(tsp1,type="III") #test the interaction ##what about post-hoc tests: TukeyHSD(tsp3,which="cycle") ##won't work! #look at cycle in each case TukeyHSD(tsp1,which="cycle") TukeyHSD(tsp2,which="cycle") TukeyHSD(tsp3,which="cycle") library(sjstats) anova_stats(tsp1) ?anova_stats anova_stats(tsp2) ##Exercise Solution dat.raw <- read.table("tsp-all.txt",header=T) dat <- dat.raw[ dat.raw$subnum !="B1"&dat.raw$cycle>0,] dat$cycle <- as.factor(dat$cycle) contrasts(dat$cycle) <- contr.poly(levels(dat$cycle)) dat$mopp <- as.factor(dat$mopp) tab1 <- tapply(dat$eff,list(size=dat$numpos,cycle=dat$cycle),mean) matplot(c(10,20,30),tab1,type="o",pch=c(1:4),xlab="Problem size",ylab="Efficiency",lwd=2) legend(25,1.08,paste("Cycle", 1:4),lty=1:4,pch=1:4,col=1:4) tab1 dat[1:5,] tsp1 tsp2 <- aov(eff~numpos*cycle,data=dat) ##interaction tsp3 <- aov(eff~test+subnum+cycle+(mopp),data=dat) ##MOPP is the thing we really care about tsp3 summary(tsp3) Anova(tsp3) dat$cycle table(dat$cycle,dat$test) Anova(tsp3) tsp3b <- aov(eff~test+subnum+(mopp)+ mopp:numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsb3b) Anova(tsp3b) tsp3b <- aov(eff~subnum+(mopp)+ cycle+ mopp:numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp3b) tsp4a <- aov(eff~subnum+(mopp)+ cycle+ numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4a) tsp4a <- aov(eff~subnum+(mopp)+ cycle,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4a) tsp4a <- aov(eff~subnum+(mopp)+ cycle+ numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4b) tsp4b <- aov(eff~subnum+(mopp)+ cycle+ numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4b) tsp4a <- aov(eff~subnum+(mopp)+ cycle,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4a) tsp4b <- aov(eff~subnum+(mopp)+ cycle+ numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4b) Anova(tsp4a,tsp4b) anova(tsp4a,tsp4b) Anova(tsp4b) ##Is the numpos covariate significant? anova(tsp4a,tsp4b) Anova(tsb4b,type="III") Anova(tsp4b,type="III") Anova(tsp4b) Anova(tsp4b,type="III") Anova(tsp2, type="II") #test the interaction Anova(tsp2,type="III") #test the interaction Anova(tsp4b,type="II") Anova(tsp4b,type="III") Anova(tsp1) Anova(tsp2, type="II") #test the interaction Anova(tsp2,type="III") #test the interaction Anova(tsp1) ##These don't differ: Anova(tsp1, type="II") #test the interaction Anova(tsp1,type="III") #test the interaction Anova(tsp2, type="II") #test the interaction Anova(tsp2,type="III") #test the interaction tsp3 <- aov(eff~test+subnum+cycle+(mopp),data=dat) ##MOPP is the thing we really care about ##subnum is a factor accounting for consistency within people (repeated measures) ## Although this is not exactly the right way to hand that predictor. ## test is the problem number, sort of like subnum. ##cycle and test were confounded intentionally, so adding cycle won't do anything table(dat$cycle,dat$test) Anova(tsp3) tsp3 <- aov(eff~test+subnum+cycle+(mopp),data=dat) ##MOPP is the thing we really care about ##subnum is a factor accounting for consistency within people (repeated measures) ## Although this is not exactly the right way to hand that predictor. ## test is the problem number, sort of like subnum. ##cycle and test were confounded intentionally, so adding cycle won't do anything table(dat$cycle,dat$test) Anova(tsp3) tsp4a <- aov(eff~subnum+(mopp)+ cycle,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4a) #Here we add problem size as an independent covariate: tsp4b <- aov(eff~subnum+(mopp)+ cycle+ numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate ##Is the numpos covariate significant? Comparing type-II and type-III, the main effects actually have the same values anova(tsp4a,tsp4b) Anova(tsp4b,type="II") Anova(tsp4b,type="III") tsp4c <- aov(eff~subnum+(mopp)+ cycle+ mopp:numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4c) anova(tsp4c,tsp4b) tsp4b <- aov(eff~subnum+(mopp)+ cycle+ numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate ##Is the numpos covariate significant? Comparing type-II and type-III, the main effects actually have the same values anova(tsp4a,tsp4b) Anova(tsp4b,type="II") Anova(tsp4b,type="III") ## Problem size is significant, and so are the other main effects (and these no longer depend on type-II vs. type-III) ## #What if we added an interaction term? tsp4c <- aov(eff~subnum+(mopp)+ cycle+ mopp:numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4c) anova(tsp4c,tsp4b) Anova(tsp4c,type="I") Anova(tsp4c,type="II") Anova(tsp4c,type="III") anova(tsp4c,tsp4b) tsp4c <- aov(eff~subnum+(mopp)+ cycle+ +numpos+ mopp:numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4c,type="II") Anova(tsp4c,type="III") tsp4c <- aov(eff~subnum+(mopp)+ cycle+ numpos*mopp,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4c,type="II") Anova(tsp4c,type="III") anova(tsp4c,tsp4b) ##what about post-hoc tests: TukeyHSD(tsp3,which="cycle") ##won't work! #look at cycle in each case TukeyHSD(tsp1,which="cycle") TukeyHSD(tsp2,which="cycle") TukeyHSD(tsp2,which="cycle") TukeyHSD(tsp2,which="cycle") #ditto TukeyHSD(tsp3,which="cycle") tsp3 summary(tsp3) library(sjstats) anova_stats(tsp1) anova_stats(tsp3) knitr::opts_chunk$set(echo = TRUE) data <- read.csv("spokenduration.csv") data$length <- as.factor(rowSums(data[,2:12])) setwd("~/Dropbox/courses/5210-2020/problemsets/ps11") knitr::opts_chunk$set(echo = TRUE) data <- read.csv("spokenduration.csv") data$length <- as.factor(rowSums(data[,2:12])) data[1:5,] m1 <- aov(time~length,data=data) l1 <- lm(time~length,data=data) summary(m1) summary(l1) sjstats::anova_stats(m1) sjstats::anova_stats(l1) m1 <- aov(time~length,data=data) l1 <- lm(time~length,data=data) summary(m1) summary(l1) library(agricolae) HSD.test(m1,trt="length",group=T,console=T) library(sjstats) sjstats::anova_stats(m1) sjstats::anova_stats(l1) eta_sq(m1) omega_sq(m1,partial=F) anova(l1,m1) l2 <- lm(time~as.numeric(length),data=data) anova(l1,m2) l2 <- lm(time~as.numeric(length),data=data) anova(l1,l2) dat[1:5,] data[1:5,] m2a <- lm(time~cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal,data=data) m2a <- lm(time~cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal + as.numeric(length),data=data) m2a m2a <- lm(time~(cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal)* as.numeric(length),data=data) m2b <- lm(time~(cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal)* as.numeric(length),data=data) m2a <- lm(time~cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal,data=data) m2b <- lm(time~(cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal)* as.numeric(length),data=data) m2b m2b <- lm(time~(cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal):as.numeric(length),data=data) m2b m2b <- lm(time~as.numeric(length) +(cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal):as.numeric(length),data=data) m2b summary(m2b) m2b <- lm(time~(cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal):as.numeric(length),data=data) summary(m2b) anova(m2a,m2b) anova(m2a,m2b,test="F") m2b <- lm(time~(cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal)*as.numeric(length),data=data) anova(m2a,m2b,test="F") lm(time~length*cult,data=data) summary(lm(time~length*cult,data=data)) summary(lm(time~length*dare,data=data)) summary(lm(time~length*hint,data=data)) summary(lm(time~length*hint*cult,data=data)) summary(lm(time~length*zeal,data=data)) summary(lm(time~length*truth,data=data)) summary(lm(time~length*verb,data=data)) data <- read.csv("spokenduration.csv") data$length <- rowSums(data[,2:12]) data$lengthC <- as.factor(rowSums(data[,2:12])) m1 <- aov(time~lengthC,data=data) l1 <- lm(time~lengthC,data=data) summary(m1) summary(l1) l2 <- lm(time~length,data=data) anova(l1,l2) ##there is no difference between these, so we would probably prefer the smaller model treating length as a numeric library(agricolae) HSD.test(m1,trt="lengthC",group=T,console=T) library(sjstats) sjstats::anova_stats(m1) sjstats::anova_stats(l1) eta_sq(m1) omega_sq(m1,partial=F) contrasts(data$lengthC) <- contr.sum(levels(data$lengthC)) lm(time~lengthC,data=data) lm2a <- lm(time~lengthC,data=data) #contrasts(data$lengthC) <- contr.sum(levels(data$lengthC)) lm2a <- lm(time~cult+dare+fate+guess+hint+mood+oath+plea=rush+verb+zeal,data=data) #contrasts(data$lengthC) <- contr.sum(levels(data$lengthC)) lm2a <- lm(time~cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal,data=data) lm2a <- lm(time~cult+dare+fate+guess+hint+mood+oath+plea+rush+verb+zeal+0,data=data) lm2a barplot(lm2a$coefficients) barplot(lm2a$coefficients,ylab="Duration per word (s)") m2a <- lm(time~verb,data=data) m2a summary(m2a) data.verb <- data[data$verb,] m3a <- lm(time~verb,data=data.verb) m3a <- lm(time~verb*length,data=data) m3b <- lm(time~verb*length,data=data) summary(m3a) m3b data.verb$length <- contr.poly(data.verb$length) m3a <- lm(time~verb,data=data.verb) m3b <- lm(time~verb*length,data=data) anova(m3a,m3b) summar(m3a) summary(m3a) summary(m3b) data$length <- contr.poly(data$length) data$length <- contr.poly(data$length) data$lengthC <- contr.poly(data$lengthC) data$lengthC data$lengthC <- contr.poly(levels(data$lengthC)) contrasts(data$lengthC) <- contr.poly(levels(data$lengthC)) m3a <- lm(time~verb,data=data.verb) m3b <- lm(time~verb*length,data=data) anova(m3a,m3b) m3a <- lm(time~verb,data=data) m3b <- lm(time~verb*length,data=data) anova(m3a,m3b) summary(m3b) m3a <- lm(time~verb+length,data=data) m3b <- lm(time~verb*length,data=data) summary(m3b) anova(m3a,m3b) m3a summary(m3a) anova(m3a) summary(m3b) library(car) contrasts(data$subject) <- contr.sum(levels(data$subject)) data$subject contrasts(data$subject) <- contr.sum(levels(as.factor(data$subject))) data$subject <- factor(data$subject, contrasts= contr.sum(levels(as.factor(data$subject)))) contrasts(data$subject) <- contr.sum(levels(as.factor(data$subject)))) data$subject <- factor(data$subject) contrasts(data$subject) <- contr.sum(levels(as.factor(data$subject))) m2 <- aov(time~length+subject,data=data) Anova(m2) model.tables(m2) model.tables(m2) m2 <- aov(time~lengthC+subject,data=data) Anova(m2) model.tables(m2) library(car) data$subject <- factor(data$subject) contrasts(data$subject) <- contr.sum(levels(as.factor(data$subject))) m2 <- aov(time~lengthC+subject,data=data) Anova(m2) model.tables(m2) eta_sq(m2) omega_sq(m2,partial=F) TukeyHSD(m2) anova_stats(m2) l3 <- lm(time~lengthC*subject,data=data) m3 <- aov(time~lengthC*subject,data=data) sjstats::anova_stats(m3) Anova(l3) summary(l3) TukeyHSD(m3) options(max.print=500) tapply(data$time[data$length==6],list(data$subject[data$length==6]),mean) ?TukeyHSD TukeyHSD(m3,ordered=F,which="subject:lengthC") HSD.test(m3,console=T,group=T) data[1:5,] TukeyHSD(m3,ordered=F) HSD.test(m3,"console=T,group=T) HSD.test(m3,"",console=T,group=T) ) ) )" HSD.test(m3,"",console=T,group=T) HSD.test(m3,"lengthC:subject",console=T,group=T) HSD.test(m3,"lengthC",console=T,group=T) TukeyHSD(m3,which="lengthC:subject",ordered=F) tuk <- TukeyHSD(m3,which="lengthC:subject",ordered=F) options(max.print=500) tuk tuk$`lengthC:subject`[1,] rowNames(tuk$`lengthC:subject`) rownames(tuk$`lengthC:subject`) keep <- substr(rownames(tuk$`lengthC:subject`),1,1)="6" tuk[keep,] keep <- substr(rownames(tuk$`lengthC:subject`),1,1)=="6" tuk[keep,] tuk$`lengthC:subject`[keep,] keep <- (substr(rownames(tuk$`lengthC:subject`),1,1)=="6") & (substr(rownames(tuk$`lengthC:subject`),7,7)=="6") tuk$`lengthC:subject`[keep,] tukey6 <- tuk$`lengthC:subject`[keep,] tukey6 tukey6[,4] tukey6[tukey6[,4]<.01,] l4 <- lm(time~length*subject,data=data) m4 <- aov(time~length*subject,data=data) Anova(l4) summary(l4) options(max.print=2000) #TukeyHSD(m4) options(max.print=500) HSD.test(m4,trt="subject",console=T,group=T) eta_sq(m4) knitr::opts_chunk$set(echo = TRUE) data <- read.csv("spokenduration.csv") data$length <- rowSums(data[,2:12]) #numerical list-length data$lengthC <- as.factor(rowSums(data[,2:12])) #categorical listlength set.seed(100) gender <- as.factor(c("M","M","M","M","M","M","M","M","M","M", "F","F", "F","F", "F","F", "F","F", "F","F")) ##we are worried about interactions, so be sure we have an orthogonal set of contrasts: contrasts(gender)<- contr.poly(2) experience <- c(4,6,10,5,3,8,12,15,9,19, 5,3,5, 6,1,3,5, 9,10,2) salary1<-c(52.26,59.28,71.10,56.69,49.40,65.80,77.43,85.94,68.99,98.21,56.22,50.42, 55.12,59.74,43.51,50.91,55.69,67.65,70.18,46.30) + rnorm(20)*5 salary2 <- c(53.43,59.39,70.65,55.74,49.68,65.52,76.47,85.92,67.31,97.41,50.49, 45.23,50.3,53.17,39.92,45.93,50.55,63.53,66.77,41.81)+rnorm(20)*2 salary3 <- c(46.6,55.01,71.21,51.82,42.83,62.5,78.35,90.98,67.6,107.52,40.54,37.25, 41.83,42.81,33.34,36.46,40.47,48.37,51.42,34.56)+rnorm(20)*2 #pdf("c19-salaries.pdf",width=8,height=5) par(mfrow=c(1,3)) boxplot(salary1~gender,col="gold",main="Salary group 1") boxplot(salary2~gender,col="gold",main="Salary group 2") boxplot(salary3~gender,col="gold",main="Salary group 3") t.test(salary1~gender) t.test(salary2~gender) t.test(salary3~gender) par(mfrow=c(1,3)) plot(experience,salary1,col=as.numeric(gender),pch=16,cex=2) plot(experience,salary2,col=as.numeric(gender),pch=16,cex=2) plot(experience,salary3,col=as.numeric(gender),pch=16,cex=2) m1.0 <- lm(salary1~experience) Anova(m1.0) ##experience matters! m1 <- lm(salary1~gender+experience) Anova(m1,type="II") Anova(m1,type="II") summary(aov(salary1~experience+gender)) ## Type 1--wrong summary(aov(salary1~gender+experience))## type 1 -- wrong Anova(m1,type="II") m2.0 <- lm(salary2~experience) ##experience matters! Anova(m2.0) m2 <- lm(salary2~gender+experience) Anova(m2,type="II") m2.0 m2 summary(m2) ##how about the third company? m3.0 <- lm(salary3~experience) Anova(m3.0) m3 <- lm(salary3~gender+experience) Anova(m3,type="II") ##experience+gender matter plot(experience,salary1,col=as.numeric(gender),pch=16) abline(m1$coef[1]+m1$coef[2],m1$coef[3],col=2) abline(m1$coef[1]-m1$coef[2],m1$coef[3],col=1) plot(experience,salary2,col=as.numeric(gender),pch=16) abline(m2$coef[1]+sqrt(.5)*m2$coef[2],m2$coef[3],col=2) abline(m2$coef[1]-sqrt(.5)*m2$coef[2],m2$coef[3],col=1) plot(experience,salary3,col=as.numeric(gender),pch=16) abline(m3$coef[1]+sqrt(.5)*m3$coef[2],m3$coef[3],col=2) abline(m3$coef[1]-sqrt(.5)*m3$coef[2],m3$coef[3],col=1) ##what about the interactions? m1b <- lm(salary1~gender * experience) Anova(m1b,type="III") anova(m1b,m1) ##no difference--interaction does not matter. m2b <- lm(salary2~gender * experience) Anova(m2b,type="III") m3b <- lm(salary3~gender * experience) Anova(m3b,type="III") plot(experience,salary3,col=as.numeric(gender),pch=16) abline(m3b$coef[1]+sqrt(.5)*m3b$coef[2],m3b$coef[3]+sqrt(.5)*m3b$coef[4],col=2) abline(m3b$coef[1]-sqrt(.5)*m3b$coef[2],m3b$coef[3]-sqrt(.5)*m3b$coef[4],col=1) Anova(m3b,type="II") m3b summary(m3b) ##Exercise Solution dat.raw <- read.table("tsp-all.txt",header=T) setwd("~/Dropbox/courses/5210-2020/web-5210/psy5210/Projects/Chapter19") ##Exercise Solution dat.raw <- read.table("tsp-all.txt",header=T) dat <- dat.raw[ dat.raw$subnum !="B1"&dat.raw$cycle>0,] dat$cycle <- as.factor(dat$cycle) dat[1:5,] dat$cycle <- as.factor(dat$cycle) contrasts(dat$cycle) <- contr.poly(levels(dat$cycle)) dat$mopp <- as.factor(dat$mopp) tab1 <- tapply(dat$eff,list(size=dat$numpos,cycle=dat$cycle),mean) matplot(c(10,20,30),tab1,type="o",pch=c(1:4),xlab="Problem size",ylab="Efficiency",lwd=2) legend(25,1.08,paste("Cycle", 1:4),lty=1:4,pch=1:4,col=1:4) matplot(c(10,20,30),tab1,type="o",pch=c(1:4),xlab="Problem size",ylab="Efficiency",lwd=2) legend(25,1.08,paste("Cycle", 1:4),lty=1:4,pch=1:4,col=1:4) ##Build and test the ANCOVA models: tsp0 <- aov(eff~numpos,data=dat) ##predict efficiency by problem size alone; essentially a regression tsp1 <- aov(eff~numpos+cycle,data=dat) ##problem size + cycle; cycle is categorical tsp2 <- aov(eff~numpos*cycle,data=dat) ##interaction Anova(tsp0) Anova(tsp1) tsp2 <- aov(eff~numpos*cycle,data=dat) ##interaction Anova(tsp2, type="II") #test the interaction dat[1:10,] nrow(dat) Anova(tsp2,type="III") #test the interaction Anova(tsp2, type="II") #test the interaction Anova(tsp1) Anova(tsp2, type="II") #test the interaction Anova(tsp2,type="III") #test the interaction tsp2 dat[1:5,] tsp3 <- aov(eff~test+subnum+cycle+(mopp),data=dat) ##MOPP is the thing we really care about ##subnum is a factor accounting for consistency within people (repeated measures) ## Although this is not exactly the right way to hand that predictor. ## test is the problem number, sort of like subnum. Anova(tsp3) ##cycle and test were confounded intentionally, so adding cycle won't do anything table(dat$cycle,dat$test) Anova(tsp3) tsp4a <- aov(eff~subnum+ as.factor(mopp)+ cycle,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4a) tsp4a <- aov(eff~subnum+ (mopp)+ cycle,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4a) #Here we add problem size as an independent covariate: tsp4b <- aov(eff~subnum+(mopp)+ cycle+ numpos,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4b,type="III") Anova(tsp4b,type="II") tsp4c <- aov(eff~subnum+(mopp)+ cycle+ numpos*mopp,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4c,type="II") Anova(tsp4c,type="III") tsp4c <- aov(eff~subnum*numpos+(mopp)+ cycle+ mopp,data=dat) ##MOPP is the thing we really care about; we will include problem size as a covariate Anova(tsp4c,type="II") library(sjstats) anova_stats(tsp1) sjstats::eta_sq(tsp1)