1
$\begingroup$

I'm running mixed design ANOVA using R.
Somehow, I got incorrect values for the degrees of freedom (Df). There are two factors: temperature (2 levels) and identity (7 levels) and when I perform this command :

aov4<- aov(NO3.means~temperature*identity,data=mydata)

I get:

                     Df  Sum Sq Mean Sq F value   Pr(>F)    
temperature           1 3936158 3936158  24.519 1.54e-05 ***
identity              1   71125   71125   0.443  0.50967    
temperature:identity  1 1363345 1363345   8.493  0.00595 ** 
Residuals            38 6100236  160533                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

the degrees of freedom for identity should be 6 rather than 1. What is the problem?

$\endgroup$
1
  • 2
    $\begingroup$ is.numeric(mydata$identity) will presumably give TRUE when it should give FALSE (you need it to be a factor). See ?factor and ?as.factor. $\endgroup$
    – Glen_b
    Aug 20, 2014 at 4:01

1 Answer 1

4
$\begingroup$

It looks like your identity variable is treated like a numerical variable instead of a factor (categorical) variable. Using your code, one way to fix this would be:

mydata$identity <- as.factor(mydata$identity)
aov4 <- aov(NO3.means ~ temperature*identity, data=mydata)
summary(aov4)
$\endgroup$
1
  • $\begingroup$ Unfortunately, same thing as the poster faced happened to me but your suggestion does not seem to be working. $\endgroup$
    – Kevin Kang
    May 11, 2018 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.