R package for ensemble estimation of Riesz Representers for a family of statistical functionals.
To install SuperRiesz
directly from Github:
remotes::install_github("herbps10/SuperRiesz")
Suppose we observe data
If
The random variable
For more details, RieszNet and ForestRiesz: Automatic Debiased Machine Learning with Neural Nets and Random Forests by Chernozhukov et al. (2022) has a nice overview of the theory. See also Automatic Debiased Machine Learning via Riesz Regression by Chernozhukov et al. (2021).
The primary function is super_riesz
.
Arguments:
data
: data frame containing all observations.alternatives
: named list containing any alternative versions of the dataset.library
: vector or list of candidate learners.m
: function defining the parameter mapping.folds
: number of cross-validation folds (default = 5)
Estimate the Riesz Representer for the Average Treatment Effect:
# Simulate data
library(tidyverse)
N <- 1e3
set.seed(152)
data <- tibble(
W = runif(N, -1, 1),
A = rbinom(N, 1, plogis(W)),
Y = rnorm(N, mean = W + A, sd = 0.5)
)
vars <- c("W", "A")
m <- \(alpha, data) alpha(data("treatment")) - alpha(data("control"))
fit <- super_riesz(
data[, vars],
list(
"control" = mutate(data[, vars], A = 0),
"treatment" = mutate(data[, vars], A = 1)
),
library = c("linear", "nn"),
m = m
)
predict(fit, data[, vars])
Learner that always returns a constant
Parameters:
constant
: constant to return
Linear learner based on optim
.
Parameters:
constrain_positive
: whether to constrain predictions to be positive (true or false)
General neural network learner based on torch
Parameters:
architecture
: function which has a single parameter, the input dimension, and returns atorch
neural network architecture.learning_rate
: learning rate (positive float)epochs
: number of training epochs (integer)verbose
: logicalseed
: torch random seed (optional)
Simple neural network learner based on torch
.
Parameters:
hidden
: number of neurons in each hidden layer (integer)layers
: number of layers (integer)learning_rate
: training learning rate (positive float)epochs
: number of training epochs (integer)dropout
: dropout in hidden layer during training (float between 0 and 1)constrain_positive
: whether to constrain predictions to be positive (true or false)verbose
: logicalseed
: torch random seed (optional)
Linear model learner based on torch
Parameters:
learning_rate
: training learning rate (positive float)epochs
: number of training epochs (integer)