treatment.effects: Calculation of covariate-conditional treatment effects

Description Usage Arguments Value See Also Examples

View source: R/calculate_treatment_effects.R

Description

Calculates covariate conditional treatment effects using estimated benefit scores

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
treatment.effects(x, ...)

## Default S3 method:
treatment.effects(x, ...)

treat.effects(benefit.scores, loss = c("sq_loss_lasso",
  "logistic_loss_lasso", "poisson_loss_lasso", "cox_loss_lasso",
  "owl_logistic_loss_lasso", "owl_logistic_flip_loss_lasso",
  "owl_hinge_loss", "owl_hinge_flip_loss", "sq_loss_lasso_gam",
  "poisson_loss_lasso_gam", "logistic_loss_lasso_gam", "sq_loss_gam",
  "poisson_loss_gam", "logistic_loss_gam", "owl_logistic_loss_gam",
  "owl_logistic_flip_loss_gam", "owl_logistic_loss_lasso_gam",
  "owl_logistic_flip_loss_lasso_gam", "sq_loss_gbm", "poisson_loss_gbm",
  "logistic_loss_gbm", "cox_loss_gbm",      "custom"),
  method = c("weighting", "a_learning"), pi.x = NULL, ...)

## S3 method for class 'subgroup_fitted'
treatment.effects(x, ...)

Arguments

x

a fitted object from fit.subgroup()

...

not used

benefit.scores

vector of estimated benefit scores

loss

loss choice USED TO CALCULATE benefit.scores of both the M function from Chen, et al (2017) and potentially the penalty used for variable selection. See fit.subgroup for more details.

method

method choice USED TO CALCULATE benefit.scores. Either the "weighting" method or "a_learning" method. See fit.subgroup for more details

pi.x

The propensity score for each observation

Value

A List with elements delta (if the treatment effects are a difference/contrast, i.e. E[Y|T=1, X] - E[Y|T=-1, X]) and gamma (if the treatment effects are a ratio, i.e. E[Y|T=1, X] / E[Y|T=-1, X])

See Also

fit.subgroup for function which fits subgroup identification models.

print.individual_treatment_effects for printing of objects returned by treat.effects or treatment.effects

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
library(personalized)

set.seed(123)
n.obs  <- 1000
n.vars <- 50
x <- matrix(rnorm(n.obs * n.vars, sd = 3), n.obs, n.vars)


# simulate non-randomized treatment
xbetat   <- 0.5 + 0.5 * x[,21] - 0.5 * x[,41]
trt.prob <- exp(xbetat) / (1 + exp(xbetat))
trt01    <- rbinom(n.obs, 1, prob = trt.prob)

trt      <- 2 * trt01 - 1

# simulate response
delta <- 2 * (0.5 + x[,2] - x[,3] - x[,11] + x[,1] * x[,12])
xbeta <- x[,1] + x[,11] - 2 * x[,12]^2 + x[,13]
xbeta <- xbeta + delta * trt

# continuous outcomes
y <- drop(xbeta) + rnorm(n.obs, sd = 2)

# time-to-event outcomes
surv.time <- exp(-20 - xbeta + rnorm(n.obs, sd = 1))
cens.time <- exp(rnorm(n.obs, sd = 3))
y.time.to.event  <- pmin(surv.time, cens.time)
status           <- 1 * (surv.time <= cens.time)

# create function for fitting propensity score model
prop.func <- function(x, trt)
{
    # fit propensity score model
    propens.model <- cv.glmnet(y = trt,
                               x = x, family = "binomial")
    pi.x <- predict(propens.model, s = "lambda.min",
                    newx = x, type = "response")[,1]
    pi.x
}

subgrp.model <- fit.subgroup(x = x, y = y,
                             trt = trt01,
                             propensity.func = prop.func,
                             loss   = "sq_loss_lasso",
                             nfolds = 5)    # option for cv.glmnet

trt_eff <- treatment.effects(subgrp.model)
str(trt_eff)

trt_eff


library(survival)
subgrp.model.cox <- fit.subgroup(x = x, y = Surv(y.time.to.event, status),
                           trt = trt01,
                           propensity.func = prop.func,
                           loss   = "cox_loss_lasso",
                           nfolds = 5)              # option for cv.glmnet

trt_eff_c <- treatment.effects(subgrp.model.cox)
str(trt_eff_c)

trt_eff_c

personalized documentation built on Nov. 7, 2019, 5:07 p.m.