bbolker / broom.mixed

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

conf.int values for random effects do not depend on scales argument in tidy() #94

Open joelgautschi opened 4 years ago

joelgautschi commented 4 years ago

if I use scales = "vcov" to set scales for random effects terms to variances and covariances instead of the default "sd-cor" in broom.mixed::tidy(), the random effects' confidence interval reported remain on the scale "sd-cor" and not the scale of my random effects "vcov"`. Is this a bug or by design?

library(lme4)
library(broom.mixed)
fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)

tidy(fm1,
     effects = "ran_pars",
     conf.int = TRUE,
     conf.method = "profile")
#> Computing profile confidence intervals ...
#> # A tibble: 4 x 6
#>   effect   group    term                  estimate conf.low conf.high
#>   <chr>    <chr>    <chr>                    <dbl>    <dbl>     <dbl>
#> 1 ran_pars Subject  sd__(Intercept)        24.7      14.4      37.7  
#> 2 ran_pars Subject  cor__(Intercept).Days   0.0656   -0.482     0.685
#> 3 ran_pars Subject  sd__Days                5.92      3.80      8.75 
#> 4 ran_pars Residual sd__Observation        25.6      22.9      28.9

# set scales for random effects terms to variances and covariances
tidy(fm1,
     effects = "ran_pars",
     scales = "vcov",
     conf.int = TRUE,
     conf.method = "profile")
#> Computing profile confidence intervals ...
#> # A tibble: 4 x 6
#>   effect   group    term                  estimate conf.low conf.high
#>   <chr>    <chr>    <chr>                    <dbl>    <dbl>     <dbl>
#> 1 ran_pars Subject  var__(Intercept)        612.     14.4      37.7  
#> 2 ran_pars Subject  cov__(Intercept).Days     9.60   -0.482     0.685
#> 3 ran_pars Subject  var__Days                35.1     3.80      8.75 
#> 4 ran_pars Residual var__Observation        655.     22.9      28.9

Created on 2020-04-28 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> - Session info --------------------------------------------------------------- #> setting value #> version R version 3.6.3 (2020-02-29) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate German_Switzerland.1252 #> ctype German_Switzerland.1252 #> tz Europe/Berlin #> date 2020-04-28 #> #> - Packages ------------------------------------------------------------------- #> ! package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.3) #> backports 1.1.6 2020-04-05 [1] CRAN (R 3.6.3) #> boot 1.3-24 2019-12-20 [1] CRAN (R 3.6.3) #> broom 0.5.6 2020-04-20 [1] CRAN (R 3.6.3) #> broom.mixed * 0.2.5 2020-04-28 [1] Github (bbolker/broom.mixed@7b16240) #> callr 3.4.3 2020-03-28 [1] CRAN (R 3.6.3) #> cli 2.0.2 2020-02-28 [1] CRAN (R 3.6.3) #> coda 0.19-3 2019-07-05 [1] CRAN (R 3.6.3) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.3) #> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.3) #> devtools 2.3.0 2020-04-10 [1] CRAN (R 3.6.3) #> digest 0.6.25 2020-02-23 [1] CRAN (R 3.6.3) #> dplyr 0.8.5 2020-03-07 [1] CRAN (R 3.6.3) #> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.3) #> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.3) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.3) #> fs 1.4.1 2020-04-04 [1] CRAN (R 3.6.3) #> generics 0.0.2 2018-11-29 [1] CRAN (R 3.6.3) #> glue 1.4.0 2020-04-03 [1] CRAN (R 3.6.3) #> highr 0.8 2019-03-20 [1] CRAN (R 3.6.3) #> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.3) #> knitr 1.28 2020-02-06 [1] CRAN (R 3.6.3) #> lattice 0.20-41 2020-04-02 [1] CRAN (R 3.6.3) #> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 3.6.3) #> lme4 * 1.1-23 2020-04-07 [1] CRAN (R 3.6.3) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.3) #> MASS 7.3-51.5 2019-12-20 [1] CRAN (R 3.6.3) #> Matrix * 1.2-18 2019-11-27 [1] CRAN (R 3.6.3) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.3) #> minqa 1.2.4 2014-10-09 [1] CRAN (R 3.6.3) #> nlme 3.1-147 2020-04-13 [1] CRAN (R 3.6.3) #> nloptr 1.2.2.1 2020-03-11 [1] CRAN (R 3.6.3) #> pillar 1.4.3 2019-12-20 [1] CRAN (R 3.6.3) #> pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 3.6.3) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.3) #> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.3) #> plyr 1.8.6 2020-03-03 [1] CRAN (R 3.6.3) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 3.6.3) #> processx 3.4.2 2020-02-09 [1] CRAN (R 3.6.3) #> ps 1.3.2 2020-02-13 [1] CRAN (R 3.6.3) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 3.6.3) #> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.3) #> Rcpp 1.0.4.6 2020-04-09 [1] CRAN (R 3.6.3) #> remotes 2.1.1 2020-02-15 [1] CRAN (R 3.6.3) #> reshape2 1.4.4 2020-04-09 [1] CRAN (R 3.6.3) #> rlang 0.4.5 2020-03-01 [1] CRAN (R 3.6.3) #> rmarkdown 2.1 2020-01-20 [1] CRAN (R 3.6.3) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.3) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.3) #> statmod 1.4.34 2020-02-17 [1] CRAN (R 3.6.3) #> stringi 1.4.6 2020-02-17 [1] CRAN (R 3.6.2) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.3) #> testthat 2.3.2 2020-03-02 [1] CRAN (R 3.6.3) #> tibble 3.0.1 2020-04-20 [1] CRAN (R 3.6.3) #> tidyr 1.0.2 2020-01-24 [1] CRAN (R 3.6.3) #> tidyselect 1.0.0 2020-01-27 [1] CRAN (R 3.6.3) #> D TMB 1.7.16 2020-01-15 [1] CRAN (R 3.6.3) #> usethis 1.6.0 2020-04-09 [1] CRAN (R 3.6.3) #> utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.3) #> vctrs 0.2.4 2020-03-10 [1] CRAN (R 3.6.3) #> withr 2.2.0 2020-04-20 [1] CRAN (R 3.6.3) #> xfun 0.13 2020-04-13 [1] CRAN (R 3.6.3) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 3.6.2) #> #> [1] C:/R/R-3.6.3/library #> #> D -- DLL MD5 mismatch, broken installation. ```