fit_subgroup_2part {personalized2part} | R Documentation |
Fitting subgroup identification models for semicontinuous positive outcomes
Description
Fits subgroup identification models
Usage
fit_subgroup_2part(
x,
y,
trt,
propensity.func = NULL,
propensity.func.positive = NULL,
match.id = NULL,
augment.func.zero = NULL,
augment.func.positive = NULL,
cutpoint = 1,
larger.outcome.better = TRUE,
penalize.ate = TRUE,
y_eps = 1e-06,
...
)
Arguments
x |
The design matrix (not including intercept term) |
y |
The nonnegative response vector |
trt |
treatment vector with each element equal to a 0 or a 1, with 1 indicating treatment status is active. |
propensity.func |
function that inputs the design matrix x and the treatment vector trt and outputs
the propensity score, ie Pr(trt = 1 | X = x). Function should take two arguments 1) x and 2) trt. See example below.
For a randomized controlled trial this can simply be a function that returns a constant equal to the proportion
of patients assigned to the treatment group, i.e.:
|
propensity.func.positive |
function that inputs the design matrix x and the treatment vector trt and outputs
the propensity score for units with positive outcome values, ie Pr(trt = 1 | X = x, Z = 1). Function should take
two arguments 1) x and 2) trt. See example below.
For a randomized controlled trial this can simply be a function that returns a constant equal to the proportion
of patients assigned to the treatment group, i.e.:
|
match.id |
a (character, factor, or integer) vector with length equal to the number of observations in Example 1: Example 2: augment.func <- function(x, y, trt) { data <- data.frame(x, y, trt) lmod <- glm(y ~ x * trt, family = binomial()) ## get predictions when trt = 1 data$trt <- 1 preds_1 <- predict(lmod, data, type = "response") ## get predictions when trt = -1 data$trt <- -1 preds_n1 <- predict(lmod, data, type = "response") ## return predictions averaged over trt return(0.5 * (preds_1 + preds_n1)) } |
augment.func.zero |
(similar to augment.func.positive) function which inputs the
indicators of whether each response is positive ( |
augment.func.positive |
(similar to augment.func.zero) function which inputs the positive part response
(ie all observations in |
cutpoint |
numeric value for patients with benefit scores above which
(or below which if |
larger.outcome.better |
boolean value of whether a larger outcome is better/preferable. Set to |
penalize.ate |
should the treatment main effect (ATE) be penalized too? |
y_eps |
positive value above which observations in |
... |
options to be passed to |
Examples
set.seed(42)
dat <- sim_semicontinuous_data(250, n.vars = 15)
x <- dat$x
y <- dat$y
trt <- dat$trt
prop_func <- function(x, trt)
{
propensmod <- glm(trt ~ x, family = binomial())
propens <- unname(fitted(propensmod))
propens
}
fitted_model <- fit_subgroup_2part(x, y, trt, prop_func, prop_func)
fitted_model
## correlation of estimated covariate-conditional risk ratio and truth
cor(fitted_model$benefit.scores, dat$treatment_risk_ratio, method = "spearman")