Giter Club home page Giter Club logo

Comments (18)

danheck avatar danheck commented on June 3, 2024 1

Thanks for noticing this issue! This is clearly a bug, the argument ci is not passed to the internal summary functions.

dfa24c6 provides a solution, but I have not checked this thoroughly yet. I will update the CRAN version as soon as possible.

from metabma.

danheck avatar danheck commented on June 3, 2024 1

Okay, I will try to fix this asap and check whether renaming is a bigger issue or not.

EDIT: I will let you know until tomorrow about the naming scheme.

from metabma.

strengejacke avatar strengejacke commented on June 3, 2024 1

This is how it looks (and works) with current dev of metaBMA.

library(metaBMA)
#> Loading required package: Rcpp
library(parameters)
data(towels)

set.seed(123)
m1 <- suppressWarnings(meta_bma(logOR, SE, study, data = towels, ci = 0.95))
model_parameters(m1)
#> # Studies 
#> 
#> Parameter                                           | Coefficient |   SE |        95% CI | Weight
#> -------------------------------------------------------------------------------------------------
#> Goldstein, Cialdini, & Griskevicius (2008), Exp. 1  |        0.38 | 0.20 | [-0.01, 0.77] |  25.59
#> Goldstein, Cialdini, & Griskevicius  (2008), Exp. 2 |        0.30 | 0.14 | [ 0.04, 0.57] |  53.97
#> Schultz, Khazian, & Zaleski (2008), Exp. 2          |        0.21 | 0.19 | [-0.17, 0.58] |  27.24
#> Schultz, Khazian, & Zaleski (2008), Exp. 3          |        0.25 | 0.17 | [-0.08, 0.58] |  34.57
#> Mair & Bergin-Seers (2010), Exp. 1                  |        0.29 | 0.82 | [-1.33, 1.90] |   1.47
#> Bohner & Schluter (2014), Exp. 1                    |       -0.12 | 0.25 | [-0.61, 0.36] |  16.25
#> Bohner & Schluter (2014), Exp. 2                    |       -1.46 | 0.76 | [-2.95, 0.03] |   1.73
#> 
#> # Meta-Parameters 
#> 
#> Parameter | Coefficient |   SE |        95% CI |    BF |  Rhat |     ESS
#> ------------------------------------------------------------------------
#> averaged  |        0.20 | 0.09 | [ 0.03, 0.37] |       |       |        
#> fixed     |        0.21 | 0.07 | [ 0.07, 0.36] | 11.97 | 1.000 | 3712.10
#> random    |        0.18 | 0.11 | [-0.03, 0.37] |  5.37 | 1.002 | 3670.80
#> 
#> Using highest density intervals as credible intervals.

set.seed(123)
m2 <- suppressWarnings(meta_bma(logOR, SE, study, data = towels, ci = 0.99))
model_parameters(m2)
#> # Studies 
#> 
#> Parameter                                           | Coefficient |   SE |        99% CI | Weight
#> -------------------------------------------------------------------------------------------------
#> Goldstein, Cialdini, & Griskevicius (2008), Exp. 1  |        0.38 | 0.20 | [-0.01, 0.77] |  25.59
#> Goldstein, Cialdini, & Griskevicius  (2008), Exp. 2 |        0.30 | 0.14 | [ 0.04, 0.57] |  53.97
#> Schultz, Khazian, & Zaleski (2008), Exp. 2          |        0.21 | 0.19 | [-0.17, 0.58] |  27.24
#> Schultz, Khazian, & Zaleski (2008), Exp. 3          |        0.25 | 0.17 | [-0.08, 0.58] |  34.57
#> Mair & Bergin-Seers (2010), Exp. 1                  |        0.29 | 0.82 | [-1.33, 1.90] |   1.47
#> Bohner & Schluter (2014), Exp. 1                    |       -0.12 | 0.25 | [-0.61, 0.36] |  16.25
#> Bohner & Schluter (2014), Exp. 2                    |       -1.46 | 0.76 | [-2.95, 0.03] |   1.73
#> 
#> # Meta-Parameters 
#> 
#> Parameter | Coefficient |   SE |        99% CI |    BF |  Rhat |     ESS
#> ------------------------------------------------------------------------
#> averaged  |        0.20 | 0.09 | [-0.06, 0.43] |       |       |        
#> fixed     |        0.21 | 0.07 | [ 0.02, 0.39] | 11.97 | 1.000 | 3712.10
#> random    |        0.18 | 0.11 | [-0.16, 0.44] |  5.37 | 1.002 | 3670.80
#> 
#> Using highest density intervals as credible intervals.

