IndrajeetPatil / statsExpressions

Tidy data frames and expressions with statistical summaries 📜
https://indrajeetpatil.github.io/statsExpressions/
Other
313 stars 20 forks source link

adding support for robust meta-analysis #14

Closed IndrajeetPatil closed 4 years ago

IndrajeetPatil commented 4 years ago
library(robumeta)

# Load data
data(hierdat)

# Small-Sample Corrections - Hierarchical Dependence Model
HierModSm <-  robu(formula = effectsize ~ binge + followup + sreport
                   + age, data = hierdat, studynum = studyid, 
                   var.eff.size = var, modelweights = "HIER", small = TRUE)

class(HierModSm)
#> [1] "robu"

tibble::as_tibble(HierModSm$reg_table)
#> # A tibble: 5 x 9
#>   labels            b.r       SE      t   dfs   prob     CI.L    CI.U sig  
#>   <fct>           <dbl>    <dbl>  <dbl> <dbl>  <dbl>    <dbl>   <dbl> <fct>
#> 1 X.Intercept.  0.397   0.658     0.603  3.06 0.588  -1.68    2.47    ""   
#> 2 binge         0.452   0.102     4.44   3.59 0.0144  0.156   0.747   "**" 
#> 3 followup      0.00133 0.000723  1.84   2.03 0.205  -0.00173 0.00439 ""   
#> 4 sreport       0.539   0.143     3.76   4.36 0.0170  0.153   0.924   "**" 
#> 5 age          -0.0437  0.0379   -1.15   2.69 0.340  -0.172   0.0849  ""

Created on 2020-01-09 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 3.6.2 (2019-12-12) #> os macOS Mojave 10.14.6 #> system x86_64, darwin15.6.0 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Berlin #> date 2020-01-09 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0) #> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.0) #> callr 3.4.0 2019-12-09 [1] CRAN (R 3.6.0) #> cli 2.0.1 2020-01-08 [1] CRAN (R 3.6.2) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0) #> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.0) #> devtools 2.2.1 2019-09-24 [1] CRAN (R 3.6.0) #> digest 0.6.23 2019-11-23 [1] CRAN (R 3.6.0) #> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.2) #> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0) #> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0) #> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0) #> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.0) #> knitr 1.26 2019-11-12 [1] CRAN (R 3.6.0) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.0) #> pillar 1.4.3 2019-12-20 [1] CRAN (R 3.6.2) #> pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 3.6.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.0) #> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.0) #> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.0) #> processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.0) #> ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0) #> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.0) #> Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.1) #> remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.0) #> rlang 0.4.2.9000 2020-01-07 [1] Github (r-lib/rlang@e48b07d) #> rmarkdown 2.0 2019-12-12 [1] CRAN (R 3.6.0) #> robumeta * 2.0 2017-05-29 [1] CRAN (R 3.6.0) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0) #> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0) #> testthat 2.3.1 2019-12-01 [1] CRAN (R 3.6.0) #> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0) #> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.0) #> utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.0) #> vctrs 0.2.1 2019-12-17 [1] CRAN (R 3.6.2) #> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0) #> xfun 0.11 2019-11-12 [1] CRAN (R 3.6.0) #> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0) #> zeallot 0.1.0 2018-01-28 [1] CRAN (R 3.6.0) #> #> [1] /Users/patil/Library/R/3.6/library #> [2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library ```
IndrajeetPatil commented 4 years ago
library(metaplus)
#> 
#> Note: The second parameter is the study standard error not the standard error squared as in the metafor package.

mag.meta <- metaplus(yi, sei, slab = study, random = "t-dist", data = mag)

summary(mag.meta)
#>          Est. 95% ci.lb 95% ci.ub   pvalue
#> muhat -0.7463   -1.2583   -0.3430 0.000501
#> tau2   0.2540                             
#> vinv   0.0000                             
#> 
#>      logLik      AIC      BIC
#>   -19.68459 45.36918 47.68695

