# Help with ANOVA in R

4 messages
Open this post in threaded view
|

## Help with ANOVA in R

 Hi I am attempting Anova analysis to compare results from four groups (Samp1-4) which are lists of intensities from the experiment. I am doing this by first creating a structured list of the data and then conducting the ANOVA (Script provided below). Im an R beginner so am not sure if I am using this correctly. Two major questions I have are: 1) Is using the code (zzz.aov <- aov(Intensity ~ Group + Error(Sample), data = zzzanova)) the correct method to calculate the variances between the four groups (samp 1-4). I am unsure of the inclusion of the error portion. 2) I beleive this method (aov) assumes equal variances. How can I adjust this to do an ANOVA with unequal variances #####SCRIPT STARTS #Creates a structured list suitable for ANOVA analysis # Intensity     Group (1,2,3,4)     Sample(1:62) "zzzanova" <- structure(list(Intensity = c(t(Samp1), t(Samp2), t(Samp3), t(Samp4)), Group = structure(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,          2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,          3,3,3,3,3,3,3,3,3,3,3,3,3,3,          4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4), .Label = c("Group1", "Group2", "Group3", "Group4"), class = "factor"),     Sample = structure(c( 1, 2, 3, 4, 5, 6, 7, 8, 9,     10, 11, 12, 13, 14, 15, 16, 17, 18, 19,     20, 21, 22, 23, 24, 25, 26, 27, 28, 29,     30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62) )) , .Names = c("Intensity", "Group", "Sample"), row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61","62"),class = "data.frame") #Conducts the ANOVA for that PCI zzz.aov <- aov(Intensity ~ Group + Error(Sample), data = zzzanova) #####SCRIPT ENDS THANKS IN ADVANCE ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Help with ANOVA in R

 Your line of code:   zzz.aov <- aov(Intensity ~ Group + Error(Sample), data = zzzanova) indicates that you are trying to do a repeated measures ANOVA, not just an ANOVA. The Error(Sample) term in your expression indicates that Sample is a within subjects factor, which I presume is not the case. The way I understood your data, the Sample column is just an id number for the subjects - is that right? If you just want to compare the means of Intensity for the the four Groups, then just do:   zzz.aov <- aov(Intensity ~ Group, data = zzzanova) You may want to consult this resource for explicit examples of ANOVA in R:   http://www.personality-project.org/R/r.anova.htmlRavi Kulkarni