bbolker / broom.mixed

tidy methods for mixed models in R
227 stars 23 forks source link

`exponentiate` argument, when not relevant, not consistently ignored #72

Closed IndrajeetPatil closed 4 years ago

IndrajeetPatil commented 5 years ago

This is just one example with a tidier for glmmTMB, but I've noticed similar behavior with few other tidiers.

library(glmmTMB)
library(lme4)
#> Loading required package: Matrix
set.seed(123)

# model
mod <-
  glmmTMB::glmmTMB(
    formula = Reaction ~ Days + (Days | Subject),
    data = sleepstudy,
    family = glmmTMB::truncated_poisson()
  )
# without `exponentiate`
broom.mixed::tidy(
  mod,
  conf.int = TRUE,
  conf.method = "Wald"
)

#> # A tibble: 5 x 10
#>   effect component group term  estimate std.error statistic   p.value
#>   <chr>  <chr>     <chr> <chr>    <dbl>     <dbl>     <dbl>     <dbl>
#> 1 fixed  cond      <NA>  (Int~   5.53     0.0264     209.    0.      
#> 2 fixed  cond      <NA>  Days    0.0339   0.00459      7.37  1.71e-13
#> 3 ran_p~ cond      Subj~ sd__~   0.106   NA           NA    NA       
#> 4 ran_p~ cond      Subj~ sd__~   0.0184  NA           NA    NA       
#> 5 ran_p~ cond      Subj~ cor_~  -0.112   NA           NA    NA       
#> # ... with 2 more variables: conf.low <dbl>, conf.high <dbl>

# with `exponentiate` 
broom.mixed::tidy(
  mod,
  conf.int = TRUE,
  exponentiate = FALSE,
  conf.method = "Wald"
)

#> Warning in confint.glmmTMB(x, method = tolower(conf.method), level =
#> conf.level, : extra arguments ignored: exponentiate
#> Warning in confint.glmmTMB(x, parm = thpar, method = conf.method, level =
#> conf.level, : extra arguments ignored: exponentiate

#> # A tibble: 5 x 10
#>   effect component group term  estimate std.error statistic   p.value
#>   <chr>  <chr>     <chr> <chr>    <dbl>     <dbl>     <dbl>     <dbl>
#> 1 fixed  cond      <NA>  (Int~   5.53     0.0264     209.    0.      
#> 2 fixed  cond      <NA>  Days    0.0339   0.00459      7.37  1.71e-13
#> 3 ran_p~ cond      Subj~ sd__~   0.106   NA           NA    NA       
#> 4 ran_p~ cond      Subj~ sd__~   0.0184  NA           NA    NA       
#> 5 ran_p~ cond      Subj~ cor_~  -0.112   NA           NA    NA       
#> # ... with 2 more variables: conf.low <dbl>, conf.high <dbl>
# without `exponentiate`
broom.mixed::tidy(
  mod,
  conf.int = TRUE,
  conf.method = "uniroot"
)

#> # A tibble: 5 x 10
#>   effect component group term  estimate std.error statistic   p.value
#>   <chr>  <chr>     <chr> <chr>    <dbl>     <dbl>     <dbl>     <dbl>
#> 1 fixed  cond      <NA>  (Int~   5.53     0.0264     209.    0.      
#> 2 fixed  cond      <NA>  Days    0.0339   0.00459      7.37  1.71e-13
#> 3 ran_p~ cond      Subj~ sd__~   0.106   NA           NA    NA       
#> 4 ran_p~ cond      Subj~ sd__~   0.0184  NA           NA    NA       
#> 5 ran_p~ cond      Subj~ cor_~  -0.112   NA           NA    NA       
#> # ... with 2 more variables: conf.low <dbl>, conf.high <dbl>

# with `exponentiate` 
broom.mixed::tidy(
  mod,
  conf.int = TRUE,
  exponentiate = FALSE,
  conf.method = "uniroot"
)

#> Error in TMB::tmbroot(obj = object$obj, name = n, target = 0.5 * qchisq(level, : unused argument (exponentiate = FALSE)

