Package {CEACT}


Type: Package
Title: Cost-Effectiveness Analysis Toolkit for Clinical Trials
Version: 0.6.2
Author: Imad El Badisy [aut, cre]
Maintainer: Imad El Badisy <elbadisyimad@gmail.com>
Description: Provides tools for trial-based economic evaluation of healthcare interventions. Computes and visualizes incremental cost-effectiveness ratios, cost-effectiveness acceptability curves, cost-effectiveness planes, net monetary benefit tables, and one-way deterministic sensitivity analyses. Supports cost-utility analyses using observed summaries and non-parametric bootstrap uncertainty, and multiply imputed data through Rubin's rules (Rubin 1987, ISBN:9780471087052) or bootstrap-then-impute resampling (Brand et al. 2019 <doi:10.1002/sim.7956>).
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.3
URL: https://CRAN.R-project.org/package=CEACT
BugReports: https://github.com/ielbadisy/CEACT/issues
Depends: R (≥ 3.5.0)
Imports: basetable (≥ 1.4.5), ggplot2, boot, parallel
Suggests: mice, mimar, knitr, rmarkdown, testthat (≥ 3.0.0)
Config/testthat/edition: 3
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2026-11-13 22:07:36 UTC; imad-el-badisy
Repository: CRAN
Date/Publication: 2026-11-14 15:40:32 UTC

Deprecated functions in CEACT

Description

These functions were renamed to glued lowercase names and will be removed in a future release. Use the new names instead.

Usage

boot_icer(...)

compute_nmb_ceac(...)

dsa_icer(...)

plot_ceac(...)

plot_ceplane(...)

plot_dsa(...)

simulate_ce_trial(...)

Arguments

...

Arguments passed to the new function.

Value

The result of the new function.


Bootstrap Incremental Cost, Effect, ICER, and Net Benefit

Description

Performs non-parametric stratified bootstrap resampling for a two-arm trial-based economic evaluation. Resampling is stratified by trial group to preserve arm sizes.

Usage

booticer(formula, data, ref, R = 1000, ci.type = "bca", na.omit = TRUE)

Arguments

formula

A formula of the form cost + effect ~ group.

data

A data frame containing the variables in the formula.

ref

Reference group label.

R

Number of bootstrap replications.

ci.type

Confidence interval type passed to boot::boot.ci().

na.omit

Logical; whether to remove rows with missing values.

The ICER point estimate is the observed ratio of mean differences. The ICER has no bootstrap mean, standard error or bias: a mean of ratios is unstable when the incremental effect is near zero. Its interval is the percentile interval of the bootstrap ratios, reported only when all replicates lie in the NE or in the SW quadrant of the cost-effectiveness plane. Otherwise it is NA, a note is attached, and uncertainty should be read from the CEAC or the INMB (computenmbceac()). The share of replicates in each quadrant is returned in quadrants.

Value

An object of class boot_icer containing a summary table (summary), the bootstrap distribution (boot_dist), the observed estimates (observed), the share of replicates per quadrant (quadrants), a note on the ICER interval (or NULL), the boot object, formula, reference group, and matched call.

Examples

df <- simulatecetrial(n = 100, seed = 123)
res <- booticer(cost + effect ~ group, data = df, ref = "control", R = 200)
summary(res)


Cost-Effectiveness Analysis Summary for a Two-Arm Trial

Description

Computes observed cost-effectiveness summaries comparing one treatment group with one reference group. The incremental cost-effectiveness ratio is ICER = (mean(cost_treatment) - mean(cost_reference)) / (mean(effect_treatment) - mean(effect_reference)).

Usage

cea(formula, data, ref, na.omit = TRUE)

Arguments

formula

A formula of the form cost + effect ~ group.

data

A data frame containing the variables used in the formula.

ref

Character string specifying the reference group.

na.omit

Logical; whether to remove rows with missing values.

Value

An object of class cea, a data frame with group means, standard deviations, differences, confidence intervals, and p-values. Attributes include ICER, delta_cost, delta_effect, formula, ref, and call.

Examples

