1

I’ve often used linear regression to test if mean values differ between groups by dummy coding my categorical variable, which I think is basically the same thing (or at least I get the same results) as using ANOVA. I have used lm() function in R for doing this.

Previously, if my data did not meet the assumptions of linear regression, I’ve used data transformations. Sometimes this works better and sometimes not so good. As far as I’m concerned, I could use generalized linear models to compare group means for data that follow e.g. Poisson or negative binomial distributions without the need to transform data.

The problem is, when I fit the model and get the model summary (using glm() function in R), I don’t see the p-value for the full model – which I get in the last line of model summary when I am fitting linear models using lm() function. Model summary - when using glm() - gives me only the p and Z-values for each coefficient which I can use for pairwise comparison.

The main idea why I would like to get the p-value for full model is that I could use glm() as a substitute for ANOVA for data that does not meet its assumptions.

All help is much appreciated!

2
  • see the examples in ?anova.glm
    – Jthorpe
    Feb 19, 2015 at 19:15
  • 2
    The authors of the most widely tested mixed models functions in R are not big fans of building p-values. See: glmm.wikidot.com/faq. You can find bootstrapping procedures described in SO answers with a search on: [r] mixed models p-values
    – IRTFM
    Feb 19, 2015 at 19:27

1 Answer 1

3

I think this is what you're interested in:

counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)

# fit the model of interest
glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())

# fit the a NULL model
glm.NULL <- glm(counts ~ 1, family = poisson())

# compare the model of interest to the null model
anova(glm.D93,glm.NULL,test = "F")

You can see the same thing works with linear models:

# fit the model of interest
lm.D93 <- lm(counts ~ outcome + treatment)

# fit the a NULL model
lm.NULL <- lm(counts ~ 1)

anova(lm.D93,lm.NULL,test = "F")
#> Analysis of Variance Table
#> ...
#>   Res.Df     RSS Df Sum of Sq     F  Pr(>F)
#> 1      4  83.333  
#> 2      8 176.000 -4   -92.667 1.112  0.4603

summary(lm.D93)

#> Residual standard error: 4.564 on 4 degrees of freedom
#> Multiple R-squared:  0.5265,    Adjusted R-squared:  0.05303 
#> F-statistic: 1.112 on 4 and 4 DF,  p-value: 0.4603
1
  • Great! I think this solved my problem. In your example, I get the following warning: "using F test with a 'poisson' family is inappropriate". I think I'll just need to use a Chi-Square test instead.
    – Santiago
    Feb 20, 2015 at 7:24

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

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