fit_cross: Cross-fitting helper

Description Usage Arguments Details Value Examples

View source: R/cross_fit_helper.R

Description

Implements k-fold cross-fitting with the supplied method, is a helper function that the user should not need.

Usage

1
fit_cross(Y_def, X_def, W_def, data.size, fun.call, k.folds, method_used)

Arguments

Y_def

An argument that control the Y input (used for argument passing)

X_def

An argument that control the X input (used for argument passing)

W_def

An argument that control the W input (used for argument passing)

data.size

Parses the length of the dataset (nrow) for splitting.

fun.call

Designates the function to use for cross-fitting.

k.folds

The number of k-folds for daataset splitting, defaults to 3.

method_used

The method to used when applying predict trough a helper function (do not worry about this!).

Details

This only implements the k-fold crossfitting, not the n.repeat simulation - if you intend to use this function, it works as a 'naive' double machine learning.

Value

A list with four elements: The mean estimate of θ, the standard error of the mean estimate, the associated moment conditions, and the estimated heterogenous effects for a combined estimate from a simulation run.

Examples

1
2
3
4
5
6
7
8
  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)


fit_cross(Y_def = Y, X_def = X, W_def = W, data.size = 2000, fun.call = glmnet_helper(X,Y,W),
k.folds = 3, method_used = "glmnet")

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