diff --git a/DESCRIPTION b/DESCRIPTION index 08cc72d0..c87d18e7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: heemod Title: Models for Health Economic Evaluation -Version: 0.7.0 +Version: 0.7.1 Authors@R: c( person("Antoine", "Filipovic-Pierucci", email = "pierucci@gmail.com", role = c("aut", "cre")), person("Kevin", "Zarca", email = "kevin.zarca@urc-eco.fr", role = "aut"), diff --git a/NEWS.md b/NEWS.md index 9d80c51c..bf13085d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# heemod 0.7.1 + +## Bugfixes + + * Fixed an error resulting in incorrect covariance analysis results when relations between values and parameters were negative. + # heemod 0.7.0 ## Breaking changes diff --git a/R/covariance.R b/R/covariance.R index 125c51c7..798ef0d9 100644 --- a/R/covariance.R +++ b/R/covariance.R @@ -30,14 +30,16 @@ compute_cov <- function(psa) { )) res <- stats::lm(form, data = data_trans) - tot <- sum(stats::coef(res)[-1]) + val <- abs(stats::coef(res)[-1]) + tot <- sum(val) r2 <- summary(res)$r.squared if (r2 < .99) { warning(sprintf( - "Only %.0f%% of variance explained, results may be inaccurate." + "Only %.0f%% of variance explained, results may be inaccurate.", + r2 * 100 )) } - as.data.frame(as.list(stats::coef(res)[-1] / tot * r2)) + as.data.frame(as.list(val / tot * r2)) } psa$psa %>% diff --git a/inst/examples/example_update.R b/inst/examples/example_update.R index 23ee6ff4..67dabf5f 100644 --- a/inst/examples/example_update.R +++ b/inst/examples/example_update.R @@ -44,7 +44,7 @@ res <- run_model( # generating table with new parameter sets new_tab <- data.frame( - age_init = 40:80 + age_init = 40:45 ) # with run_model result @@ -55,7 +55,7 @@ summary(ndt) # using weights new_tab2 <- data.frame( - age_init = 40:80, + age_init = 40:45, .weights = runif(41) ) ndt2 <- update(res, newdata = new_tab2) diff --git a/man/update-model.Rd b/man/update-model.Rd index 76c24847..a841638f 100644 --- a/man/update-model.Rd +++ b/man/update-model.Rd @@ -110,7 +110,7 @@ res <- run_model( # generating table with new parameter sets new_tab <- data.frame( - age_init = 40:80 + age_init = 40:45 ) # with run_model result @@ -121,7 +121,7 @@ summary(ndt) # using weights new_tab2 <- data.frame( - age_init = 40:80, + age_init = 40:45, .weights = runif(41) ) ndt2 <- update(res, newdata = new_tab2)