Learn R Programming

TrialEmulation

This package implements algorithms to conduct a sequence of target trials analysis.

Installation

The package is available on CRAN:

install.packages('TrialEmulation')

To install the latest development version from github:

remotes::install_github("Causal-LDA/TrialEmulation")

Getting Started

Please see our Getting Started vignette for information on how to work with this package.

A manuscript is in preparation to fully describe the methodology.

Copy Link

Version

Install

install.packages('TrialEmulation')

Monthly Downloads

375

Version

0.0.4.5

License

Apache License (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Isaac Gravestock

Last Published

June 13th, 2025

Functions in TrialEmulation (0.0.4.5)

fit_outcome_model

Method for fitting outcome models
initiators

A wrapper function to perform data preparation and model fitting in a sequence of emulated target trials
outcome_data

Outcome Data Accessor and Setter
robust_calculation

Robust Variance Calculation
print.TE_weight_summary

Print a weight summary object
set_switch_weight_model

Set switching weight model
te_model_ex

Example of a fitted marginal structural model object
te_model_fitter-class

Outcome Model Fitter Class
set_outcome_model

Specify the outcome model
te_data_ex

Example of a prepared data object
save_expanded_data

Method to save expanded data
stats_glm_logit

Fit outcome models using stats::glm
show_weight_models

Show Weight Model Summaries
save_to_csv

Save expanded data as CSV
te_datastore-class

te_datastore
predict_marginal

Predict marginal cumulative incidences with confidence intervals for a target trial population
ipw_data

IPW Data Accessor and Setter
parsnip_model

Fit outcome models using parsnip models
read_expanded_data

Method to read expanded data
set_data

Set the trial data
set_expansion_options

Set expansion options
trial_msm

Fit the marginal structural model for the sequence of emulated trials
trial_sequence-class

Trial Sequence class
te_parsnip_model-class

Fit Models using parsnip
te_outcome_model-class

Fitted Outcome Model Object
trial_sequence

Create a sequence of emulated target trials object
vignette_switch_data

Example of expanded longitudinal data for sequential trial emulation
sample_expanded_data

Internal method to sample expanded data
summary.TE_data_prep

Summary methods
te_stats_glm_logit-class

Fit Models using logistic stats::glm
trial_example

Example of longitudinal data for sequential trial emulation
save_to_datatable

Save expanded data as a data.table
save_to_duckdb

Save expanded data to DuckDB
te_data-class

TrialEmulation Data Class
te_outcome_fitted-class

Fitted Outcome Model Object
te_outcome_data-class

TrialEmulation Outcome Data Class
weight_model_data_indices

Data used in weight model fitting
set_censor_weight_model

Set censoring weight model
select_data_cols

Select Data Columns
te_datastore_csv-class

te_datastore_csv, functions and methods
te_datastore_duckdb-class

te_datastore_duckdb, functions and methods
data_manipulation

Data Manipulation Function
check_newdata

Check Data used for Prediction
data_preparation

Prepare data for the sequence of emulated target trials
case_control_sampling_trials

Case-control sampling of expanded data for the sequence of emulated trials
calculate_weights

Calculate Inverse Probability of Censoring Weights
TrialEmulation-package

TrialEmulation Package
censor_func

Censoring Function in C++
data_censored

Example of longitudinal data for sequential trial emulation containing censoring
calculate_predictions

Calculate and transform predictions
expand

Expand Function
fit_msm

Fit the marginal structural model for the sequence of emulated trials
fit_weights_model

Method for fitting weight models
load_expanded_data

Method to read, subset and sample expanded data
expand_trials

Expand trials
internal-methods

Internal Methods
expand_until_switch

Check Expand Flag After Treatment Switch