set.seed(123)
m3 <- suppressWarnings(meta_random(logOR, SE, study, data = towels, ci = 0.95))
model_parameters(m3, ci_method = "eti")
#> # Studies 
#> 
#> Parameter                                           | Coefficient |   SE |        95% CI | Weight
#> -------------------------------------------------------------------------------------------------
#> Goldstein, Cialdini, & Griskevicius (2008), Exp. 1  |        0.38 | 0.20 | [-0.01, 0.77] |  25.59
#> Goldstein, Cialdini, & Griskevicius  (2008), Exp. 2 |        0.30 | 0.14 | [ 0.04, 0.57] |  53.97
#> Schultz, Khazian, & Zaleski (2008), Exp. 2          |        0.21 | 0.19 | [-0.17, 0.58] |  27.24
#> Schultz, Khazian, & Zaleski (2008), Exp. 3          |        0.25 | 0.17 | [-0.08, 0.58] |  34.57
#> Mair & Bergin-Seers (2010), Exp. 1                  |        0.29 | 0.82 | [-1.33, 1.90] |   1.47
#> Bohner & Schluter (2014), Exp. 1                    |       -0.12 | 0.25 | [-0.61, 0.36] |  16.25
#> Bohner & Schluter (2014), Exp. 2                    |       -1.46 | 0.76 | [-2.95, 0.03] |   1.73
#> 
#> # Meta-Parameters 
#> 
#> Parameter | Coefficient |   SE |        95% CI |   BF |  Rhat |     ESS
#> -----------------------------------------------------------------------
#> Overall   |        0.18 | 0.10 | [-0.04, 0.37] | 2.00 | 1.000 | 3974.80
#> tau       |        0.14 | 0.10 | [ 0.03, 0.40] |      | 1.000 | 3145.40
#> 
#> Using equal-tailed intervals as credible intervals.

set.seed(123)
m4 <- suppressWarnings(meta_random(logOR, SE, study, data = towels, ci = 0.99))
model_parameters(m4, ci_method = "eti")
#> # Studies 
#> 
#> Parameter                                           | Coefficient |   SE |        99% CI | Weight
#> -------------------------------------------------------------------------------------------------
#> Goldstein, Cialdini, & Griskevicius (2008), Exp. 1  |        0.38 | 0.20 | [-0.01, 0.77] |  25.59
#> Goldstein, Cialdini, & Griskevicius  (2008), Exp. 2 |        0.30 | 0.14 | [ 0.04, 0.57] |  53.97
#> Schultz, Khazian, & Zaleski (2008), Exp. 2          |        0.21 | 0.19 | [-0.17, 0.58] |  27.24
#> Schultz, Khazian, & Zaleski (2008), Exp. 3          |        0.25 | 0.17 | [-0.08, 0.58] |  34.57
#> Mair & Bergin-Seers (2010), Exp. 1                  |        0.29 | 0.82 | [-1.33, 1.90] |   1.47
#> Bohner & Schluter (2014), Exp. 1                    |       -0.12 | 0.25 | [-0.61, 0.36] |  16.25
#> Bohner & Schluter (2014), Exp. 2                    |       -1.46 | 0.76 | [-2.95, 0.03] |   1.73
#> 
#> # Meta-Parameters 
#> 
#> Parameter | Coefficient |   SE |        99% CI |   BF |  Rhat |     ESS
#> -----------------------------------------------------------------------
#> Overall   |        0.18 | 0.10 | [-0.16, 0.43] | 2.00 | 1.000 | 3974.80
#> tau       |        0.14 | 0.10 | [ 0.02, 0.60] |      | 1.000 | 3145.40
#> 
#> Using equal-tailed intervals as credible intervals.

