Skip to content

Commit

Permalink
Merge branch 'feature/marginal_effects' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dmphillippo committed Apr 30, 2024
2 parents aaab952 + 4693cd8 commit 7415cdf
Show file tree
Hide file tree
Showing 26 changed files with 932 additions and 916 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ LinkingTo:
rstan (>= 2.26.0),
StanHeaders (>= 2.26.0)
SystemRequirements: GNU make
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Suggests:
testthat (>= 2.1.0),
Expand Down
9 changes: 6 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ ratios.
calculations with `predict()` or `marginal_effects()` from ML-NMR models that
may take longer to run. These can be controlled with the new `progress`
argument.
* Deprecation: The `trt_ref` argument to `predict()` is now soft-deprecated, and
the new argument `baseline_ref` is preferred. This makes way for the new
`marginal_effects()` functionality.
* Deprecation: The `trt_ref` argument to `predict()` has been renamed to
`baseline_ref`; using `trt_ref` is now soft-deprecated. Renaming this argument
`baseline_ref` follows the naming convention for the other arguments
(`baseline_type`, `baseline_level`) that specify the details of a provided
`baseline` distribution. This also makes way for the new `marginal_effects()`
functionality.
* Fix: Fallback formatting used by print methods when the crayon package is not
installed now works properly, rather than giving errors.
* Fix: Small bug caused `predict()` for AgD meta-regression models with new data
Expand Down
3 changes: 1 addition & 2 deletions R/multinma-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#'
#' \insertRef{methods_paper}{multinma}
#'
#' @docType package
#' @name multinma-package
#' @aliases multinma
#' @useDynLib multinma, .registration = TRUE
Expand All @@ -69,7 +68,7 @@
#' @references
#' \insertAllCited{}
#'
NULL
"_PACKAGE"

# Stop R CMD check thinking . used in pipes is an undeclared global variable
if (getRversion() >= "2.15.1") utils::globalVariables(c("."))
Expand Down
2 changes: 1 addition & 1 deletion R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
#' computationally intensive, especially for survival outcomes. Currently the
#' default is to display progress only when running interactively and
#' producing predictions for a survival ML-NMR model.
#' @param trt_ref Deprecated, use `baseline_trt` instead.
#' @param trt_ref Deprecated, renamed to `baseline_trt`.
#'
#' @details
#' # Aggregate-level predictions from IPD NMA and ML-NMR models
Expand Down
13 changes: 13 additions & 0 deletions man/multinma-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/predict.stan_nma.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions tests/testthat/test-example_diabetes.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ plot(db_releff_RE, ref_line = 0)
db_pred_FE <- predict(db_fit_FE,
newdata = data.frame(time = 3),
baseline = distr(qnorm, mean = -4.2, sd = 1.11^-0.5),
trt_ref = "Diuretic",
baseline_trt = "Diuretic",
type = "response")
db_pred_FE
plot(db_pred_FE)
Expand All @@ -135,7 +135,7 @@ plot(db_pred_FE)
db_pred_RE <- predict(db_fit_RE,
newdata = data.frame(time = 3),
baseline = distr(qnorm, mean = -4.2, sd = 1.11^-0.5),
trt_ref = "Diuretic",
baseline_trt = "Diuretic",
type = "response")
db_pred_RE
plot(db_pred_RE)
Expand Down Expand Up @@ -302,58 +302,58 @@ db_pred_FE_multi1 <- as.data.frame(predict(db_fit_FE,
newdata = data.frame(time = times),
baseline = unname(bls),
study = time,
trt_ref = "Diuretic",
baseline_trt = "Diuretic",
type = "response"))

db_pred_RE_multi1 <- as.data.frame(predict(db_fit_RE,
newdata = data.frame(time = times),
baseline = unname(bls),
study = time,
trt_ref = "Diuretic",
baseline_trt = "Diuretic",
type = "response"))

db_pred_FE_multi2 <- as.data.frame(predict(db_fit_FE,
newdata = data.frame(time = times),
baseline = bls,
study = time,
trt_ref = "Diuretic",
baseline_trt = "Diuretic",
type = "response"))

db_pred_RE_multi2 <- as.data.frame(predict(db_fit_RE,
newdata = data.frame(time = times),
baseline = bls,
study = time,
trt_ref = "Diuretic",
baseline_trt = "Diuretic",
type = "response"))