Created on 2019-05-30 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> - Session info ---------------------------------------------------------- #> setting value #> version R version 3.6.0 alpha (2019-03-29 r76300) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.1252 #> ctype English_United States.1252 #> tz America/New_York #> date 2019-05-30 #> #> - Packages -------------------------------------------------------------- #> package * version date lib #> assertthat 0.2.1 2019-03-21 [1] #> backports 1.1.4 2019-04-10 [1] #> boot 1.3-21 2019-03-01 [2] #> broom 0.5.2.9001 2019-05-29 [1] #> broom.mixed 0.2.4.9000 2019-03-14 [1] #> callr 3.2.0 2019-03-15 [1] #> cli 1.1.0 2019-03-19 [1] #> coda 0.19-2 2018-10-08 [1] #> crayon 1.3.4 2017-09-16 [1] #> desc 1.2.0 2019-04-03 [1] #> devtools 2.0.2 2019-04-08 [1] #> digest 0.6.19 2019-05-20 [1] #> dplyr 0.8.1 2019-05-14 [1] #> evaluate 0.14 2019-05-28 [1] #> fansi 0.4.0 2018-11-05 [1] #> fs 1.3.1 2019-05-06 [1] #> generics 0.0.2 2019-03-05 [1] #> glmmTMB * 0.2.3 2019-01-11 [1] #> glue 1.3.1 2019-03-12 [1] #> highr 0.8 2019-03-20 [1] #> htmltools 0.3.6 2017-04-28 [1] #> knitr 1.23 2019-05-18 [1] #> lattice 0.20-38 2018-11-04 [2] #> lme4 * 1.1-21 2019-03-05 [1] #> magrittr 1.5 2014-11-22 [1] #> MASS 7.3-51.4 2019-03-31 [1] #> Matrix * 1.2-17 2019-03-22 [1] #> memoise 1.1.0 2017-04-21 [1] #> minqa 1.2.4 2014-10-09 [1] #> nlme 3.1-137 2018-04-07 [2] #> nloptr 1.2.1 2018-10-03 [1] #> pillar 1.4.1 2019-05-28 [1] #> pkgbuild 1.0.3 2019-03-20 [1] #> pkgconfig 2.0.2 2018-08-16 [1] #> pkgload 1.0.2 2018-10-29 [1] #> plyr 1.8.4 2016-06-08 [1] #> prettyunits 1.0.2 2015-07-13 [1] #> processx 3.3.1 2019-05-08 [1] #> ps 1.3.0 2018-12-21 [1] #> purrr 0.3.2 2019-03-15 [1] #> R6 2.4.0 2019-02-14 [1] #> Rcpp 1.0.1 2019-03-17 [1] #> remotes 2.0.4 2019-04-10 [1] #> reshape2 1.4.3 2017-12-11 [1] #> rlang 0.3.4 2019-04-07 [1] #> rmarkdown 1.13 2019-05-22 [1] #> rprojroot 1.3-2 2018-01-03 [1] #> sessioninfo 1.1.1 2018-11-05 [1] #> stringi 1.4.3 2019-03-12 [1] #> stringr 1.4.0 2019-02-10 [1] #> testthat 2.1.1 2019-04-23 [1] #> tibble 2.1.2 2019-05-29 [1] #> tidyr 0.8.3 2019-03-01 [1] #> tidyselect 0.2.5 2018-10-11 [1] #> TMB 1.7.15 2018-11-09 [1] #> usethis 1.5.0 2019-04-07 [1] #> utf8 1.1.4 2018-05-24 [1] #> vctrs 0.1.0 2018-11-29 [1] #> withr 2.1.2 2018-03-15 [1] #> xfun 0.7 2019-05-14 [1] #> yaml 2.2.0 2018-07-25 [1] #> zeallot 0.1.0 2018-01-28 [1] #> source #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> local #> Github (bbolker/broom.mixed@c2de407) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.5.1) #> Github (r-lib/desc@c860e7b) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> Github (brodieG/fansi@ab11e9c) #> CRAN (R 3.6.0) #> Github (r-lib/generics@c15ac43) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.5.1) #> #> [1] C:/Users/inp099/Documents/R/win-library/3.6 #> [2] C:/Program Files/R/R-3.6.0alpha/library ```
bbolker commented 4 years ago

this should be OK now that I've added an explicit exponentiate= argument.