On 2010-12-15 11:12, brianiphk wrote:>
> I'm trying to run an ANOVA in R and I have a problem:
>
> I used this command: anova(lm(time~age*region*facility))
> Age, region, and facility are all factor levels, which has 2, 4, and 3
> levels respectively.
>
> however, in the output (anova table), it states that the df is 1 for all
> three factors, which should be 1, 3, and 2 respectively.
>
> Can anyone tell me if it is necessary to declare the factors as class
before
> it can run correctly? Or is there any other problem?
Yes and Yes.
1) your 'factors' are obviously coded numerically - never a good idea.
See ?factor on how to convert them.
2) why are you using lm()? Use aov().
See ?aov, ?anova
Peter Ehlers
>
> I attached the data set as shown below.
>
> Thank you very much!
>
> ( http://r.789695.n4.nabble.com/file/n3089686/data1.csv data1.csv
>