tibble::as_tibble(mag.meta$results, rownames = "term")
#> # A tibble: 3 x 5
#>   term    Est. `95% ci.lb` `95% ci.ub`    pvalue
#>   <chr>  <dbl>       <dbl>       <dbl>     <dbl>
#> 1 muhat -0.746       -1.26      -0.343  0.000501
#> 2 tau2   0.254       NA         NA     NA       
#> 3 vinv   0           NA         NA     NA

Created on 2020-01-09 by the reprex package (v0.3.0)

Session info ``` r devtools::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 3.6.2 (2019-12-12) #> os macOS Mojave 10.14.6 #> system x86_64, darwin15.6.0 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Berlin #> date 2020-01-09 #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0) #> backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.0) #> bbmle 1.0.22 2019-12-19 [1] CRAN (R 3.6.2) #> bdsmatrix 1.3-3 2017-12-21 [1] CRAN (R 3.6.0) #> boot 1.3-23 2019-07-05 [2] CRAN (R 3.6.2) #> callr 3.4.0 2019-12-09 [1] CRAN (R 3.6.0) #> cli 2.0.1 2020-01-08 [1] CRAN (R 3.6.2) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0) #> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.0) #> devtools 2.2.1 2019-09-24 [1] CRAN (R 3.6.0) #> digest 0.6.23 2019-11-23 [1] CRAN (R 3.6.0) #> ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.0) #> fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.2) #> fastGHQuad 1.0 2018-09-30 [1] CRAN (R 3.6.0) #> fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.0) #> glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.0) #> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0) #> htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.0) #> knitr 1.26 2019-11-12 [1] CRAN (R 3.6.0) #> lattice 0.20-38 2018-11-04 [2] CRAN (R 3.6.2) #> lme4 1.1-21 2019-03-05 [1] CRAN (R 3.6.0) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0) #> MASS 7.3-51.4 2019-03-31 [2] CRAN (R 3.6.2) #> Matrix 1.2-18 2019-11-27 [2] CRAN (R 3.6.2) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.0) #> metafor 2.1-0 2019-05-14 [1] CRAN (R 3.6.0) #> metaplus * 0.7-11 2018-04-01 [1] CRAN (R 3.6.0) #> minqa 1.2.4 2014-10-09 [1] CRAN (R 3.6.0) #> mvtnorm 1.0-11 2019-06-19 [1] CRAN (R 3.6.0) #> nlme 3.1-142 2019-11-07 [2] CRAN (R 3.6.2) #> nloptr 1.2.1 2018-10-03 [1] CRAN (R 3.6.0) #> numDeriv 2016.8-1.1 2019-06-06 [1] CRAN (R 3.6.0) #> pillar 1.4.3 2019-12-20 [1] CRAN (R 3.6.2) #> pkgbuild 1.0.6 2019-10-09 [1] CRAN (R 3.6.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.0) #> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.0) #> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.0) #> processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.0) #> ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.0) #> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.0) #> Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.1) #> remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.0) #> rlang 0.4.2.9000 2020-01-07 [1] Github (r-lib/rlang@e48b07d) #> rmarkdown 2.0 2019-12-12 [1] CRAN (R 3.6.0) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.0) #> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0) #> testthat 2.3.1 2019-12-01 [1] CRAN (R 3.6.0) #> tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.0) #> usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.0) #> utf8 1.1.4 2018-05-24 [1] CRAN (R 3.6.0) #> vctrs 0.2.1 2019-12-17 [1] CRAN (R 3.6.2) #> withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.0) #> xfun 0.11 2019-11-12 [1] CRAN (R 3.6.0) #> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0) #> zeallot 0.1.0 2018-01-28 [1] CRAN (R 3.6.0) #> #> [1] /Users/patil/Library/R/3.6/library #> [2] /Library/Frameworks/R.framework/Versions/3.6/Resources/library ```