df <- simulatecetrial(n = 100, seed = 123)
res <- cea(cost + effect ~ group, data = df, ref = "control")
summary(res)


Compute Net Monetary Benefit and CEAC Table

Description

Computes expected incremental net monetary benefit (INMB) and the probability that treatment is cost-effective across willingness-to-pay thresholds. For a two-arm trial, INMB(k) = k * DeltaEffect - DeltaCost.

Usage

computenmbceac(
  x,
  data = NULL,
  wtp_range = seq(0, 1e+05, 1000),
  ref = NULL,
  R = 1000,
  ...
)

Arguments

x

Either a booticer object or a formula of the form cost + effect ~ group.

data

Data frame required when x is a formula.

wtp_range

Numeric vector of willingness-to-pay thresholds.

ref

Reference group label required when x is a formula.

R

Number of bootstrap replications used when x is a formula.

...

Additional arguments passed to booticer() for formula input.

Value

An object of class "nmb_ceac" with columns WTP, ENMB, and Prob_CE.

Examples

df <- simulatecetrial(n = 100, seed = 123)
ceac_tbl <- computenmbceac(cost + effect ~ group, data = df,
                             ref = "control", R = 200,
                             wtp_range = seq(0, 50000, 5000))
head(ceac_tbl)


Deterministic Sensitivity Analysis for ICER or INMB

Description

Varies one treatment-arm parameter while holding observed reference-arm data fixed, then recomputes the ICER or incremental net monetary benefit.

Usage

dsaicer(formula, data, param, range, ref, metric = "ICER", k = 1000)

Arguments

formula

A formula of the form cost + effect ~ group.

data

A data frame.

param

Name of the variable to vary, usually the cost or effect variable from formula.

range

Numeric vector of values assigned to the treatment arm.

ref

Reference group label.

metric

Either "ICER" or "INMB". "NMB" is accepted as an alias for "INMB".

k

Willingness-to-pay threshold used for INMB.

Value

A data frame with varied parameter values and resulting metric.

Examples

df <- simulatecetrial(n = 100, seed = 123)
dsa <- dsaicer(cost + effect ~ group, data = df, param = "effect",
                range = seq(0.74, 0.82, 0.02), ref = "control",
                metric = "INMB", k = 20000)
head(dsa)

Bootstrap-Then-Impute Cost-Effectiveness Analysis

Description

Resamples the incomplete data within each group, imputes every bootstrap sample with a user-supplied imputation function, and estimates the incremental cost and effect on each completed sample (averaged over the imputations of that sample). The observed estimate is the Rubin point estimate (mean over imputations) from the original data completed once by imputefun; intervals for the incremental cost and effect are percentile intervals. The ICER is handled as in booticer(): observed ratio of mean differences, no bootstrap mean or bias, and a percentile interval only when all replicates lie in the NE or in the SW quadrant. Bootstrapping before imputing propagates imputation uncertainty into the bootstrap distribution, so the result can be passed directly to computenmbceac(), plotceplane(), and plotceac().

Usage

miboot(
  formula,
  data,
  ref,
  imputefun,
  R = 1000,
  weights = NULL,
  conf = 0.95,
  ncores = 1L,
  seed = NULL
)

Arguments

formula

A formula of the form cost + effect ~ group.

data

A data frame with missing values in cost, effect, or covariates. The group variable must be complete.

ref

Reference group label.

imputefun

A function taking one data frame (a bootstrap sample) and returning its completed version: a data frame, a list of data frames, a mimar_imputation, or a mids object. With several completed data sets the bootstrap estimate is their mean. If the function adds a weight column (for example after matching each completed sample), name it in weights.

R

Number of bootstrap replications.

weights

Optional name of a case-weight column in each completed data set.

conf

Confidence level of the percentile intervals.

ncores

Number of cores used through parallel::mclapply() (Unix-alikes only; ignored on Windows).

seed

Optional seed. Results are reproducible for a given seed and ncores.

Value

An object of class c("miboot", "boot_icer") with the same components as booticer() (summary, boot_dist, observed, quadrants, note, formula, ref, call) plus R, failed (number of replications in which imputation or estimation failed and was dropped), and m (completed data sets per replication).

