Learn R Programming

R-package-trajmsm

The trajmsm package is inspired by the paper "Marginal Structural Models with Latent Class Growth Analysis of Treatment Trajectories," published in Statistical Methods for Medical Research. Read the paper.

Integrating LCGA with MSM (termed LCGA-MSM) offers an effective way to describe treatment adherence and control time-dependent confounding. Common methods to estimate MSM parameters include Inverse Probability Weighting (IPW), which creates a pseudo-population for balanced treatment groups. In longitudinal settings, IPW adjusts for time-varying covariates impacted by previous exposures and selection bias.

In this initial version of trajmsm, we estimate LCGA-MSM parameters using IPW, g-computation, and pooled Longitudinal Targeted Maximum Likelihood Estimation (LTMLE). We also introduce an extension for time-dependent outcomes, termed LCGA-History-Restricted MSM (LCGA-HRMSM), with the same three estimators.

For access to the R codes, visit our GitHub repository.

For additional insights on trajectory analysis, check out the trajectory_analysis repository.

Copy Link

Version

Install

install.packages('trajmsm')

Monthly Downloads

259

Version

0.1.4

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Awa Diop

Last Published

June 16th, 2025

Functions in trajmsm (0.1.4)

trajmsm_ipw

Marginal Structural Model and Latent Class of Growth Analysis estimated with IPW
trajhrmsm_gform

History Restricted MSM and Latent Class of Growth Analysis estimated with G-formula.
pltmle

Counterfactual means for a Pooled LTMLE
predict_traj

Predict trajectory groups for deterministic treatment regimes
split_data

Split observed data into multiple subsets
build_traj

Wrapper for flexmix
gendata

Generate data trajectories for MSM
gformula

Counterfactual means via G-Formula
trajhrmsm_ipw

History Restricted MSM and Latent Class of Growth Analysis estimated with IPW.
inverse_probability_weighting

Inverse Probability Weighting
ggtraj

ggplot Trajectory
trajmsm_pltmle

Pooled LTMLE
trajhrmsm_pltmle

History Restricted MSM and Latent Class of Growth Analysis estimated with a Pooled LTMLE.
trajmsm_gform

Parametric g-formula