db_pred_FE_multi3 <- as.data.frame(predict(db_fit_FE,
newdata = data.frame(time = rev(times)),
baseline = bls,
study = time,
trt_ref = "Diuretic",
baseline_trt = "Diuretic",
type = "response")) %>%
arrange(.study)

db_pred_RE_multi3 <- as.data.frame(predict(db_fit_RE,
newdata = data.frame(time = rev(times)),
baseline = bls,
study = time,
trt_ref = "Diuretic",
baseline_trt = "Diuretic",
type = "response")) %>%
arrange(.study)

db_pred_FE_multi4 <- as.data.frame(predict(db_fit_FE,
newdata = data.frame(time = times),
baseline = rev(bls),
study = time,
trt_ref = "Diuretic",
baseline_trt = "Diuretic",
type = "response"))

db_pred_RE_multi4 <- as.data.frame(predict(db_fit_RE,
newdata = data.frame(time = times),
baseline = rev(bls),
study = time,
trt_ref = "Diuretic",
baseline_trt = "Diuretic",
type = "response"))

test_that("Predictions for reordered newdata/baselines works", {
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-example_parkinsons.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ plot(arm_releff_RE, ref_line = 0)
arm_pred_FE <- predict(arm_fit_FE,
baseline = distr(qnorm, mean = -0.73, sd = 21^-0.5),
type = "response",
trt_ref = 1)
baseline_trt = 1)
arm_pred_FE
plot(arm_pred_FE)

## ----arm_pred_RE, fig.height = 2------------------------------------------------------------------
arm_pred_RE <- predict(arm_fit_RE,
baseline = distr(qnorm, mean = -0.73, sd = 21^-0.5),
type = "response",
trt_ref = 1)
baseline_trt = 1)
arm_pred_RE
plot(arm_pred_RE)

Expand Down Expand Up @@ -283,15 +283,15 @@ plot(contr_releff_RE, ref_line = 0)
contr_pred_FE <- predict(contr_fit_FE,
baseline = distr(qnorm, mean = -0.73, sd = 21^-0.5),
type = "response",
trt_ref = 1)
baseline_trt = 1)
contr_pred_FE
plot(contr_pred_FE)

## ----contr_pred_RE, fig.height = 2----------------------------------------------------------------
contr_pred_RE <- predict(contr_fit_RE,
baseline = distr(qnorm, mean = -0.73, sd = 21^-0.5),
type = "response",
trt_ref = 1)
baseline_trt = 1)
contr_pred_RE
plot(contr_pred_RE)

Expand Down Expand Up @@ -444,15 +444,15 @@ plot(mix_releff_RE, ref_line = 0)
mix_pred_FE <- predict(mix_fit_FE,
baseline = distr(qnorm, mean = -0.73, sd = 21^-0.5),
type = "response",
trt_ref = 1)
baseline_trt = 1)
mix_pred_FE
plot(mix_pred_FE)

## ----mix_pred_RE, fig.height = 2------------------------------------------------------------------
mix_pred_RE <- predict(mix_fit_RE,
baseline = distr(qnorm, mean = -0.73, sd = 21^-0.5),
type = "response",
trt_ref = 1)
baseline_trt = 1)
mix_pred_RE
plot(mix_pred_RE)

Expand Down Expand Up @@ -727,7 +727,7 @@ test_that("Analysis of reordered contrast data gives same results", {
expect_equivalent_nma_summary(predict(reorder_fit_FE,
baseline = distr(qnorm, mean = -0.73, sd = 21^-0.5),
type = "response",
trt_ref = 1),
baseline_trt = 1),
contr_pred_FE,
tolerance = tol)

Expand All @@ -747,7 +747,7 @@ test_that("Analysis of reordered contrast data gives same results", {
expect_equivalent_nma_summary(predict(reorder_fit_RE,
baseline = distr(qnorm, mean = -0.73, sd = 21^-0.5),
type = "response",
trt_ref = 1),
baseline_trt = 1),
contr_pred_RE,
tolerance = tol)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-example_plaque_psoriasis.R
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ plot(pso_pred_FE_new, ref_line = c(0, 1))
## "Chiricozzi 2019" = distr(qbeta, 243, 330-243)),
## baseline_type = "response",
## baseline_level = "aggregate",
## trt_ref = "SEC_300"))
## baseline_trt = "SEC_300"))


## ----pso-full-pred-new, eval=!params$run_tests && params$eval_multinomial-------------------------
Expand Down
Loading

0 comments on commit 7415cdf

Please sign in to comment.