tidymodels / broom

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

Incorrect confidence intervals for precision components of a betareg model #1169

Closed larmarange closed 1 year ago

larmarange commented 1 year ago

Please see below an example of a beta regression.

For batch terms, the confidence intervals for the "precision" component are incorrect. These are the confidence intervals for the same terms but for the "mean" component.

library(broom)
library(betareg)
data("GasolineYield", package = "betareg")
mod <- betareg(yield ~ batch + temp | batch + temp, data = GasolineYield)
tidy(mod, conf.int = TRUE) |> 
  knitr::kable()
component term estimate std.error statistic p.value conf.low conf.high
mean (Intercept) -6.4978463 0.0846003 -76.806422 0.0000000 -6.6636598 -6.3320327
mean batch1 1.5845437 0.0693063 22.862902 0.0000000 1.4487058 1.7203816
mean batch2 1.4210111 0.0606595 23.426017 0.0000000 1.3021206 1.5399016
mean batch3 1.6952506 0.0629593 26.926119 0.0000000 1.5718526 1.8186486
mean batch4 1.0409118 0.0658011 15.819070 0.0000000 0.9119441 1.1698795
mean batch5 1.2365840 0.0617598 20.022463 0.0000000 1.1155369 1.3576310
mean batch6 1.0470222 0.0669180 15.646357 0.0000000 0.9158655 1.1781790
mean batch7 0.6726930 0.0597658 11.255480 0.0000000 0.5555542 0.7898319
mean batch8 0.5554868 0.0612682 9.066477 0.0000000 0.4354033 0.6755703
mean batch9 0.3467604 0.0674377 5.141935 0.0000003 0.2145849 0.4789359
mean temp 0.0117051 0.0001428 81.996405 0.0000000 0.0114253 0.0119849
precision (Intercept) -8.7368235 1.7853220 -4.893696 0.0000010 -6.6636598 -6.3320327
precision batch1 1.4047744 1.1103500 1.265164 0.2058127 1.4487058 1.7203816
precision batch2 9.0623365 1.2376412 7.322265 0.0000000 1.3021206 1.5399016
precision batch3 5.6579558 1.2430910 4.551522 0.0000053 1.5718526 1.8186486
precision batch4 1.8084883 1.0910103 1.657627 0.0973928 0.9119441 1.1698795
precision batch5 3.3999312 1.1600801 2.930773 0.0033812 1.1155369 1.3576310
precision batch6 1.9603814 1.1579044 1.693043 0.0904474 0.9158655 1.1781790
precision batch7 5.5540694 1.1127723 4.991200 0.0000006 0.5555542 0.7898319
precision batch8 2.0602136 1.1497873 1.791821 0.0731616 0.4354033 0.6755703
precision batch9 1.3619734 1.2872171 1.058076 0.2900208 0.2145849 0.4789359
precision temp 0.0376697 0.0040708 9.253675 0.0000000 0.0114253 0.0119849

Created on 2023-08-07 with reprex v2.0.2

simonpcouch commented 1 year ago

Thank you for the report!

github-actions[bot] commented 1 year 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.