tidymodels / broom

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

test failure re: `augment.betareg()` #1216

Closed simonpcouch closed 1 month ago

simonpcouch commented 1 month ago
── Error ('test-betareg.R:45:3'): augment.betareg ──────────────────────────────
Error in `data.frame(..., check.names = FALSE)`: arguments imply differing number of rows: 6, 32
Backtrace:
    ▆
 1. └─modeltests::check_augment_function(...) at test-betareg.R:45:3
 2.   └─modeltests:::check_augment_data_specification(...)
 3.     └─broom (local) aug(model, data = head_dl$tibble, newdata = head_new_dl$tibble)
 4.       └─broom::augment_columns(...) at broom/R/betareg-tidiers.R:80:3
 5.         ├─tibble::as_tibble(cbind(original, ret)) at broom/R/utilities.R:319:5
 6.         └─base::cbind(original, ret) at broom/R/utilities.R:319:5
 7.           └─base::cbind(deparse.level, ...)
 8.             └─base::data.frame(..., check.names = FALSE)
simonpcouch commented 1 month ago

A more minimal reprex:

library(broom)
library(betareg)
data("GasolineYield")

fit1 <- betareg(yield ~ batch + temp, data = GasolineYield)
augment(fit1, newdata = head(GasolineYield))
#> Error in data.frame(..., check.names = FALSE): arguments imply differing number of rows: 6, 32

# fine if uses newdata with the same number of rows
augment(fit1, data = NULL, newdata = GasolineYield)
#> # A tibble: 32 × 7
#>    yield gravity pressure temp10  temp batch .fitted
#>    <dbl>   <dbl>    <dbl>  <dbl> <dbl> <fct>   <dbl>
#>  1 0.122    50.8      8.6    190   205 1      0.101 
#>  2 0.223    50.8      8.6    190   275 1      0.195 
#>  3 0.347    50.8      8.6    190   345 1      0.343 
#>  4 0.457    50.8      8.6    190   407 1      0.508 
#>  5 0.08     40.8      3.5    210   218 2      0.0797
#>  6 0.131    40.8      3.5    210   273 2      0.137 
#>  7 0.266    40.8      3.5    210   347 2      0.263 
#>  8 0.074    40        6.1    217   212 3      0.0943
#>  9 0.182    40        6.1    217   272 3      0.167 
#> 10 0.304    40        6.1    217   340 3      0.298 
#> # ℹ 22 more rows

Created on 2024-09-26 with reprex v2.1.1

simonpcouch commented 1 month ago

Works fine with pak::pak("cran/betareg@3.1-4"), newly errors with pak::pak("cran/betareg@3.2-0"). Current release is 3.2-1.

github-actions[bot] commented 3 weeks 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.