This function computes the Monte Carlo integrand for double integration in the InterXshift package. It combines the models for the outcome given mediator and exposure (q_model), the density of the mediator given exposure and covariates (r_model), and the density of the exposure given covariates (g_model).

mc_integrand_q_g_r(
  sample_a,
  sample_z,
  row_data,
  covars,
  w_names,
  q_model,
  g_model,
  r_model,
  exposure,
  mediator,
  delta,
  upper_a,
  density_type
)

Arguments

sample_a

A vector of sampled exposure values.

sample_z

A vector of sampled mediator values.

row_data

A single row of data containing covariates and outcome.

covars

A character vector of covariate names.

w_names

A character vector of baseline covariate names.

q_model

An SL object representing the outcome model.

g_model

An SL object representing the density model of exposure given covariates.

r_model

An SL object representing the density model of mediator given exposure and covariates.

exposure

The name of the exposure variable.

mediator

The name of the mediator variable.

delta

The exposure shift for the counterfactual calculation.

upper_a

The upper bound for the exposure.

density_type

A string indicating the density estimation method, either "sl" or "nonparametric".

Value

A numeric vector representing the Monte Carlo integrand values for the given sample points.