gertvv / gemtc

GeMTC R package: model generation for network meta-analysis
GNU General Public License v3.0
43 stars 25 forks source link

[Bug] Node-splitting models broken? #58

Closed riher closed 3 years ago

riher commented 4 years ago

Hey, first of all, thank you so much for this amazing package, you're doing god's work!

One problem I've stumbled upon though, not being able to resolve it: I can't create a node-splitting model. The error message I'm getting:

9.
FUN(X[[i]], ...)
8.
lapply(X = X, FUN = FUN, ...)
7.
sapply(data[, "study"], function(study) { sum(data[, "study"] == study) > 1 })
6.
remove.onearm(data.re, warn = TRUE)
5.
mtc.network(data.ab = data.ab, data.re = data.re, treatments = model[["network"]][["treatments"]], studies = studies)
4.
mtc.model.nodesplit(list(type = "nodesplit", linearModel = "random", network = structure(list(description = "Network", treatments = structure(list( id = structure(1:23, .Label = c(...
3.
do.call(fn, c(list(model), list(...)))
2.
mtc.model.call("mtc.model", model, ...)
1.
mtc.model(nma$network, linearModel = "random", n.chain = 3, likelihood = "normal", link = "identity", type = "nodesplit", t1 = "...", t2 = "...")

Version 0.8-7 of gemtc. Version 1.3.959 of RStudio Version 4.0.2 of R

I'd be very grateful for any pointers on how to get this to run.

Cheers

riher commented 4 years ago

I looked into it a bit more. It seems to be caused by the data (data.re) being passed as a tibble, not as a data frame.

As tidyverse is common and this is pretty obscure, applying as.data.frame somewhere to the data would be quite helpful.

// Since this is a bug in mtc.network(), I'm wondering why it only appears when trying to fit a node-splitting model, while calling mtc.network() on its own works fine...

riher commented 4 years ago

A similar error occurred with mtc.anohe. It's also fixed by this change.

gertvv commented 4 years ago

Hi Ricardo. Thanks for reporting and looking into this. The pull request is also much appreciated, I'll leave some feedback there.

vovoch commented 4 years ago

I have also found one more problem with node-splitting model (gemtc v. 0.8-7; R v. 4.0.2). It occurs with the code which worked with absolutely no problem before.

gemtc_data - a tibble with study, treatment, responders, and sampleSizecolumns.

mynetwork <- mtc.network(data.ab = as.data.frame(gemtc_data), description = "Data1")
nodespl <- mtc.nodesplit(mynetwork, linearModel = .x, n.adapt = 20000, n.iter = 180000, n.chain = 3, thin = 3)
res <- summary(nodespl)$p.value %>% as_tibble()

There are several following warnings after both fixed and random models:

# rjags::jags.model(file.model, data = syntax[["data"]], inits = syntax[["inits"]],  :
#  Unused variable "om.scale" in data
gertvv commented 3 years ago

Thanks, both issues have been fixed for the upcoming version.