set.seed(123)
m5 <- suppressWarnings(meta_fixed(logOR, SE, study, data = towels, ci = 0.95))
model_parameters(m5)
#> # Studies 
#> 
#> Parameter                                           | Coefficient |   SE |        95% CI | Weight
#> -------------------------------------------------------------------------------------------------
#> Goldstein, Cialdini, & Griskevicius (2008), Exp. 1  |        0.38 | 0.20 | [-0.01, 0.77] |  25.59
#> Goldstein, Cialdini, & Griskevicius  (2008), Exp. 2 |        0.30 | 0.14 | [ 0.04, 0.57] |  53.97
#> Schultz, Khazian, & Zaleski (2008), Exp. 2          |        0.21 | 0.19 | [-0.17, 0.58] |  27.24
#> Schultz, Khazian, & Zaleski (2008), Exp. 3          |        0.25 | 0.17 | [-0.08, 0.58] |  34.57
#> Mair & Bergin-Seers (2010), Exp. 1                  |        0.29 | 0.82 | [-1.33, 1.90] |   1.47
#> Bohner & Schluter (2014), Exp. 1                    |       -0.12 | 0.25 | [-0.61, 0.36] |  16.25
#> Bohner & Schluter (2014), Exp. 2                    |       -1.46 | 0.76 | [-2.95, 0.03] |   1.73
#> 
#> # Meta-Parameters 
#> 
#> Parameter | Coefficient |   SE |       95% CI |    BF
#> -----------------------------------------------------
#> Overall   |        0.21 | 0.08 | [0.06, 0.36] | 11.97
#> 
#> Using highest density intervals as credible intervals.

set.seed(123)
m6 <- suppressWarnings(meta_fixed(logOR, SE, study, data = towels, ci = 0.99))
model_parameters(m6)
#> # Studies 
#> 
#> Parameter                                           | Coefficient |   SE |        99% CI | Weight
#> -------------------------------------------------------------------------------------------------
#> Goldstein, Cialdini, & Griskevicius (2008), Exp. 1  |        0.38 | 0.20 | [-0.01, 0.77] |  25.59
#> Goldstein, Cialdini, & Griskevicius  (2008), Exp. 2 |        0.30 | 0.14 | [ 0.04, 0.57] |  53.97
#> Schultz, Khazian, & Zaleski (2008), Exp. 2          |        0.21 | 0.19 | [-0.17, 0.58] |  27.24
#> Schultz, Khazian, & Zaleski (2008), Exp. 3          |        0.25 | 0.17 | [-0.08, 0.58] |  34.57
#> Mair & Bergin-Seers (2010), Exp. 1                  |        0.29 | 0.82 | [-1.33, 1.90] |   1.47
#> Bohner & Schluter (2014), Exp. 1                    |       -0.12 | 0.25 | [-0.61, 0.36] |  16.25
#> Bohner & Schluter (2014), Exp. 2                    |       -1.46 | 0.76 | [-2.95, 0.03] |   1.73
#> 
#> # Meta-Parameters 
#> 
#> Parameter | Coefficient |   SE |       99% CI |    BF
#> -----------------------------------------------------
#> Overall   |        0.21 | 0.08 | [0.01, 0.41] | 11.97
#> 
#> Using highest density intervals as credible intervals.

Created on 2020-10-26 by the reprex package (v0.3.0)

from metabma.

IndrajeetPatil avatar IndrajeetPatil commented on June 3, 2024

Would the column names for the intervals still contain 95? Or will it change according to the specified confidence level?

I know this would be a breaking change, but i feel like the names for these columns should be more generic, like conf.low, ci.lower, etc.

What do you think?

from metabma.

danheck avatar danheck commented on June 3, 2024

Yes, the names will change depending on the value of ci.

On the one hand, generic names would be beneficial for accessing the estimates (e.g., in your package or within JASP). On the other hand, having the names in the columns will tell the user what level of ci was used. And changing this will require more time and checks.

from metabma.

IndrajeetPatil avatar IndrajeetPatil commented on June 3, 2024

Another option to have a generic column names and then a separate column called ci.width or conf.level that contains this information, if the user is curious.

from metabma.

IndrajeetPatil avatar IndrajeetPatil commented on June 3, 2024

By the way, do you plan to submit the patched version to CRAN any time soon?

from metabma.

danheck avatar danheck commented on June 3, 2024

Good idea, thanks for the suggestion.

Since the semester is starting again, I will require 1-2 weeks for this. Is this fast enough?

from metabma.

