| fit_CATE | R Documentation |
Returns a fitted CATE \tau(Z) where covariates Z_S has no effect
modification given the remaining covariates. It employs R-loss and cross fitting
to estimate
\mathbb{E}[Y|T,Z] = \mu_0(Z) + T \cdot \tau(Z), \quad \mu_0(Z) := \mathbb{E}[Y \mid T=0, Z].
fit_CATE(
y,
X,
w = rep(1, nrow(X)),
S = 1:(ncol(X) - 1),
folds.crossfit = 5,
randomized = FALSE
)
y |
Numeric response vector of length n. |
X |
Matrix |
w |
Non-negative numeric weight vector of length n. Defaults to
|
S |
A subset of |
folds.crossfit |
An integer for the number of folds in cross fitting using the R-loss to estimate CATE. When it is 1, no cross fitting is used. |
randomized |
If |
An object of class "CATE":
control_mean_fun\mu_0(Z) = \mathbb{E}[Y | T=0, Z]
CATE_fun\tau(Z) = \mathbb{E}[Y | T=1, Z] - \mathbb{E}[Y | T=0, Z],
which only depends on Z through Z_{S^c}.
SS as specified.
pNumber of covariates, which equals ncol(Z).
## A randomized trial in which the treatment effect depends on Z1 only.
set.seed(2)
n <- 500
Z <- matrix(rnorm(n * 2), n, 2, dimnames = list(NULL, c("Z1", "Z2")))
Tr <- rbinom(n, 1, 0.5) # randomized treatment
tau <- Z[, "Z1"] # true CATE
y <- Z[, "Z1"] + Z[, "Z2"] + Tr * tau + rnorm(n)
## S = NULL leaves the CATE unrestricted, so it may depend on Z1 and Z2.
fit <- fit_CATE(y, cbind(Tr, Z), S = NULL, randomized = TRUE,
folds.crossfit = 2)
cor(fit$CATE_fun(Z), tau) # close to 1: the true CATE is recovered
sd(fit$CATE_fun(Z))
## S = 1 bars Z1 from modifying the effect. Because the true CATE depends
## on Z1 alone, the fitted CATE then collapses to nearly a constant.
fit0 <- fit_CATE(y, cbind(Tr, Z), S = 1, randomized = TRUE,
folds.crossfit = 2)
sd(fit0$CATE_fun(Z)) # much smaller than above
## predict() gives the fitted outcome mean mu0(Z) + T * tau(Z).
head(predict(fit, cbind(Tr, Z)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.