From 05fbd6ef608ee0dbfad1820073b57bf5cd7649ed Mon Sep 17 00:00:00 2001 From: David Phillippo Date: Thu, 4 Jul 2024 14:48:01 +0100 Subject: [PATCH] Fix marginal_effects() for single target pop with survival outcome --- DESCRIPTION | 2 +- NEWS.md | 2 ++ R/marginal_effects.R | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 624c22b5..ccf972e5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: multinma Title: Bayesian Network Meta-Analysis of Individual and Aggregate Data -Version: 0.7.1.9001 +Version: 0.7.1.9002 Authors@R: person(given = c("David", "M."), family = "Phillippo", diff --git a/NEWS.md b/NEWS.md index 14a21e76..f3d27238 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,8 @@ * Fix: Predictions for non-proportional hazards IPD NMA or ML-NMR survival models using `aux_regression = ~.trt` were incorrectly omitting the treatment effects on the auxiliary parameter(s) in some cases (#43). +* Fix: Calling `marginal_effects()` for survival outcomes with a single target +population previously gave an error. # multinma 0.7.1 diff --git a/R/marginal_effects.R b/R/marginal_effects.R index 2f1b0452..d799e037 100644 --- a/R/marginal_effects.R +++ b/R/marginal_effects.R @@ -207,7 +207,7 @@ marginal_effects <- function(object, vars <- intersect(c(".study", ".time", ".quantile", ".category"), colnames(pred_meta)) if (".time" %in% vars) { - pred_meta <- dplyr::group_by(pred_meta, .data$.study, .data$.trt) %>% + pred_meta <- { if (".study" %in% vars) dplyr::group_by(pred_meta, .data$.study, .data$.trt) else dplyr::group_by(pred_meta, .data$.trt) } %>% dplyr::mutate(.time_id = 1:dplyr::n()) %>% dplyr::ungroup()