xlasso: X-learner implemented via glmnet (lasso)

Description Usage Arguments Examples

View source: R/xlasso.R

Description

X-learner as proposed by Kunzel, Sekhon, Bickel, and Yu (2017), implemented via glmnet (lasso)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
xlasso(
  x,
  w,
  y,
  alpha = 1,
  k_folds_mu1 = NULL,
  k_folds_mu0 = NULL,
  k_folds_p = NULL,
  lambda_t = NULL,
  lambda_x = NULL,
  lambda_w = NULL,
  lambda_choice = c("lambda.min", "lambda.1se"),
  mu1_hat = NULL,
  mu0_hat = NULL,
  p_hat = NULL
)

Arguments

x

the input features

w

the treatment variable (0 or 1)

y

the observed response (real valued)

alpha

tuning parameter for the elastic net

k_folds_mu1

number of folds for learning E[Y|X,W=1]

k_folds_mu0

number of folds for learning E[Y|X,W=0]

k_folds_p

number of folds for learning E[W|X]

lambda_t

user-supplied lambda sequence for cross validation in learning E[y|x,w=0] and E[y|x,w=1]

lambda_x

user-supplied lambda sequence for cross validation in learning E[d1|x] and E[d0|x] where d1 = y1 - E[y|x,w=0] and d0 = y0 - E[y|x,w=1]

lambda_w

user-supplied lambda sequence for cross validation in learning E[w|x]

lambda_choice

how to cross-validate; choose from "lambda.min" or "lambda.1se"

mu1_hat

pre-computed estimates on E[Y|X,W=1] corresponding to the input x. xlasso will compute it internally if not provided.

mu0_hat

pre-computed estimates on E[Y|X,W=0] corresponding to the input x. xlasso will compute it internally if not provided.

p_hat

pre-computed estimates on E[W|X] corresponding to the input x. xlasso will compute it internally if not provided.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
n = 100; p = 10

x = matrix(rnorm(n*p), n, p)
w = rbinom(n, 1, 0.5)
y = pmax(x[,1], 0) * w + x[,2] + pmin(x[,3], 0) + rnorm(n)

xlasso_fit = xlasso(x, w, y)
xlasso_est = predict(xlasso_fit, x)

## End(Not run)

xnie/rlearner documentation built on April 11, 2021, 12:49 a.m.