References

Brand J, van Buuren S, le Cessie S, van den Hout W. Combining multiple imputation and bootstrap in the analysis of cost-effectiveness trial data. Stat Med. 2019;38(2):210-220.

Schomaker M, Heumann C. Bootstrap inference when using multiple imputation. Stat Med. 2018;37(14):2252-2266.

Examples

df <- simulatecetrial(n = 60, seed = 123)
df$cost[sample(nrow(df), 20)] <- NA
hotdeck <- function(d) {
  for (g in levels(d$group)) {
    i <- d$group == g
    miss <- i & is.na(d$cost)
    d$cost[miss] <- sample(d$cost[i & !is.na(d$cost)], sum(miss),
                           replace = TRUE)
  }
  d
}
res <- miboot(cost + effect ~ group, data = df, ref = "control",
              imputefun = hotdeck, R = 50, seed = 1)
summary(res)


Cost-Effectiveness Analysis on Multiply Imputed Data

Description

Estimates the incremental cost, incremental effect, ICER, and incremental net monetary benefit (INMB) in each completed data set, then pools them with Rubin's rules. Within-imputation variances use the unequal-variance (Welch-type) standard error of each mean difference, and the cost-effect covariance is carried through so that the INMB variance is correct at every willingness-to-pay threshold. Degrees of freedom follow Barnard and Rubin (1999) with complete-data degrees of freedom n - 2.

Usage

micea(
  formula,
  data,
  ref,
  wtp_range = seq(0, 1e+05, 1000),
  weights = NULL,
  conf = 0.95
)

Arguments

formula

A formula of the form cost + effect ~ group.

data

Multiply imputed data: a mimar_imputation object (from mimar::impute()), a mids object (from mice::mice()), or a list of completed data frames.

ref

Reference group label.

wtp_range

Numeric vector of willingness-to-pay thresholds.

weights

Optional name of a numeric column holding case weights (for example matching or inverse probability weights), looked up in each completed data set so weights can differ across imputations. The within-imputation variance treats weights as fixed.

conf

Confidence level.

Details

The probability that the treatment is cost-effective at threshold k is P(INMB(k) > 0) from the pooled t reference distribution.

Value

An object of class micea: a list with summary (pooled estimates, standard errors, confidence intervals, degrees of freedom, and fraction of missing information), ceac (an nmb_ceac table usable with plotceac()), estimates (per-imputation estimates), the pooled components Qbar, Ubar, B, and Tvar, and m, n, ref, formula, and call.

References

Rubin DB. Multiple Imputation for Nonresponse in Surveys. Wiley; 1987.

Barnard J, Rubin DB. Small-sample degrees of freedom with multiple imputation. Biometrika. 1999;86(4):948-955.

Examples

df <- simulatecetrial(n = 100, seed = 123)
set.seed(1)
df$cost[sample(nrow(df), 40)] <- NA
# Toy within-group hot-deck imputation, repeated five times
imps <- lapply(1:5, function(i) {
  d <- df
  for (g in levels(d$group)) {
    miss <- d$group == g & is.na(d$cost)
    pool <- d$cost[d$group == g & !is.na(d$cost)]
    d$cost[miss] <- sample(pool, sum(miss), replace = TRUE)
  }
  d
})
res <- micea(cost + effect ~ group, data = imps, ref = "control",
             wtp_range = seq(0, 50000, 5000))
res
head(res$ceac)


Deprecated Tornado Plot Alias

Description

plot_tornado() is kept for backward compatibility. Use plotdsa() instead. The plot produced by CEACT is a one-way deterministic sensitivity curve, not a conventional tornado plot.

Usage

plot_tornado(df, metric = "ICER")

Arguments

df

A data frame from dsaicer().

metric

Character string. Either "ICER" or "INMB".

Value

A ggplot object.


Plot Cost-Effectiveness Acceptability Curve

Description

Plots the probability that treatment is cost-effective across willingness-to-pay thresholds.

Usage

