Search code examples
rerror-handlinganova

How to handle with error in r in one-way anova?


I have tried anova for two different ways:

1.

lm(os ~ cd3_abs, data = dd) %>% anova()

Which gives this error:

Error in if (ssr < 1e-10 * mss) warning("ANOVA F-tests on an essentially perfect fit are unreliable") :
missing value where TRUE/FALSE needed
aov(formula = compete2 ~ cd3_abs, data = dd)

Which gives this error:

"Error in levels(x)[x] : only 0's may be mixed with negative subscripts"

My data looks like:

    cd3_abs  OS
1   1.38     0  
2   1.19     1  
3   NA       1
4   2.32     0 
5   0.9      1
6   3.3      1

Solution

  • Two obvious issues: 1) since your os is binary, you should use logistic regression; 2) your cd3_abs column has NA, which should be excluded for ANOVA. Typical code is like below:

    glm(os ~ cd3_abs, data = dd%>%na.omit(), family=binomial)