Description Usage Arguments See Also Examples

Plots results for estimated subgroup treatment effects

Plots validation results for estimated subgroup treatment effects

1 2 3 4 5 6 7 |

`x` |
fitted object returned by |

`type` |
type of plot. |

`avg.line` |
boolean value of whether or not to plot a line for the average
value in addition to the density (only valid for |

`...` |
not used |

`fit.subgroup`

for function which fits subgroup identification models.

`validate.subgroup`

for function which creates validation results
and `fit.subgroup`

for function which fits subgroup identification models.

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 64 65 66 67 68 69 70 | ```
library(personalized)
set.seed(123)
n.obs <- 250
n.vars <- 15
x <- matrix(rnorm(n.obs * n.vars, sd = 3), n.obs, n.vars)
# simulate non-randomized treatment
xbetat <- 0.5 + 0.5 * x[,11] - 0.5 * x[,13]
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)
# 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
subgrp.model$subgroup.trt.effects
plot(subgrp.model)
plot(subgrp.model, type = "boxplot")
plot(subgrp.model, type = "interaction")
plot(subgrp.model, type = "conditional")
valmod <- validate.subgroup(subgrp.model, B = 3,
method = "training_test",
benefit.score.quantiles = c(0.25, 0.5, 0.75),
train.fraction = 0.75)
plot(valmod)
plot(valmod, type = "interaction")
# see how summary statistics of subgroups change
# when the subgroups are defined based on different cutoffs
# (25th quantile of bene score, 50th, and 75th)
plot(valmod, type = "conditional")
# visualize the frequency of particular variables
# of being selected across the resampling iterations with
# 'type = "stability"'
# not run:
# plot(valmod, type = "stability")
``` |

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

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.