plotceac(
  x,
  data = NULL,
  wtp_range = seq(0, 1e+05, 1000),
  ref = NULL,
  R = 1000,
  ...
)

Arguments

x

A booticer object, nmb_ceac object, or formula of the form cost + effect ~ group.

data

Data frame required when x is a formula.

wtp_range

Numeric vector of willingness-to-pay thresholds.

ref

Reference group label required when x is a formula.

R

Number of bootstrap replications used when x is a formula.

...

Additional arguments passed to ggplot2::labs().

Value

A ggplot object.

Examples

df <- simulatecetrial(n = 100, seed = 123)
res <- booticer(cost + effect ~ group, data = df, ref = "control", R = 200)
plotceac(res, wtp_range = seq(0, 50000, 5000))

Plot Cost-Effectiveness Plane

Description

Visualizes bootstrap replicates of incremental cost and incremental effect.

Usage

plotceplane(boot_icer_result, k = NULL, subtitle = NULL)

Arguments

boot_icer_result

A booticer object from booticer().

k

Optional willingness-to-pay threshold shown as a straight line with slope k.

subtitle

Optional subtitle text.

Value

A ggplot object.

Examples

df <- simulatecetrial(n = 100, seed = 123)
res <- booticer(cost + effect ~ group, data = df, ref = "control", R = 200)
plotceplane(res, k = 20000)

One-Way Deterministic Sensitivity Plot

Description

Creates a one-way sensitivity plot from a data frame generated by dsaicer().

Usage

plotdsa(df, metric = "ICER")

Arguments

df

A data frame from dsaicer().

metric

Character string. Either "ICER" or "INMB".

Value

A ggplot object.

Examples

df <- simulatecetrial(n = 100, seed = 123)
dsa <- dsaicer(cost + effect ~ group, data = df, param = "effect",
                range = seq(0.74, 0.82, 0.02), ref = "control")
plotdsa(dsa, metric = "ICER")

Simulate a Two-Arm Trial for Cost-Effectiveness Analysis

Description

Generates individual-level cost and effect outcomes for a simple two-arm randomized clinical trial. The function is intended for examples, tutorials, tests, and manuscript demonstrations.

Usage

simulatecetrial(
  n = 200,
  mean_cost = c(5000, 5600),
  sd_cost = c(900, 1000),
  mean_effect = c(0.72, 0.78),
  sd_effect = c(0.1, 0.11),
  rho = 0.15,
  seed = NULL,
  group_names = c("control", "treatment")
)

Arguments

n

Number of participants per arm.

mean_cost

Control and treatment mean costs.

sd_cost

Control and treatment cost standard deviations.

mean_effect

Control and treatment mean effects, for example QALYs.

sd_effect

Control and treatment effect standard deviations.

rho

Within-person cost-effect correlation used in a Gaussian construction.

seed

Optional random seed.

group_names

Character vector naming control and treatment arms.

Value

A data frame with cost, effect, and group.

Examples

trial <- simulatecetrial(n = 50, seed = 1)
head(trial)

Example Trial-Based Cost-Effectiveness Dataset

Description

A patient-level clinical-trial cost-effectiveness dataset with treatment assignment, total cost, QALYs, and baseline covariates. The dataset is used in teaching examples for trial-based economic evaluation and was described as being provided by the Health Services Research Unit for the textbook Economic Evaluation in Clinical Trials.

Usage

trial_cea

Format

A data frame with 500 rows and 10 variables:

id

Patient identifier.

treat

Treatment indicator, 1 for treatment and 0 for control.

cost

Total cost in US dollars.

qaly

Quality-adjusted life-years.

dissev

Disease severity, ranging approximately from 0.025 to 0.729.

race

Race indicator as supplied in the source dataset.

blcost

Baseline cost in US dollars.

blqaly

Baseline QALY.

male

Sex indicator, 1 for male and 0 for female.

group

Factor version of treat, with levels control and treatment.

Source

Health Services Research Unit example dataset used in Glick HA, Doshi JA, Sonnad SS, Polsky D. Economic Evaluation in Clinical Trials. Oxford University Press. Also distributed in the ceaR package as clintrial_cea.