IndrajeetPatil avatar IndrajeetPatil commented on June 3, 2024

Unfortunately, I have a deadline of 5th of November to submit revised version of my package because the tests are currently failing.

That said, if you can already tell us (cc @strengejacke) what naming schema you will adopt, we can put in contingencies in our packages to make it work with both the CRAN and GitHub versions.

Sounds reasonable?

from metabma.

IndrajeetPatil avatar IndrajeetPatil commented on June 3, 2024

Thanks, Daniel! :)

from metabma.

strengejacke avatar strengejacke commented on June 3, 2024

I revised model_parameters(), so it should now work with flexible column names that include the ci-level (e.g. hdp95_upper or hdp89_upper...).

from metabma.

danheck avatar danheck commented on June 3, 2024

Great, this was fast. Just for your information, the column names when using ci=.99 are currently:
mean sd 0.5% 50% 99.5% hpd99_lower hpd99_upper n_eff Rhat

Since there are both quantiles and the HPD interval, a consistent renaming of the table column names would require not only renaming but also reordering the columns, for instance, as follows:
mean sd median ci bci_lower bci_upper hpd_lower hpd_upper n_eff Rhat

Alternatively, I could merely remove the information about the ci in the HPD labels. The ci level would then be implicit in the reported quantiles. This would be a compromise:
mean sd 0.5% 50% 99.5% hpd_lower hpd_upper n_eff Rhat

from metabma.

IndrajeetPatil avatar IndrajeetPatil commented on June 3, 2024

Thanks @strengejacke!

I like this one-

mean sd median ci bci_lower bci_upper hpd_lower hpd_upper n_eff Rhat

from metabma.

strengejacke avatar strengejacke commented on June 3, 2024

Great, this was fast. Just for your information, the column names when using ci=.99 are currently:
mean sd 0.5% 50% 99.5% hpd99_lower hpd99_upper n_eff Rhat

Since there are both quantiles and the HPD interval, a consistent renaming of the table column names would require not only renaming but also reordering the columns, for instance, as follows:
mean sd median ci bci_lower bci_upper hpd_lower hpd_upper n_eff Rhat

Alternatively, I could merely remove the information about the ci in the HPD labels. The ci level would then be implicit in the reported quantiles. This would be a compromise:
mean sd 0.5% 50% 99.5% hpd_lower hpd_upper n_eff Rhat

Yes, the pattern to detect the appropriate CI columns in parameters::model_parameters() should be OK:

ci_method <- "hdi"
ci <- .95

switch(
  toupper(ci_method),
  "HDI" = sprintf(c("hpd%i_lower", "hpd%i_upper"), 100 * ci),
  c(sprintf("%g%%", (100 * (1 - ci)) / 2), sprintf("%g%%", 100 - (100 * (1 - ci)) / 2))
)
#> [1] "hpd95_lower" "hpd95_upper"

ci_method <- "hdi"
ci <- .99

switch(
  toupper(ci_method),
  "HDI" = sprintf(c("hpd%i_lower", "hpd%i_upper"), 100 * ci),
  c(sprintf("%g%%", (100 * (1 - ci)) / 2), sprintf("%g%%", 100 - (100 * (1 - ci)) / 2))
)
#> [1] "hpd99_lower" "hpd99_upper"

ci_method <- "eti"
ci <- .95

switch(
  toupper(ci_method),
  "HDI" = sprintf(c("hpd%i_lower", "hpd%i_upper"), 100 * ci),
  c(sprintf("%g%%", (100 * (1 - ci)) / 2), sprintf("%g%%", 100 - (100 * (1 - ci)) / 2))
)
#> [1] "2.5%"  "97.5%"

ci_method <- "eti"
ci <- .99

switch(
  toupper(ci_method),
  "HDI" = sprintf(c("hpd%i_lower", "hpd%i_upper"), 100 * ci),
  c(sprintf("%g%%", (100 * (1 - ci)) / 2), sprintf("%g%%", 100 - (100 * (1 - ci)) / 2))
)
#> [1] "0.5%"  "99.5%"

Created on 2020-10-26 by the reprex package (v0.3.0)

from metabma.

strengejacke avatar strengejacke commented on June 3, 2024

I'm ok with both approaches. It would be good to know your decision the next days, so I can already take care of this in my package update, which should be submitted the next days.

