项目作者: jaredhuling

项目描述 :
Methods for subgroup identification / personalized medicine / individualized treatment rules
高级语言: R
项目地址: git://github.com/jaredhuling/personalized.git
创建时间: 2017-05-17T20:40:34Z
项目社区:https://github.com/jaredhuling/personalized

开源协议:

下载


version
Build
Status
Appveyor Build
Status
codecov

Overview of ‘personalized’

The ‘personalized’ package is designed for the analysis of data where
the effect of a treatment or intervention may vary for different
patients. It can be used for either data from randomized controlled
trials or observational studies and is not limited specifically to the
analysis of medical data.

The personalized package provides estimation methods for subgroup
identification under the framework of Chen et al
(2017)
. It
also provides routines for valid estimation of the subgroup-specific
treatment effects.

Documentation

Documentation

Installing the ‘personalized’ package

Install from CRAN using:

  1. install.packages("personalized")

or install the development version using the devtools package:

  1. devtools::install_github("jaredhuling/personalized")

or by cloning and building using R CMD INSTALL

Quick Usage Overview

Load the package:

  1. library(personalized)

Create a propensity score model

(it should be a function which inputs covariates and treatments and
returns propensity score):

  1. prop.func <- function(x, trt)
  2. {
  3. # fit propensity score model
  4. propens.model <- cv.glmnet(y = trt,
  5. x = x, family = "binomial")
  6. pi.x <- predict(propens.model, s = "lambda.min",
  7. newx = x, type = "response")[,1]
  8. pi.x
  9. }

Fit a model to estimate subgroup:

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

Display estimated subgroups and variables selected which determine the subgroups:

  1. summary(subgrp.model)
  1. ## family: gaussian
  2. ## loss: sq_loss_lasso
  3. ## method: weighting
  4. ## cutpoint: 0
  5. ## propensity
  6. ## function: propensity.func
  7. ##
  8. ## benefit score: f(x),
  9. ## Trt recom = Trt*I(f(x)>c)+Ctrl*I(f(x)<=c) where c is 'cutpoint'
  10. ##
  11. ## Average Outcomes:
  12. ## Recommended Ctrl Recommended Trt
  13. ## Received Ctrl -3.9319 (n = 109) -21.2055 (n = 122)
  14. ## Received Trt -25.078 (n = 112) -8.326 (n = 157)
  15. ##
  16. ## Treatment effects conditional on subgroups:
  17. ## Est of E[Y|T=Ctrl,Recom=Ctrl]-E[Y|T=/=Ctrl,Recom=Ctrl]
  18. ## 21.1461 (n = 221)
  19. ## Est of E[Y|T=Trt,Recom=Trt]-E[Y|T=/=Trt,Recom=Trt]
  20. ## 12.8795 (n = 279)
  21. ##
  22. ## NOTE: The above average outcomes are biased estimates of
  23. ## the expected outcomes conditional on subgroups.
  24. ## Use 'validate.subgroup()' to obtain unbiased estimates.
  25. ##
  26. ## ---------------------------------------------------
  27. ##
  28. ## Benefit score quantiles (f(X) for Trt vs Ctrl):
  29. ## 0% 25% 50% 75% 100%
  30. ## -9.2792 -1.8237 0.5011 2.5977 9.6376
  31. ##
  32. ## ---------------------------------------------------
  33. ##
  34. ## Summary of individual treatment effects:
  35. ## E[Y|T=Trt, X] - E[Y|T=Ctrl, X]
  36. ##
  37. ## Min. 1st Qu. Median Mean 3rd Qu. Max.
  38. ## -18.5583 -3.6474 1.0023 0.9507 5.1954 19.2753
  39. ##
  40. ## ---------------------------------------------------
  41. ##
  42. ## 5 out of 50 interactions selected in total by the lasso (cross validation criterion).
  43. ##
  44. ## The first estimate is the treatment main effect, which is always selected.
  45. ## Any other variables selected represent treatment-covariate interactions.
  46. ##
  47. ## Trt V2 V11 V17 V32 V35
  48. ## Estimate 0.5463 0.9827 -0.4356 -0.1532 0.0326 0.1007

Use repeated train and test splitting to estimate subgroup treatment effects:

  1. val.model <- validate.subgroup(subgrp.model, B = 100,
  2. method = "training_test",
  3. train.fraction = 0.75)

Display estimated subgroup treatment effects:

  1. print(val.model, digits = 2, sample.pct = TRUE)
  1. ## family: gaussian
  2. ## loss: sq_loss_lasso
  3. ## method: weighting
  4. ##
  5. ## validation method: training_test_replication
  6. ## cutpoint: 0
  7. ## replications: 100
  8. ##
  9. ## benefit score: f(x),
  10. ## Trt recom = Trt*I(f(x)>c)+Ctrl*I(f(x)<=c) where c is 'cutpoint'
  11. ##
  12. ## Average Test Set Outcomes:
  13. ## Recommended Ctrl Recommended Trt
  14. ## Received Ctrl -9.56 (SE = 7.98, 19.88%) -18.62 (SE = 6.72, 26.5%)
  15. ## Received Trt -16.64 (SE = 6.85, 23.23%) -13.41 (SE = 7.8, 30.39%)
  16. ##
  17. ## Treatment effects conditional on subgroups:
  18. ## Est of E[Y|T=Ctrl,Recom=Ctrl]-E[Y|T=/=Ctrl,Recom=Ctrl]
  19. ## 6.54 (SE = 10.49, 43.11%)
  20. ## Est of E[Y|T=Trt,Recom=Trt]-E[Y|T=/=Trt,Recom=Trt]
  21. ## 5.21 (SE = 11.06, 56.89%)
  22. ##
  23. ## Est of
  24. ## E[Y|Trt received = Trt recom] - E[Y|Trt received =/= Trt recom]:
  25. ## 2.91 (SE = 8.29)

Visualize subgroup-specific treatment effect estimates across
training/testing iterations:

  1. plot(val.model)

Investigate the marginal characteristics of the two estimated subgroups

Here we only display covariates with a significantly different mean
value (at level 0.05)

  1. summ <- summarize.subgroups(subgrp.model)
  2. print(summ, p.value = 0.05)
  1. ## Avg (recom Ctrl) Avg (recom Trt) Ctrl - Trt SE (recom Ctrl) SE (recom Trt)
  2. ## V2 -2.4161 1.9013 -4.317 0.1423 0.1298
  3. ## V11 1.1279 -0.7963 1.924 0.1914 0.1572
  4. ## V17 0.8053 -0.3715 1.177 0.2170 0.1736

Accessing Help Files for Main Functions of personalized

Access help files for the main functions of the personalized package:

  1. ?fit.subgroup
  2. ?validate.subgroup