library(psych) library(granova) library(Rcmdr) #5. Obtain and view data anorexia=read.table("http://www.unt.edu/rss/class/mike/data/anorexia.txt", header=T) anorexia #6. Create 'change' variable, view new data set, attach data anorexia$change=anorexia$Postwt-anorexia$Prewt anorexia attach(anorexia) #8. Obtain descriptives describe.by(anorexia$change,Treat) #9. Create histogram of 'change' hist(change) #10. Create boxplot plot(change~Treat) #11. Conduct ANOVA anovamod <- lm(change~Treat, data=anorexia) anova(anovamod) #13. Diagnostic plots oldpar <- par(oma=c(0,0,3,0), mfrow=c(2,2)) plot(anovamod) par(oldpar) #14. Influence plot influencePlot(anovamod) #15. Shapiro-Wilk test shapiro.test(anovamod$res) #16. Levene's test levene.test(change~Treat) #17. Plot ANOVA granova.1w(change,Treat, tr=T) #18. Welch F test oneway.test(change~Treat, data=anorexia) #19. Kruskal-Wallis test kruskal.test(change~Treat, data=anorexia) #20. Welch F test with trimmed means source("http://www.unt.edu/rss/class/mike/Rallfun-v9_2.txt") newanor=matrix(c(anorexia$Treat,anorexia$change), ncol=2) modmod=t1way(newanor, MAT=T) modmod #21. Pairwise t-test using FDR to correct pairwise.t.test(change, Treat, p.adjust="fdr")