# Direct Doubly Robust Conditional Quantile Contrasts
This is the code for the paper "Conditional Quantile Comparator: A Quantile Alternative to CATE"

As a quick summary, this method creates a function to transform values from one conditional distribution to a value of the equivalent quantile in another conditional distribution. All experiments can be found in the `Experiments` folder in seaprate notebooks for the numerical experiments and the two real data examples. The code to plot results from numerical expreiments and our ilustrative plots can be found in the `plotcode` folder. The code for our method alongside the methods of Givens et al (2024) and Kallus and Oprescu (2023) can be found in the `cqc` folder. We provide a more detailed breakdown of this code below.

# `cqc` module contents
## `CDTE`
This contains the code for the CDTE method presented in Kallus and Oprescu 2023. The paper and original code for this can be found at:
https://proceedings.mlr.press/v206/kallus23a.html

## `estimators`
This contains the code for the estimators used in the paper. All classes have `fit` and `predict` classes which can bu used to fit the model. 
Our method is presented in `grad_estimators.py` and is given by either the `DREstimator` or `CrossDREstimator` classes.
The methods of Givens et al (2024) are presented in `old_estimators.py` with the main method given by `DRInverseEstimator` and `CrossDRInverseEstimator`.

Nonparametric regression and CDF estiation methods are given in `nonparam_nuisance.py`.

Wrappers for the `sklearn` estimators are given in `sklearn_nuisance.py`.

## `cqc`
For `DREstimator` and `CrossDREstimator`, a parametrised CQC model can must be provided. Such models are given in the `models` folder.

## `losses`
The losses which are used in our approach are provided in the `losses` folder.

## `utils`
Various utility functions are provided in the `utils` folder.


# Other folders/
## `Experiments`
This contains notebooks for all the experiments in the paper.  ColonExample.ipynb contains the code for the colon cancer example, EmploymentExample.ipynb contains the code for the employment example, and `SimulatedExperiment.ipynb` contains the code for all the simulated examples. Code for the 10 dimensional experiments is also give in separate files in the `HPC` folder, these can be run without requiring any additional arguments. All experimental results are saved in the `Results` folder.
## `Plots`
This contains all the plots for the paper.
## `plotcode`
This contains the code to plot the results from the Numerical Experiments and Illustrative Plots.
## `RealData`
The contains the colon data and employment data used in the paper as well as the R code to retrieve and process the colon data.

# Datasets
## Employment data
The Employment data is taken from https://www.journals.uchicago.edu/doi/suppl/10.1086/687522/suppl_file/12062data.zip, the supplementary material for https://www.journals.uchicago.edu/doi/10.1086/687522
## Colon Cancer Data
The colon cancer data is found in the `survival` package in R.  The data is loaded with the following code:
```{r}
library(survival)
data(colon)
```
Code to convert this data from long into wide format and then save to csv can be found in `RealData/data_read.R`.

# References
Givens, J., Reeve, H. W. J., Liu, S., & Reluga, K. (2024). Conditional outcome equivalence: A quantile alternative to CATE. In A. Globerson, L. Mackey, D. Belgrave, A. Fan, U. Paquet, J. Tomczak, & C. Zhang (Eds.), Advances in neural information processing systems (Vol. 37, pp. 102634–102671). Curran Associates, Inc. https://proceedings.neurips.cc/paper_files/paper/2024/file/ba1293b663ddd4a29c6854e4d3bf766a-Paper-Conference.pdf

Kallus, N., & Oprescu, M. (2023). Robust and agnostic learning of conditional distributional treatment effects. In F. Ruiz, J. Dy, & J.-W. van de Meent (Eds.), Proceedings of the 26th international conference on artificial intelligence and statistics (Vol. 206, pp. 6037–6060). PMLR. https://proceedings.mlr.press/v206/kallus23a.html