glmnet_helper: Helper function(glmnet).

Description Usage Arguments Details Value Examples

View source: R/glmnet_dispatch.R

Description

Helper function that dispatches to glmnet for the post-double estimation.

Usage

1
2
3
glmnet_helper(X, Y, W, Z.trans = TRUE, cv.steps = 100,
  parallelize = FALSE, cores.to.use = NULL, lambda.set.Y = NULL,
  lambda.set.W = NULL)

Arguments

X

A matrix of covariates (must be all numeric)

Y

A vector of the target variable, of same length as the number of rows of Y, must be numeric

W

A vector of the treatment variable, of same length as the number of rows of X, must be numeric

Z.trans

A logical value indicating whether to standardize inputs, defaults to TRUE

cv.steps

The number of folds for k-fold cross-validation of the hyperparameter tuning, defaults to 100

parallelize

Whether to run the simulations in parallel, using every available core. Defaults to FALSE.

cores.to.use

The number of cores to use. If NULL (the default), uses the maximum number of cores detected by detectCores.

lambda.set.Y

Allows the user to specify lambda for the Y model, defaults to null.

lambda.set.W

Allows the user to specify lambda for the W model, defaults to null.

Details

This function does not support the full range of arguments to glmnet, intentionally. If you need something specific please refer to custom_generator.

Value

A list with two elements: The fitted W model and the fitted Y model.

Examples

1
2
3
4
5
6
  n = 2000; p = 10
  X = matrix(rnorm(n*p), n, p)
  W = rbinom(n, 1, 0.4 + 0.2 * (X[,1] > 0))
  Y = pmax(X[,1], 0) * W + X[,2] + pmin(X[,3], 0) + rnorm(n)

glmnet_helper(X = X, Y = Y, W = W, lambda.set.W = 0.7, lambda.set.Y = 0.5)

postDoubleR documentation built on Oct. 7, 2019, 5:05 p.m.