Skip to content

Degrees of freedom is incorrect in the glance function #273

@jbryer

Description

@jbryer

Note that the summary function correctly shows 2 and 29 degrees of freedom for the F, but the glance function returns 3 and 29.

> library(broom)
> data(mtcars)
> lm.out <- lm(mpg ~ disp + hp, data = mtcars)
> summary(lm.out)

Call:
lm(formula = mpg ~ disp + hp, data = mtcars)

Residuals:
    Min      1Q  Median      3Q     Max 
-4.7945 -2.3036 -0.8246  1.8582  6.9363 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) 30.735904   1.331566  23.083  < 2e-16 ***
disp        -0.030346   0.007405  -4.098 0.000306 ***
hp          -0.024840   0.013385  -1.856 0.073679 .  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 3.127 on 29 degrees of freedom
Multiple R-squared:  0.7482,	Adjusted R-squared:  0.7309 
F-statistic: 43.09 on 2 and 29 DF,  p-value: 2.062e-09

> glance(lm.out)
  r.squared adj.r.squared    sigma statistic      p.value df    logLik      AIC      BIC deviance
1 0.7482402     0.7308774 3.126601  43.09458 2.062068e-09  3 -80.30928 168.6186 174.4815 283.4934
  df.residual
1          29

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions