crr | R Documentation |
Conditional Relative Risk estimation via Double Machine Learning
crr( treatment, response_model, propensity_model, importance_model, contrast = c(1, 0), data, nfolds = 5, type = "dml1", ... )
treatment |
formula specifying treatment and variables to condition on |
response_model |
SL object (outcome/response model) |
propensity_model |
SL object (treatment/propensity model) |
importance_model |
SL object (conditional expectation of outcome model on variables conditioned on in treatment argument) |
contrast |
treatment contrast (default 1 vs 0) |
data |
data.frame |
nfolds |
Number of folds |
type |
'dml1' or 'dml2' |
... |
additional arguments to SuperLearner |
cate.targeted object
Klaus Kähler Holst & Andreas Nordland
sim1 <- function(n=1e4, seed=NULL, return_model=FALSE, ...) { suppressPackageStartupMessages(require("lava")) if (!is.null(seed)) set.seed(seed) m <- lava::lvm() distribution(m, ~x) <- gaussian.lvm() distribution(m, ~v) <- gaussian.lvm(mean = 5) distribution(m, ~a) <- binomial.lvm("logit") regression(m, "a") <- function(v, x){.2*v + x} distribution(m, "y") <- gaussian.lvm() regression(m, "y") <- function(a, v, x){v+x+a*x+a*v*v} if (return_model) return(m) lava::sim(m, n = n) } d <- sim1(n = 1e3, seed = 1) if (require("SuperLearner",quietly=TRUE)) { e <- crr(data=d, type = "dml2", treatment = a ~ v, response_model = y~ a*(x + v + I(v^2)), importance_model = SL(D_ ~ v + I(v^2)), nfolds = 2) summary(e) # the true parameters are c(1,1) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.