Dear Stackoverflow community,
I am struggling with using the tidy function from the broom package. I need this function in the context of a multiple imputation.
You can see here a reprex example using a ggplot2 dataset.
library(ggplot2, quietly = T)
library(AER, quietly = T)
#>
#> Attaching package: 'zoo'
#> The following objects are masked from 'package:base':
#>
#> as.Date, as.Date.numeric
library(broom, quietly = T)
library(tidyverse, quietly = T)
data <- ggplot2::diamonds
data
#> # A tibble: 53,940 × 10
#> carat cut color clarity depth table price x y z
#> <dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl>
#> 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43
#> 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31
#> 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31
#> 4 0.29 Premium I VS2 62.4 58 334 4.2 4.23 2.63
#> 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75
#> 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48
#> 7 0.24 Very Good I VVS1 62.3 57 336 3.95 3.98 2.47
#> 8 0.26 Very Good H SI1 61.9 55 337 4.07 4.11 2.53
#> 9 0.22 Fair E VS2 65.1 61 337 3.87 3.78 2.49
#> 10 0.23 Very Good H VS1 59.4 61 338 4 4.05 2.39
#> # ℹ 53,930 more rows
fit <- AER::tobit(
formula = price ~ z,
left = 500,
right = 1500,
data = data
)
fit %>% summary(tidy)
#> Error in if (correlation) cov2cor(vcov.) else NULL: argument is not interpretable as logical
Created on 2023-07-26 with reprex v2.0.2
I checked my R version and the package version:
R version 4.3.1 (2023-06-16 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)
other attached packages: [1] reprex_2.0.2 broom_1.0.5 AER_1.2-10
I identified the following issue and resolution on GitHub but I was not able to transfer it into my in-working project: https://github.com/tidymodels/broom/issues/749 https://github.com/tidymodels/broom/commit/56437bce30841211bfa64074677fe2d9124d99cc
Any help would be very much appreciated!
Thank you in advance!
I came up with a workaround, which you should use with caution:
class(fit)isc("tobit", "survreg"), and there is a tidy method forsurvregobjects (seemethods("tidy")), buttidy(fit)returnsSo:
This appears to match the results of
summary():Note: to make this work in
miceyou have to explicitly override the version inbroomviabefore you run
pool().