giabaio / BCEA

Bayesian Cost Effectiveness Analysis. Given the results of a Bayesian model (possibly based on MCMC) in the form of simulations from the posterior distributions of suitable variables of costs and clinical benefits for two or more interventions, produces a health economic evaluation. Compares one of the interventions (the "reference") to the others ("comparators"). Produces many summary and plots to analyse the results
https://gianluca.statistica.it/software/bcea/
GNU General Public License v3.0
40 stars 16 forks source link

error not clear when providing data.frames instead of matrices #31

Closed David-rios closed 3 years ago

David-rios commented 3 years ago

Hi! Pretty minor but error message when providing data frames instead of matrices to bcea could be clearer. Reproducible example below


library(BCEA)
c1 <- data.frame(c1 = runif(100),
                 c2 = runif(100) )

e1 <-data.frame(c1 = runif(100),
                c2 = runif(100))

m <-bcea(c = as.matrix(c1) ,e =  as.matrix(e1) ,interventions = c("Intervention", "SoC"),Kmax = 60,ref = 1)
class(m)
#> [1] "bcea"
m <-bcea(c = c1 ,e =  e1 ,interventions = c("Intervention", "SoC"),Kmax = 60,ref = 1)
#> Error in rep(e, K) * rep(k, each = n.sim * n.comparators): non-numeric argument to binary operator

Created on 2021-03-02 by the reprex package (v0.3.0)

giabaio commented 3 years ago

The dev version of BCEA, available from GitHub and soon to be submitted to CRAN does clarify the error. If you test the code on the 2.4.1 version, you get

> m <-bcea(c = c1 ,e =  e1 ,interventions = c("Intervention", "SoC"),Kmax = 60,ref = 1)
Error: eff and cost must be matrices.

We may decide to convert anything that isn't a matrix on the fly to even avoid this...