causalMARS: Fit a causal MARS model

Description Usage Arguments Details Value Examples

Description

Fit a causal MARS model

Usage

1
2
3
4
causalMARS(x, tx, y, maxterms = 11, nquant = 5, degree = ncol(x),
  eps = 1, backstep = FALSE, x.val = NULL, tx.val = NULL,
  y.val = NULL, propensity = FALSE, stratum = rep(1, nrow(x)),
  stratum.val = NULL, minnum = 5)

Arguments

x

matrix of covariates

tx

vector of treatment indicators (0 or 1)

y

vector of response values

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: after building out regression basis, should backward stepwise selection be used to create a sequence of models, with the criterion evaluated on a validation set to choose among the sequence?

x.val

optional matrix of validation-set covariates (only used if backstep = TRUE)

tx.val

optional vector of validation-set treatment indicators (only used if backstep = TRUE)

y.val

optional vector of validation-set response values (only used if backstep = TRUE)

propensity

logical: should propensity score stratification be used?

stratum

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

stratum.val

optional vector giving propensity score stratum for each validation-set observation (only used if propensity = backstep = 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)

Details

parallel arms mars with backward stepwise BOTH randomized case and propensity stratum. data structures: model terms (nodes) are numbered 1, 2, ... with 1 representing the intercept. forward stepwise: modmatrix contains basis functions as model is built up – two columns are added at each step. Does not include a column of ones for tidiness, we always add two terms, even when term added in linear (so that reflected version is just zero). backward stepwise: khat is the sequence of terms deleted at each step, based on deltahat = relative change in rss. rsstesthat is rss over test (validation) set achieved by each reduced model in sequence- used later for selecting a member of the sequence. active2 contains indices of columns with nonzero norm

Value

an object of class causalMARS with attributes:

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 causal MARS model
fit_cm = causalLearning::causalMARS(x, tx, y)
pred_cm = predict(fit_cm, newx = x)

# Visualize results
plot(tx_effect, pred_cm, main = '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.