npcoxph: npcoxph Nonparametric robust generalized linear models for...

View source: R/npcoxph.R

npcoxphR Documentation

npcoxph Nonparametric robust generalized linear models for causal inference and marginal structural models (for some estimands). Supports flexible nonparametric conditional average treatment effect (CATE), conditional odds ratio (OR), and conditional relative risk (RR) estimation, ... where a user-specified working parametric model for the estimand is viewed as an approximation of the true estimand and nonparametrically correct inference is given for these approximations. Specifically, a causal projection of the true estimand onto the working-model is estimated; the parametric model is not assumed correct. The estimates and inference obtained by 'causalRobustGLM' are robust and nonparametrically correct, which comes at a small cost in confidence interval width relative to 'causalGLM'. Highly Adaptive Lasso (HAL) (see fit_hal), a flexible and adaptive spline regression estimator, is recommended for medium-small to large sample sizes.

Description

npcoxph Nonparametric robust generalized linear models for causal inference and marginal structural models (for some estimands). Supports flexible nonparametric conditional average treatment effect (CATE), conditional odds ratio (OR), and conditional relative risk (RR) estimation, ... where a user-specified working parametric model for the estimand is viewed as an approximation of the true estimand and nonparametrically correct inference is given for these approximations. Specifically, a causal projection of the true estimand onto the working-model is estimated; the parametric model is not assumed correct. The estimates and inference obtained by 'causalRobustGLM' are robust and nonparametrically correct, which comes at a small cost in confidence interval width relative to 'causalGLM'. Highly Adaptive Lasso (HAL) (see fit_hal), a flexible and adaptive spline regression estimator, is recommended for medium-small to large sample sizes.

Usage

npcoxph(
  formula,
  data,
  W,
  A,
  Ttilde,
  Delta,
  num_bins_t = 20,
  learning_method = c("HAL", "SuperLearner", "glm", "glmnet", "gam", "mars", "ranger",
    "xgboost"),
  cross_fit = FALSE,
  sl3_Learner_A = NULL,
  sl3_Learner_T = NULL,
  sl3_Learner_C = NULL,
  formula_T = as.formula(paste0("~ . + . *", A)),
  formula_HAL_T = paste0("~ . + h(.,", A, ") + h(.,t)"),
  HAL_args_T = list(smoothness_orders = 1, max_degree = 2, num_knots = c(10, 5, 1)),
  HAL_fit_control = list(parallel = F),
  delta_epsilon = 0.025,
  verbose = TRUE,
  ...
)

Arguments

formula

A R formula object specifying the parametric form of CATE, OR, or RR (depending on method).

data

A data.frame or matrix containing the numeric values corresponding with the nodes W, A and Y.

W

A character vector of covariates contained in data

A

A character name for the treatment assignment variable contained in data

learning_method

Machine-learning method to use. This is overrided if argument sl3_Learner is provided. Options are: "SuperLearner": A stacked ensemble of all of the below that utilizes cross-validation to adaptivelly choose the best learner. "HAL": Adaptive robust automatic machine-learning using the Highly Adaptive Lasso hal9001 Good for most sample sizes when propertly tuned. See arguments max_degree_Y0W and num_knots_Y0W. "glm": Fit nuisances with parametric model. Best for smaller sample sizes (e.g. n =30-100). See arguments glm_formula_A, glm_formula_T and glm_formula_T0. "glmnet": Learn using lasso with glmnet. Best for smaller sample sizes (e.g. n =30-100) "gam": Learn using generalized additive models with mgcv. Good for small-to-medium-small sample sizes. "mars": Multivariate adaptive regression splines with earth. Good for small-to-medium-small sample sizes. "ranger": Robust random-forests with the package Ranger Good for medium-to-large sample sizes. "xgboost": Learn using a default cross-validation tuned xgboost library with max_depths 3 to 7. Good for medium-to-large sample sizes. We recommend performing simulations checking 95 Note speed can vary significantly depending on learner choice!

cross_fit

Whether to cross-fit the initial estimator. This is always set to FALSE if argument sl3_Learner is provided. learning_method = 'SuperLearner' is always cross-fitted (default). learning_method = 'xgboost' and 'ranger' are always cross-fitted regardless of the value of cross_fit All other learning_methods are only cross-fitted if 'cross_fit=TRUE'. Note, it is not necessary to cross-fit glm, glmnet, gam or mars as long as the dimension of W is not too high. In smaller samples and lower dimensions, it may fact hurt to cross-fit.

sl3_Learner_A

