compute_nuisance_functions: Fit outcome/decision and propensity score models

View source: R/ability_compute_nuisance_functions.R

compute_nuisance_functionsR Documentation

Fit outcome/decision and propensity score models

Description

Fit (1) the decision model m^{D}(z, X_i) := \Pr(D = 1 \mid Z = z, X = X_i) and (2) the outcome model m^{Y}(z, X_i) := \Pr(Y = 1 \mid D = 0, Z = z, X = X_i) for each treatment group z \in \{0,1\} and (3) the propensity score model e(1, X_i) := \Pr(Z = 1 \mid X = X_i).

Usage

compute_nuisance_functions(
  Y,
  D,
  Z,
  V,
  d_form = D ~ .,
  y_form = Y ~ .,
  ps_form = Z ~ .,
  distribution = "bernoulli",
  n.trees = 1000,
  shrinkage = 0.01,
  interaction.depth = 1,
  ...
)

Arguments

Y

An observed outcome (binary: numeric vector of 0 or 1).

D

An observed decision (binary: numeric vector of 0 or 1).

Z

A treatment indicator (binary: numeric vector of 0 or 1).

V

Pretreatment covariates for nuisance functions. A vector, a matrix, or a data frame.

d_form

A formula for decision model where the dependent variable is D.

y_form

A formula for outcome model where the dependent variable is Y.

ps_form

A formula for propensity score model.

distribution

A distribution argument used in gbm function. Default is "bernoulli".

n.trees

Integer specifying the total number of trees to fit used in gbm function.

shrinkage

A shrinkage parameter used in gbm function.

interaction.depth

Integer specifying the maximum depth of each tree used in gbm function.

...

Additional arguments to be passed to gbm function called in crossfit

Value

A list with the following components:

z_models

A data.frame with the following columns:

idx

Index of observation.

d_pred

Predicted probability of decision.

y_pred

Predicted probability of outcome.

Z

Treatment group.

pscore

A vector of predicted propensity scores.

Examples

compute_nuisance_functions(
  Y = NCAdata$Y,
  D = ifelse(NCAdata$D == 0, 0, 1),
  Z = NCAdata$Z,
  V = NCAdata[, c("Sex", "White", "Age")],
  shrinkage = 0.01,
  n.trees = 1000
)


aihuman documentation built on April 12, 2025, 1:47 a.m.