| | 1 | == One-way ANOVA == |
| | 2 | |
| | 3 | See the [http://www.graphpad.com/support/faqid/1745/ Prism help page] for some general considerations. |
| | 4 | |
| | 5 | ==== Reading in Data ==== |
| | 6 | |
| | 7 | |
| | 8 | * Use read.* or create appropriate dataframe |
| | 9 | |
| | 10 | |
| | 11 | {{{ |
| | 12 | #Eg. testing 4 different strains by creating a dataframe |
| | 13 | PA7<-c(56,60,44,53) |
| | 14 | PA7_dGra15<-c(29,38,18,35) |
| | 15 | PA7_Rop16l<-c(11,25,7,18) |
| | 16 | PA7_Rop16l_dGra15<-c(26,44,20,32) |
| | 17 | strains<-data.frame(PA7, PA7_dGra15, PA7_Rop16l, PA7_Rop16l_dGra15) |
| | 18 | strains_stack<-stack(strains) |
| | 19 | |
| | 20 | #Eg. from Mathias' Stats Lecture |
| | 21 | brainweight <- read.csv("brain_weights.csv",header=TRUE) |
| | 22 | |
| | 23 | }}} |
| | 24 | |
| | 25 | ==== Creating an ANOVA Table ==== |
| | 26 | * Use the command //anova// or //aov// with summary. The first arg is the dependent var, followed by ~, and then by independent variable(s) |
| | 27 | |
| | 28 | |
| | 29 | {{{ |
| | 30 | #column headers were not given above, default are "values" and "ind" |
| | 31 | anova(lm(values~ind, data=strains_stack)) |
| | 32 | #or save to file |
| | 33 | x<-anova(lm(values~ind, data=strains_stack)) |
| | 34 | write.table(x, file="strains1_anova.txt", quote=F) |
| | 35 | |
| | 36 | #Eg. from Mathias' Stats Lecture |
| | 37 | summary(aov(Weight~Group)) |
| | 38 | |
| | 39 | }}} |
| | 40 | |
| | 41 | == Post-Test: Comparing All Pairs of Means == |
| | 42 | |
| | 43 | ==== Tukey ==== |
| | 44 | * "Tukey's method is more conservative but may miss real differences too often" - Intuitive Biostatistics (p.259) |
| | 45 | |
| | 46 | |
| | 47 | {{{ |
| | 48 | TukeyHSD(aov(values~ind, data=strains_stack)) |
| | 49 | |
| | 50 | #Eg. from Mathias' Stats Lecture |
| | 51 | TukeyHSD(aov(brainweight$Weight~brainweight$Group)) |
| | 52 | |
| | 53 | |
| | 54 | }}} |
| | 55 | |
| | 56 | ==== Dunnett ==== |
| | 57 | * Useful if you want to compare a reference group to all other groups (instead of doing an all vs. all comparison) |
| | 58 | * The first group is used as the reference group, so name your groups so this is the case. |
| | 59 | |
| | 60 | |
| | 61 | {{{ |
| | 62 | library(multcomp) |
| | 63 | summary(glht(lm(Weight ~ Group, data=brainweight), linfct=mcp(Group="Dunnett"))) |
| | 64 | |
| | 65 | }}} |