Modeling Covariate Transition for Efficient Estimation of Longitudinal Treatment Effects in Randomized Experiments
This repository contains the implementation of the ICML 2026 paper, "Modeling Covariate Transition for Efficient Estimation of Longitudinal Treatment Effects in Randomized Experiments ," by Naoki Chihara, Tatsushi Oka, Yasuko Matsubara, Yasushi Sakurai, and Shota Yasui.
-
Clone this repository.
git clone https://github.com/C-Naoki/dynamic-adjustment.git
-
Construct a virtual environment and install the required packages.
make install
- Note that it requires pyenv and uv.
- If you prefer not to use them, you can also use
requirements.txtcreated based onpyproject.toml.
Specifically, the above command performs the following steps:
- if necessary, install Python 3.11.13 using pyenv, and then switch to this version.
- create a virtual environment based on Python 3.11.13
- install packages in
pyproject.toml. - attach the path file (i.e.,
*.pth) in thesite-packages/for extending module search path.
Please check the
Makefilefor more details. -
Run quick demo.
bash bin/demo.sh
If you want the command to continue running after logging out, you use
-noption as shown below (using nohup).bash bin/demo.sh -n
- The execution log is saved in
nohup/directory.
- The execution log is saved in
import numpy as np
from src.models.dynamicra.model import DynamicRAEstimator
from src.utils import build_arrays
X, Y, W, T = build_arrays(data)
estimator = DynamicRAEstimator(
method='dynamicra',
regmodel_name='ols',
transmodel_name='var',
)
results = estimator.estimate(
X=X,
Y=Y,
W=W,
times=list(range(T)),
treatment_path=np.ones(T),
control_path=np.zeros(T),
variance_type='moment',
)
for result in results:
print(
f"t={result['time']}: "
f"ATE={result['mu']:.3f}, "
f"95% CI=({result['ci_lower']:.3f}, {result['ci_upper']:.3f})"
)It expects a long-format pandas.DataFrame with the following columns:
| Column | Default name | Type | Description |
|---|---|---|---|
| Unit ID | id |
int | Experimental unit identifier. |
| Time | date |
int | Integer time index from 0 to T - 1. |
| Feature | feature |
str | Variable name, e.g., Y, W, X1, ... |
| Value | value |
float | Numeric value of that feature. |
Required features are:
Y: outcome.W: treatment assignment, encoded as integer arms such as0and1.- Covariates: all non-
Y/Wfeatures are used.
Example:
id,date,feature,value
1,0,Y,2.31
1,0,W,0
1,0,X1,0.42
1,0,X2,-1.10
1,1,Y,2.76
1,1,W,1
1,1,X1,0.50
1,1,X2,-0.87
If you use this code for your research, please consider citing our paper.