Description Usage Arguments Value Examples
Fit a causal boosting model with cross validation
1 2 3 |
x |
matrix of covariates |
tx |
vector of treatment indicators (0 or 1) |
y |
vector of response values |
num.trees |
number of shallow causal trees to build |
maxleaves |
maximum number of leaves per causal tree |
eps |
learning rate |
splitSpread |
how far apart should the candidate splits be for the
causal trees? (e.g. |
type.measure |
loss to use for cross validation: 'response' returns mean-square error for predicting response in each arm. 'effect' returns MSE for treatment effect using honest over-fit estimation. |
nfolds |
number of cross validation folds |
foldid |
vector of fold membership |
propensity |
logical: should propensity score stratification be used? |
stratum |
optional vector giving propensity score stratum for each
observation (only used if |
isConstVar |
logical: for the causal tree splitting criterion (T-statistc), should it be assumed that the noise variance is the same in treatment and control arms? |
an object of class cv.causalBoosting
which is an object of
class causalBoosting
with these additional attributes:
num.trees.min: number of trees with lowest CV error
cvm: vector of mean CV error for each number of trees
cvsd: vector of standard errors for mean CV errors
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 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 boosting model with cross-validation
fit_cv = causalLearning::cv.causalBoosting(x, tx, y)
fit_cv$num.trees.min.effect # number of trees chosen by cross-validation
pred_cv = predict(fit_cv, newx = x)
# Visualize results
plot(tx_effect, pred_cv, main = 'Causal boosting w/ CV',
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.