A sl3 Learner object to use to estimate nuisance function P(A=1|W) with machine-learning. Note, cross_fit is automatically set to FALSE if this argument is provided. If you wish to cross-fit the learner sl3_Learner then do: sl3_Learner <- Lrnr_cv$new(sl3_Learner). Cross-fitting is recommended for all tree-based algorithms like random-forests and gradient-boosting.

sl3_Learner_T

A sl3 Learner object to use to nonparametrically [Y|A,W] with machine-learning. Note, cross_fit is automatically set to FALSE if this argument is provided. Cross-fitting is recommended for all tree-based algorithms like random-forests and gradient-boosting.

formula_T

Only used if 'learning_method By default, 'formula_T = . + A*.' so that additive learners still model treatment interactions.

formula_HAL_T

A HAL formula string to be passed to fit_hal). See the 'formula' argument of fit_hal) for syntax and example use.

HAL_args_T

A list of parameters for the semiparametric Highly Adaptive Lasso estimator for E[Y|A,W]. Possible parameters are: 1. 'smoothness_orders': Smoothness order for HAL estimator of E[Y|A,W] (see fit_hal) smoothness_order_Y0W = 1 is piece-wise linear. smoothness_order_Y0W = 0 is piece-wise constant. 2. 'max_degree': Max interaction degree for HAL estimator of E[Y|A,W] (see fit_hal) 3. 'num_knots': A vector of the number of knots by interaction degree for HAL estimator of E[Y|A=0,W] (see fit_hal). Used to generate spline basis functions. num_knots_Y0W = c(1) is equivalent to main term glmnet/LASSO. (Assuming max_degree_Y0W = 1) num_knots_Y0W = c(1,1) is equivalent to glmnet/LASSO with both main-terms and all two-way interactions (e.g. Y~ W1 + A + A W1+ W1 + W1*W2 + ...). (Assuming max_degree_Y0W = 2) num_knots_Y0W = c(10) is an additive piece-wise linear model with 10 knot points. (Assuming max_degree_Y0W = 1) num_knots_Y0W = c(10,5) is a bi-additive model with the same one-way basis functions as above, but also two-way interaction piece-wise linear basis functions generated by main-term one-way basis functions with 5 knots. (Assuming max_degree_Y0W = 2) num_knots_Y0W = c(10,5,1) generates same basis functions as above and also the three-way interaction basis functions with only a single knot point at the origin (e.g. the triple interaction 'W1*W2*W3') (Assuming max_degree_Y0W = 3)

HAL_fit_control

See the argument 'fit_control' of (see fit_hal).

delta_epsilon

Step size of iterative targeted maximum likelihood estimator. 'delta_epsilon = 1 ' leads to large step sizes and fast convergence. 'delta_epsilon = 0.005' leads to slower convergence but possibly better performance. Useful to set to a large value in high dimensions.

...

Other arguments to pass to main routine (spCATE, spOR, spRR)

Y

A character name for the outcome variable contained in data (outcome can be continuous, nonnegative or binary depending on method)

estimand

Estimand/parameter to estimate. Choices are: 'CATE': Estimate the best parametric approximation of the conditional average treatment effect with Param_npCATE using the parametric model formula. Note: if formula = '~1' then causalRobustGLM returns a nonparametric and efficient estimator for the ATE (Marginal average treatment effect). Specifically, this estimand is the least-squares projection of the true CATE onto the parametric working model. 'CATT': Estimate the best parametric approximation of the conditional average treatment effect among the treated with Param_npCATE using the parametric model formula. Note: if formula = '~1' then causalRobustGLM returns a nonparametric and efficient estimator for the ATT (Marginal average treatment effect among the treated). Specifically, this estimand is the least-squares projection of the true CATE onto the parametric working model using only the observations with 'A=1' (among the treated). 'TSM': Estimate the best parametric approximation of the conditional treatment-specific mean 'E[Y|A=a,W]' for 'a' in levels_A. Note: if formula = '~1' then causalRobustGLM returns a nonparametric and efficient estimator for the TSM (Marginal treatment-specific mean). Specifically, this estimand is the least-squares projection of the true TSM onto the parametric working model. 'OR': Estimate the best parametric approximation of the conditional odds ratio with Param_npOR using the parametric model formula. Specifically, this estimand is the log-likelihood projection of the true conditional odds ratio onto the partially-linear logistic regression model with the true 'E[Y|A=0,W]' used as offset. 'RR': Projection of the true conditional relative risk onto a exponential working-model using log-linear/poisson regression. Note: if formula = '~1' then causalRobustGLM returns a nonparametric and efficient estimator for the marginal relative risk ('E_W[E[Y|A=1,W]]/E_W[E[Y|A=0,W]]“).

weights

An optional vector of weights to use in procedure.


Larsvanderlaan/causalGLM documentation built on April 14, 2022, 12:51 a.m.