robincar_SL.Rd
Estimate treatment-group-specific response means and (optionally) treatment group contrasts using a generalized linear working model.
A data.frame with the required columns
Name of column in df with treatment variable
Name of the column in df with response variable
Names of columns in df with car_strata variables
Names of columns in df with covariate variables
Name of the type of covariate-adaptive randomization scheme. One of: "simple", "pocock-simon", "biased-coin", "permuted-block".
Whether to include car_strata variables in covariate adjustment. Defaults to F for ANOVA and ANCOVA; defaults to T for ANHECOVA. User may override by passing in this argument.
Vector of super-learner libraries to use for the covariate adjustment (see SuperLearner::listWrappers)
Optional list of super-learner "learners" to use for the covariate adjustment (see SuperLearner::create.Learner())
Number of splits to use in cross-fitting
Level of accuracy to check prediction un-biasedness (in digits).
An optional function to specify a desired contrast
An optional jacobian function for the contrast (otherwise use numerical derivative)
The type of variance estimator to use, type 1, 2, or 3. All three are asymptotically equivalent. See details of RobinCar::robincar_glm for more.
See value of RobinCar::robincar_glm, but the working model for \(\hat{\mu}(X_i)\) is based on the AIPW::AIPW package that uses specified SuperLearner libraries and cross-fitting. Also, `mod` attribute is an object of class AIPW::AIPW.
*WARNING: This function is still under development and has not been extensively tested.* This function currently only works for two treatment groups. Before using this function, you must load the SuperLearner library with `library(SuperLearner)`, otherwise the function call will fail.
library(SuperLearner)
#> Loading required package: nnls
#> Loading required package: gam
#> Loading required package: splines
#> Loading required package: foreach
#> Loaded gam 1.22-3
#> Super Learner
#> Version: 2.0-29
#> Package created on 2024-02-06
library(ranger)
n <- 1000
set.seed(10)
DATA2 <- data.frame(A=rbinom(n, size=1, prob=0.5),
y=rbinom(n, size=1, prob=0.2),
x1=rnorm(n),
x2=rnorm(n),
x3=as.factor(rbinom(n, size=1, prob=0.5)),
z1=rbinom(n, size=1, prob=0.5),
z2=rbinom(n, size=1, prob=0.5))
DATA2[, "y"] <- NA
As <- DATA2$A == 1
DATA2[DATA2$A == 1, "y"] <- rbinom(
sum(As),
size=1,
prob=exp(DATA2[As,]$x1)/(1+exp(DATA2[As,]$x1)))
DATA2[DATA2$A == 0, "y"] <- rbinom(
n-sum(As),
size=1,
prob=exp(1 +
5*DATA2[!As,]$x1 + DATA2[!As,]$x2)/
(1+exp(1 + 5*DATA2[!As,]$x1 + DATA2[!As,]$x2)))
DATA2$A <- as.factor(DATA2$A)
sl.mod <- robincar_SL(
df=DATA2,
response_col="y",
treat_col="A",
car_strata_cols=c("z1"),
covariate_cols=c("x1"),
SL_libraries=c("SL.ranger"),
car_scheme="permuted-block",
covariate_to_include_strata=TRUE
)
#> Done!
#> Warning: Prediction unbiasedness does not hold.
sl.mod$result
#> # A tibble: 2 × 4
#> treat estimate se `pval (2-sided)`
#> <chr> <dbl> <dbl> <dbl>
#> 1 0 0.582 0.0194 2.15e-198
#> 2 1 0.518 0.0217 2.85e-126