tidymodels / broom

Convert statistical analysis objects from R into tidy format
https://broom.tidymodels.org
Other
1.45k stars 302 forks source link

tidy() gives a warning when used with anova() #487

Closed AndrewKostandy closed 5 years ago

AndrewKostandy commented 6 years ago

After the latest broom update (0.5.0), the tidy function gives the warning: "Warning: Unknown or uninitialised column: 'term'." when used on the anova function. That was not the case before the update.

m1 <- lm(mpg~hp, data=mtcars)
m2 <- lm(mpg~hp+wt, data=mtcars)
broom::tidy(anova(m1,m2))
#> Warning: Unknown or uninitialised column: 'term'.
#> # A tibble: 2 x 6
#>   res.df   rss    df sumsq statistic     p.value
#> *  <dbl> <dbl> <dbl> <dbl>     <dbl>       <dbl>
#> 1     30  448.    NA   NA       NA   NA         
#> 2     29  195.     1  253.      37.6  0.00000112
alexpghayes commented 6 years ago

Hmmm, will look into this.

topepo commented 5 years ago

I get a similar issue when using one of the updater functions that has a column for AIC (but maybe a different issue)

# from ?drop1
require(graphics); require(utils); require(broom); require(dplyr)
#> Loading required package: broom
#> Loading required package: dplyr
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
## following example(swiss)
lm1 <- lm(Fertility ~ ., data = swiss)
add1(lm1, ~ I(Education^2) + .^2) %>% tidy()
#> Warning in tidy.anova(.): The following column names in ANOVA output were
#> not recognized or transformed: AIC
#> # A tibble: 12 x 5
#>    term                            df  sumsq   rss   AIC
#>    <chr>                        <dbl>  <dbl> <dbl> <dbl>
#>  1 <none>                          NA  NA    2105.  191.
#>  2 I(Education^2)                   1  11.8  2093.  192.
#>  3 Agriculture:Examination          1  10.7  2094.  192.
#>  4 Agriculture:Education            1   1.83 2103.  193.
#>  5 Agriculture:Catholic             1  75.0  2030.  191.
#>  6 Agriculture:Infant.Mortality     1   4.44 2101.  193.
#>  7 Examination:Education            1  48.7  2056.  192.
#>  8 Examination:Catholic             1  40.8  2064.  192.
#>  9 Examination:Infant.Mortality     1  65.9  2039.  191.
#> 10 Education:Catholic               1 278.   1827.  186.
#> 11 Education:Infant.Mortality       1  93.0  2012.  191.
#> 12 Catholic:Infant.Mortality        1   2.36 2103.  193.
drop1(lm1, test = "F")  %>% tidy()
#> Warning in tidy.anova(.): The following column names in ANOVA output were
#> not recognized or transformed: AIC
#> # A tibble: 6 x 7
#>   term                df  sumsq   rss   AIC statistic    p.value
#>   <chr>            <dbl>  <dbl> <dbl> <dbl>     <dbl>      <dbl>
#> 1 <none>              NA   NA   2105.  191.     NA    NA        
#> 2 Agriculture          1  308.  2413.  195.      5.99  0.0187   
#> 3 Examination          1   53.0 2158.  190.      1.03  0.315    
#> 4 Education            1 1163.  3268.  209.     22.6   0.0000243
#> 5 Catholic             1  448.  2553.  198.      8.72  0.00519  
#> 6 Infant.Mortality     1  409.  2514.  197.      7.96  0.00734

Created on 2019-01-07 by the reprex package (v0.2.1)

brunaw commented 5 years ago

I claim this one

tvatter commented 4 years ago

I know that this is supposed to be fixed, but I actually get the exact same issue with broom version 0.5.5. Any idea what could be happening?

github-actions[bot] commented 3 years ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.