If your current implementation is mean sd 0.5% 50% 99.5% hpd99_lower hpd99_upper n_eff Rhat, it will already work.

from metabma.

danheck avatar danheck commented on June 3, 2024

Okay, I think I will just leave the names as they are. I am a bit hesitant due to other dependencies (e.g., JASP).

Keeping the current naming scheme also has the benefit that it is not necessary that metaBMA is submitted before your package. You could disable unit tests with ci values other than 95% with:
if(packageVersion("metaBMA") < "0.6.4") ...

Anyways, I will of course still check everything and submit the revision asap. Thanks again for pointing out the issue.

from metabma.

strengejacke avatar strengejacke commented on June 3, 2024

This is how it looks (and works) with current dev of metaBMA.

library(metaBMA)
library(parameters)
data(towels)

set.seed(123)
m1 <- meta_bma(logOR, SE, study, data = towels, ci = 0.95)
model_parameters(m1)
#> Parameter | Coefficient |   SE |        95% CI |    BF |  Rhat |     ESS
#> ------------------------------------------------------------------------
#> averaged  |        0.20 | 0.09 | [ 0.03, 0.37] |       |       |        
#> fixed     |        0.21 | 0.07 | [ 0.07, 0.36] | 11.97 | 1.000 | 3712.10
#> random    |        0.18 | 0.11 | [-0.03, 0.37] |  5.37 | 1.002 | 3670.80
#> 
#> Using highest density intervals as credible intervals.

set.seed(123)
m2 <- meta_bma(logOR, SE, study, data = towels, ci = 0.99)
model_parameters(m2)
#> Parameter | Coefficient |   SE |        99% CI |    BF |  Rhat |     ESS
#> ------------------------------------------------------------------------
#> averaged  |        0.20 | 0.09 | [-0.06, 0.43] |       |       |        
#> fixed     |        0.21 | 0.07 | [ 0.02, 0.39] | 11.97 | 1.000 | 3712.10
#> random    |        0.18 | 0.11 | [-0.16, 0.44] |  5.37 | 1.002 | 3670.80
#> 
#> Using highest density intervals as credible intervals.

set.seed(123)
m3 <- meta_random(logOR, SE, study, data = towels, ci = 0.95)
model_parameters(m3, ci_method = "eti")
#> Parameter | Coefficient |   SE |        95% CI |   BF |  Rhat |     ESS
#> -----------------------------------------------------------------------
#> Overall   |        0.18 | 0.10 | [-0.04, 0.37] | 2.00 | 1.000 | 3974.80
#> tau       |        0.14 | 0.10 | [ 0.03, 0.40] |      | 1.000 | 3145.40
#> 
#> Using equal-tailed intervals as credible intervals.

set.seed(123)
m4 <- meta_random(logOR, SE, study, data = towels, ci = 0.99)
model_parameters(m4, ci_method = "eti")
#> Parameter | Coefficient |   SE |        99% CI |   BF |  Rhat |     ESS
#> -----------------------------------------------------------------------
#> Overall   |        0.18 | 0.10 | [-0.16, 0.43] | 2.00 | 1.000 | 3974.80
#> tau       |        0.14 | 0.10 | [ 0.02, 0.60] |      | 1.000 | 3145.40
#> 
#> Using equal-tailed intervals as credible intervals.

set.seed(123)
m5 <- meta_fixed(logOR, SE, study, data = towels, ci = 0.95)
model_parameters(m5)
#> Parameter | Coefficient |   SE |       95% CI |    BF
#> -----------------------------------------------------
#> Overall   |        0.21 | 0.08 | [0.06, 0.36] | 11.97
#> 
#> Using highest density intervals as credible intervals.

set.seed(123)
m6 <- meta_fixed(logOR, SE, study, data = towels, ci = 0.99)
model_parameters(m6)
#> Parameter | Coefficient |   SE |       99% CI |    BF
#> -----------------------------------------------------
#> Overall   |        0.21 | 0.08 | [0.01, 0.41] | 11.97
#> 
#> Using highest density intervals as credible intervals.

Created on 2020-10-26 by the reprex package (v0.3.0)

from metabma.

IndrajeetPatil avatar IndrajeetPatil commented on June 3, 2024

closed in dfa24c6

from metabma.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.