Description Usage Arguments Details Value Examples
Fit a causal MARS model
1 2 3 4 |
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. |
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 |
tx.val |
optional vector of validation-set treatment indicators
(only used if |
y.val |
optional vector of validation-set response values
(only used if |
propensity |
logical: should propensity score stratification be used? |
stratum |
optional vector giving propensity score stratum for each
observation (only used if |
stratum.val |
optional vector giving propensity score stratum for each
validation-set observation
(only used if |
minnum |
minimum number of observations in each arm of each propensity
score stratum needed to estimate regression coefficients for basis
(only used if |
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
an object of class causalMARS
with attributes:
parent: indices of nodes that are parents at each stage
childvar: index of predictor chosen at each forward step
childquant: quantile of cutoff chosen at each forward step
quant: quantiles of the columns of x
active: indices of columns with nonzero norm
allvars: list of variables appearing in each term
khat: the sequence of terms deleted at each step
deltahat: relative change in rss
rsstesthat: validation-set rss achieved by each model in sequence
setesthat: standard error for rsstesthat
tim1: time elapsed during forward stepwise phase
tim2: total time elapsed
x
tx
y
maxterms
eps
backstep
propensity
x.val
tx.val
y.val
stratum
stratum.val
minnum
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.