Degrees of freedom Anova R

Asked

Viewed 139 times

3

I’m trying to run a basic one-way ANOVA on R.

library(drc)
data=S.alba
aov(DryMatter~Dose,data=S.alba)

However, there are 7 treatments in this data. Therefore, DF (Gree of Freedom) or Degrees of freedom of treatment should be 7-1 = 6, but the R presents me the DF as 1. I did not understand what is happening. Can someone clear up that doubt?

> aov(DryMatter~Dose,data=S.alba)
Call:
   aov(formula = DryMatter ~ Dose, data = S.alba)

Terms:
                    Dose Residuals
Sum of Squares  65.62088  75.12662
Deg. of Freedom        1        66

Residual standard error: 1.066903
Estimated effects may be unbalanced

1 answer

7


The Dose column is a numerical value of the type int, not a factor:

dados <- S.alba
str(dados)
'data.frame':   68 obs. of  3 variables:
 $ Dose     : int  0 0 0 0 0 0 0 0 10 10 ...
 $ Herbicide: Factor w/ 2 levels "Bentazone","Glyphosate": 2 2 2 2 2 2 2 2 2 2 ...
 $ DryMatter: num  4.7 4.6 4.1 4.4 3.2 3 3.8 3.9 3.8 3.8 ...

Thus, R will not understand that the explanatory variable is a factor. Convert the column Dose, so that it becomes a categorical variable:

dados$Dose <- as.factor(dados$Dose)
str(dados)
'data.frame':   68 obs. of  3 variables:
 $ Dose     : Factor w/ 8 levels "0","10","20",..: 1 1 1 1 1 1 1 1 2 2 ...
 $ Herbicide: Factor w/ 2 levels "Bentazone","Glyphosate": 2 2 2 2 2 2 2 2 2 2 ...
 $ DryMatter: num  4.7 4.6 4.1 4.4 3.2 3 3.8 3.9 3.8 3.8 ...

Also, only the command aov will not give you the ANOVA table you want. You should first adjust a model with the function aov and then ask for the summary his:

ajuste <- aov(DryMatter~Dose, data=dados)
summary(ajuste)

            Df Sum Sq Mean Sq F value Pr(>F)    
Dose         7 121.17  17.310   53.04 <2e-16 ***
Residuals   60  19.58   0.326                   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.