bagged.causalMARS: Fit a bag of causal MARS models

Description Usage Arguments Value Examples

Description

Fit a bag of causal MARS models

Usage

1
2
3
bagged.causalMARS(x, tx, y, nbag = 20, maxterms = 11, nquant = 5,
  degree = ncol(x), eps = 1, backstep = FALSE, propensity = FALSE,
  stratum = rep(1, nrow(x)), minnum = 5, verbose = FALSE)

Arguments

x

matrix of covariates

tx

vector of treatment indicators (0 or 1)

y

vector of response values

nbag

number of models to bag

maxterms

maximum number of terms to include in the regression basis (e.g. maxterms = 11 means intercept + 5 pairs added)

nquant

number of quantiles used in splitting

degree

max number of different predictors that can interact in model

eps

shrinkage factor for new term added

backstep

logical: should out-of-bag samples be used to prune each model? otherwise full regression basis is used for each model

propensity

logical: should propensity score stratification be used?

stratum

optional vector giving propensity score stratum for each observation (only used if propensity = TRUE)

minnum

minimum number of observations in each arm of each propensity score stratum needed to estimate regression coefficients for basis (only used if propensity = TRUE)

verbose

logical: should progress be printed to console?

Value

an object of class bagged.causalMARS, which is itself a list of causalMARS objects

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Randomized experiment example

n = 100 # number of training-set patients to simulate
p = 10  # number of features for each training-set patient

# Simulate data
x = matrix(rnorm(n * p), nrow = n, ncol = p) # simulate covariate matrix
tx_effect = x[, 1] + (x[, 2] > 0) # simple heterogeneous treatment effect
tx = rbinom(n, size = 1, p = 0.5) # random treatment assignment
y = rowMeans(x) + tx * tx_effect + rnorm(n, sd = 0.001) # simulate response

# Estimate bagged causal MARS model
fit_bcm = causalLearning::bagged.causalMARS(x, tx, y, nbag = 10)
pred_bcm = predict(fit_bcm, newx = x)

# Visualize results
plot(tx_effect, pred_bcm, main = 'Bagged causal MARS',
 xlab = 'True treatment effect', ylab = 'Estimated treatment effect')
abline(0, 1, lty = 2)

saberpowers/causalLearning documentation built on May 30, 2019, 8:26 a.m.