An open API service indexing awesome lists of open source software.

https://github.com/jackmwolf/joint

Fit Joint Endpoint Models to Efficiently Estimate Treatment Effects
https://github.com/jackmwolf/joint

Last synced: 12 months ago
JSON representation

Fit Joint Endpoint Models to Efficiently Estimate Treatment Effects

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# joint

`joint` is an R package designed to efficiently estimate treatment effects in
randomized trials by jointly modeling primary and secondary efficacy endpoints.

## Installation

You can install the development version of joint from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("jackmwolf/joint")
```

## Example

```{r}
library(joint)
```

The example dataset includes $n = 200$ observations.
Participants were randomly assigned to the treatment (`A == 1`) or control (`A == 0`) conditions and four endpoints were measured (`Y1`, `Y2`, `Y3`, and `Y4`).
Categorical versions of `Y3` (`Y3_cat`; binary) and `Y4` (`Y4_cat`; ordinal with three levels) are also provided.

```{r}
data("joint_example")
head(joint_example)
```

To estimate the average treatment effect (ATE) on `Y1` while leveraging data from `Y2` and `Y3`, we could assume that the following one-factor structural equation model is correctly specified:

$$ \begin{pmatrix} Y_1 \\ Y_2 \\ Y_3 \end{pmatrix} |A \sim N\left\{\vec\nu + \gamma\vec\lambda A, \text{diag}(\vec\theta)+\vec\lambda\vec\lambda^T \right\}$$
and estimate the ATE via the maximum likelihood estimator, $\widehat\tau_\text{SEM}=\widehat\gamma\widehat\lambda_1$.
This is accomplished by `joint_sem()`:

```{r}
fit_sem <- joint_sem(
data0 = joint_example,
endpoints = c("Y1", "Y2", "Y3"),
treatment = "A"
)
```

ATE estimates along with variance estimates can be extracted using `estimate_effects()`:

```{r}
estimate_effects(fit_sem)
```
However, we suspect that the model may be misspecified, we may wish to use model averaging and additionally consider a saturated means model (which would result in unbiased and consistent treatment effect estimation) and the estimator $\widehat\tau_\text{MA}(\omega)=\omega\widehat\tau_\text{SEM}+(1-\omega)\widehat\tau_\text{Saturated}$ for $\omega \in [0,1]$.
We could then select $\omega$ using super learning (`joint_sl()`) or Bayesian model averaging (`joint_bma()`):

```{r}
set.seed(1)
fit_sl <- joint_sl(
data0 = joint_example,
endpoints = c("Y1", "Y2", "Y3"),
treatment = "A",
primary = "Y1",
n_boot = 5 # note the choice of n_boot = 5; more are recommended in practice
)
fit_sl$summary
```

## Future Work

- Support parallel computation for `joint_sl` and `joint_bma`

- Develop `summary` methods for `joint_sl` and `joint_bma` output

## References

- Wolf, J. M., Koopmeiners, J. S., & Vock, D. M. (2025). Jointly modeling multiple endpoints for efficient treatment effect estimation in randomized controlled trials. arXiv preprint arXiv:2506.03393