#5710 Lab Week of 4/13 #Install packages through RGui, then load libraries install.packages(c("psych","Rcmdr","HH"),contriburl = "http://cran.stat.ucla.edu/bin/windows/contrib/2.6/") library(psych) library(HH) library(granova) #Bring in Adler data set data(Adler, package="car") attach(Adler) #Get descriptives of rating by expectation and instruction describe.by(rating, expectation) describe.by(rating, instruction) #Get descriptives of rating by each level of expectation and instruction tapply(Adler$rating, list(expectation=Adler$expectation, instruction=Adler$instruction), mean, na.rm=TRUE) #Plot means plotMeans(Adler$rating, Adler$instruction, Adler$expectation, error.bars="se") #Run ANOVA Anova = (lm(rating ~ expectation*instruction, data=Adler)) tapply(Adler$rating, list(expectation=Adler$expectation, instruction=Adler$instruction), mean, na.rm=TRUE) # means tapply(Adler$rating, list(expectation=Adler$expectation, instruction=Adler$instruction), sd, na.rm=TRUE) # std. deviations tapply(Adler$rating, list(expectation=Adler$expectation, instruction=Adler$instruction), function(x) sum(!is.na(x))) # counts #Plot interaction with main effects interaction2wt(rating~expectation + instruction, data=Adler) #Plot interaction with simple effects interaction2wt(rating~expectation + instruction, data=Adler, simple=T) #Detach HH detach(package:HH) #Conduct post hoc with Tukey's HSD aovmod = aov(rating~expectation*instruction, data=Adler) model.tables(aovmod) TukeyHSD(aovmod) plot(TukeyHSD(aovmod)) #Select 'Anova' from active model list #Use Rcmdr menu to get basic diagnostic plots or cycle through them with: plot(aovmod) #Get influence plot influencePlot(Anova, labels=FALSE) #Granova graph of one-way with instruction granova.1w(rating, instruction, tr=T) #Run robust ANOVA source("http://www.unt.edu/rss/class/mike/Rallfun-v9_2.txt") newdat = as.matrix (cbind(as.numeric (Adler$instruction), as.numeric(Adler$expectation), Adler$rating)) t2way(3,2, newdat, MAT=T)