# What does aov(glm model) actually do in R?

What is happening when you use aov() on a glm model in R?

Normal glm model sumamry(m1):

Call:
glm(formula = value ~ origin + variable, family = poisson(),
data = comb_data)

Deviance Residuals:
Min       1Q   Median       3Q      Max
-0.8227  -0.5547  -0.4385  -0.3038   2.5258

Coefficients: (1 not defined because of singularities)
Estimate Std. Error z value Pr(>|z|)
(Intercept)                                                     -2.853e+00  5.774e-01  -4.941 7.78e-07 ***
originisolate                                                    4.700e-01  7.071e-01   0.665  0.50625
variableRB17                                                     2.877e-01  5.401e-01   0.533  0.59425
variableM56                                                      1.299e+00  4.606e-01   2.821  0.00479 **
variableRB68                                                    -6.269e-14  5.774e-01   0.000  1.00000
variableM39b4                                                   -1.010e-13  5.774e-01   0.000  1.00000
variableRB108                                                    1.542e-01  5.563e-01   0.277  0.78172
variableM32                                                      4.055e-01  5.270e-01   0.769  0.44171
variableRB33                                                    -6.931e-01  7.071e-01  -0.980  0.32696
variableM41                                                      6.061e-01  5.075e-01   1.194  0.23236
variableRB1                                                      6.931e-01  5.000e-01   1.386  0.16566
variableM39w2                                                    1.542e-01  5.563e-01   0.277  0.78172
variableRB20                                                    -1.792e+00  1.080e+00  -1.659  0.09714 .
variableRB99                                                     1.542e-01  5.563e-01   0.277  0.78172
variableRB110                                                    6.931e-01  5.000e-01   1.386  0.16566
variableRB5                                                      1.542e-01  5.563e-01   0.277  0.78172
variableRB29                                                    -1.823e-01  6.055e-01  -0.301  0.76334
variableRB56                                                    -7.411e-14  5.774e-01   0.000  1.00000
variableRB24                                                    -1.099e+00  8.165e-01  -1.346  0.17846
variableStreptomyces_alboflavus_strain_MDJK44_RB5                1.204e+00  6.583e-01   1.829  0.06740 .
variableStreptomyces_violaceoruber_RB1                           1.299e+00  6.513e-01   1.995  0.04607 *
variableStreptomyces_T44_RB17                                    1.204e+00  6.583e-01   1.829  0.06740 .
variableStreptomyces_violaceoruber_RB1_RB110                     1.299e+00  6.513e-01   1.995  0.04607 *
variableStreptomyces_autolyticus_strain_CGMCC0516_M56            1.735e+00  6.262e-01   2.770  0.00561 **
variableStreptomyces_atratus_RB108                               9.808e-01  6.770e-01   1.449  0.14740
variableStreptomyces_sp_T44_RB17                                 1.204e+00  6.583e-01   1.829  0.06740 .
variableStreptomyces_sp_QMT.28_M41                               8.473e-01  6.901e-01   1.228  0.21950
variableAmycolatopsis_sp_AA4_M39                                 8.473e-01  6.901e-01   1.228  0.21950
variableLuteimicrobium_xylanilyticum_RB22                       -1.099e+00  1.155e+00  -0.951  0.34138
variableMycolicibacterium_parafortuitum_RB24                     1.239e-13  8.165e-01   0.000  1.00000
variableNocardia_nova_SH22a_RB20_RB56                            2.877e-01  7.638e-01   0.377  0.70642
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for poisson family taken to be 1)

Null deviance: 1024.95  on 1949  degrees of freedom
Residual deviance:  943.36  on 1917  degrees of freedom
AIC: 1507.4

Number of Fisher Scoring iterations: 6


A summary(aov(m1)):

              Df Sum Sq Mean Sq F value   Pr(>F)
origin         1   0.33  0.3285   3.050   0.0809 .
variable      31  10.41  0.3357   3.117 2.06e-08 ***
Residuals   1917 206.47  0.1077

• I’m voting to close this question because 1) the OP only throws in a R function and tables without a reproducible example, 2) it seems to be mostly about statistics and not anything to indicate it is about bioinformatics Jul 6 '20 at 17:54
• welcome to bioinformatics SE. If you indeed have a question related to bioinformatics, please provide more context and what you would like to do. See also GordonSmyth's answer below. You normally compare deviance to see how useful are the terms, not the sum of squares as you would for a linear model Jul 6 '20 at 17:59
• I am attempting to gain an understanding of that is happening inside an R function, Cross Validate don't like R specific questions so I came here. I would argue this is a bioinformatics related questions and a reproducible example is not needed to answer the question I pose. It would just further clutter the question. However I guess some context could have helped.
– RMM
Jul 7 '20 at 7:17

It's not appropriate to run aov on a GLM model. aov assumes normally distributed data and it runs on a GLM as if it was a least squares linear model. It uses the working responses and working weights from the GLM fit and performs an ordinary anova as if the responses were normally distributed.

On the other hand, anova is a generic function with a method for GLMs and it performs a sequential analysis of deviance.

Purely statistical questions like this are best sent to CrossValidated, although they don't like questions that are posed entirely in terms of an R function.

It's equivalent to doing anova(m1, test="F")

You probably want to do some sort of deviance test for a Poisson glm

anova(m1, test="Chisq")

• But what does performing an anova on a glm model do, and why does this one throw out a p value for each parameter of the model whilst anova() does not?
– RMM
Jul 3 '20 at 14:49
• Probably best to ask on CrossValidated. If you use the syntax in my answer, you'll see that p values are given with anova. Again if you want to know why anova doesn't give p values by default for a glm best to ask on CrossValidated - or search anyway...
– Greg
Jul 3 '20 at 14:57