I have attempted to glance a lm of the form y ~ x + 0. When doing so, statistic, p.value & df are returned as NA.
Examination of the package has led me to believe the issue is in line 213 of stats-lm-tidiers.R where glance checks if the model is fitted to intercept only, but it only checks if the summary of the model has one row, which it also does when a 0 intercept model is estimated.
Reproducible example
library(broom)
data <- mtcars
model <- lm(data, formula = mpg ~ 0 + cyl)
glance(model)
#> # A tibble: 1 × 12
#> r.squared adj.r.squared sigma statistic p.value df logLik AIC BIC
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.734 0.725 11.0 NA NA NA -122. 247. 250.
#> # ℹ 3 more variables: deviance <dbl>, df.residual <int>, nobs <int>
Created on 2024-07-01 with [reprex v2.1.0](https://reprex.tidyverse.org/)
The problem
I have attempted to
glance
alm
of the formy ~ x + 0
. When doing so,statistic
,p.value
&df
are returned as NA.Examination of the package has led me to believe the issue is in line 213 of
stats-lm-tidiers.R
where glance checks if the model is fitted to intercept only, but it only checks if the summary of the model has one row, which it also does when a 0 intercept model is estimated.Reproducible example