[R] Help with ANOVA in R

Amit Patel amitrhelp at yahoo.co.uk
Tue Mar 9 15:00:52 CET 2010


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






More information about the R-help mailing list