Description Usage Arguments Value Examples
Fit a pollinated transformed outcome (PTO) forest model
1 2 3 |
x |
matrix of covariates |
tx |
vector of treatment indicators (0 or 1) |
y |
vector of response values |
pscore |
vector of propensity scores |
num.trees |
number of trees for transformed outcome forest |
mtry |
number of variables to possibly split at in each node |
min.node.size |
minimum node size for transformed outcome forest |
postprocess |
logical: should optional post-processing random forest be fit at end? |
verbose |
logical: should progress be printed to console? |
an object of class PTOforest
with attributes:
x: matrix of covariates supplied by function call
pscore: vector of propensity score supplied by function call
postprocess: logical supplied by function call
TOfit: fitted random forest on transformed outcomes
PTOfit1: TOfit pollinated with treatment-arm outcomes
PTOfit0: TOfit pollinated with control-arm outcomes
postfit: post-processing random forest summarizing results
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 PTO forest model
fit_pto = PTOforest(x, tx, y)
pred_pto = predict(fit_pto, newx = x)
# Visualize results
plot(tx_effect, pred_pto, main = 'PTO forest',
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.