dmphillippo / multinma

Network meta-analysis of individual and aggregate data in Stan
https://dmphillippo.github.io/multinma
35 stars 17 forks source link

Integration issues in ML-NMR Plaque Psoriasis example #26

Closed bct0022 closed 8 months ago

bct0022 commented 1 year ago

Hi, I appreciate the great effort to create the package. I have some problems while running the ML-NMR example with multinma package. The problem may be due to the call of density function/distribution of the covariates as below. Could any one help me figure it out? Thank you in advance. Error 1:

ipd_summary <- pso_ipd %>% group_by(studyc) %>% summarise_at(vars(weight, durnpso, bsa), list(mean = mean, sd = sd, min = min, max = max)) %>% pivot_longer(weight_mean:bsa_max, namessep = "", names_to = c("covariate", ".value")) %>%

Assign distributions

mutate(dist = recode(covariate, bsa = "dlogitnorm", durnpso = "dgamma", weight = "dgamma")) %>%

Compute density curves

group_by(studyc, covariate) %>% mutate(value = if_else(dist == "dlogitnorm", list(seq(0, 1, length.out = 101)), list(seq(min0.8, max1.2, length.out = 101)))) %>% unnest(cols = value) %>% mutate(dens = eval(call(first(dist), x = value, mean = first(mean), sd = first(sd))))

============================================== Error in mutate(): ℹ In argument: dens = eval(call(first(dist), x = value, mean = first(mean), sd = first(sd))). ℹ In group 1: studyc = "IXORA-S", covariate = "bsa". Caused by error in dnorm(): ! formal argument "mean" matched by multiple actual arguments Backtrace:

  1. ... %>% ...
  2. base::eval(call(first(dist), x = value, mean = first(mean), sd = first(sd)))
    1. base::eval(call(first(dist), x = value, mean = first(mean), sd = first(sd)))
    2. logitnorm::dlogitnorm(...)
    3. base::ifelse(...)

Error 2:

pso_net <- add_integration(pso_net, durnpso = distr(qgamma, mean = durnpso_mean, sd = durnpso_sd), prevsys = distr(qbern, prob = prevsys), bsa = distr(qlogitnorm, mean = bsa_mean, sd = bsa_sd), weight = distr(qgamma, mean = weight_mean, sd = weight_sd), psa = distr(qbern, prob = psa), n_int = 1000)

============================================== Error in pmap(): ℹ In index: 3. Caused by error in dplyr::transmute(): ℹ In argument: .int_bsa = list(...). ℹ In row 1. Caused by error in qnorm(): ! formal argument "mean" matched by multiple actual arguments Backtrace:

  1. multinma::add_integration(...)
    1. logitnorm (local) <fn>(p = <dbl>, mean = 0.326, sd = 0.1778)
dmphillippo commented 1 year ago

Hi @bct0022, I think you may have loaded the logitnorm package with library(logitnorm) after loading multinma? multinma adds some convenience wrappers for these functions but these only work if the logitnorm package is not loaded (or if multinma is loaded afterwards).