Giter Club home page Giter Club logo

personalized's Issues

survival analysis with counting process data

Dear authors,
Thank you very much for your excellent package; and I have a problem in working with survival outcome data with counting process format.

library(personalized)
library(survival)
> dtRNA %>% select(PtID,startTime,endTime,status) %>% head(10)
# A tibble: 10 × 4
   PtID  startTime endTime status
   <chr>     <dbl>   <dbl>  <dbl>
 1 AH01          0       2      0
 2 AH01          2       4      0
 3 AH01          4       8      0
 4 AH02          0       2      0
 5 AH02          2       4      0
 6 AH02          4      13      0
 7 AH03          0       2      0
 8 AH03          2       4      0
 9 AH03          4      10      0
10 AH04          0       2      0
#Data reformat 
trt <- if_else(dtRNA$UTI_flg=="UTI",1,0)
trt <- if_else(dtRNA$fluidvaso_tag=="restrictive",1,0)
Xmatrix <- assay(vsd) %>% 
  as.data.frame() %>% 
  select(dtRNA$SampleName) %>% 
  t()
start.time = dtRNA$startTime
end.time = dtRNA$endTime
end.time = if_else(is.na(end.time),start.time+2,end.time)
status <- dtRNA$status

# 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
}
plot_overlap <- check.overlap(
  Xmatrix, trt, prop.func,
  type = "both")
#Fitting Subgroup Identification Models
subgrp.model <- fit.subgroup(
  x = Xmatrix, 
  y = Surv(start.time,end.time, status),
  trt = trt,
  method = "weighting",
  propensity.func = prop.func,
  loss   = "cox_loss_lasso",cutpoint = "median",
  nfolds = 5)              # option for cv.glmnet
summary(subgrp.model)

The PtID indicate a unique patient subject; and each patient can have multiple observations. I feel that this model is not correctly fit because there is no argument in the fit.subgroup function to indicate patient ID. The outcome is given in y = Surv(start.time,end.time, status). Are there any hints for survival model with counting process data?

add hinge loss via kernlab package

add hinge loss option (binary and continuous outcomes) via kernlab. this may be involved as we will need to carefully specify the kernel such that observation weights can be incorporated

Example datasets

It might be useful to include the data you simulate in the vignette as a dataset in your package. Then people can simply load it to use the vignette.

update check overlap function for multiple trtments

the check overlap function now only works for treatment/control setting. It will be more complicated for multiple treatments. need to make checks that the propensity function returns a matrix, not a vector in this case

Double checking correctness of default behavior of propensity.func() when NULL

With the multiple treatments update in place, is the default behavior of propensity.func() within fit.subgroup() correct for its return of pi.x?

For instance, when n.trts == 2, all subjects get assigned the same value of mean.trt. However, when there are more, say n.trts == 3, then there are 3 different possible values assigned (each getting the mean of their respective category of membership).

This seems like a disconnect (going from 1 to 2 treatments but going from 1 to 3 unique values of pi.x).

Doesn't the generalized version already provide the right calculation when n.trts == 2?. Could the following block be removed from propensity.func() without breaking anything?

    if (n.trts == 2)
    {
        mean.trt <- mean(trt == unique.trts[2L])
        propensity.func <- function(trt, x) rep(mean.trt, length(trt))
    } else

For reference, the entire block of code I'm referring to is this:

if (is.null(propensity.func))
{
    if (n.trts == 2)
    {
        mean.trt <- mean(trt == unique.trts[2L])
        propensity.func <- function(trt, x) rep(mean.trt, length(trt))
    } else
    {
        mean.trt <- numeric(n.trts)
        for (t in 1:n.trts)
        {
            mean.trt[t] <- mean(trt == unique.trts[t])
        }
        propensity.func <- function(trt, x)
        {
            pi.x <- numeric(length(trt))
            for (t in 1:n.trts)
            {
                which.t       <- trt == unique.trts[t]
                pi.x[which.t] <- mean(which.t)
            }

            pi.x
        }
    }
}

fixed handling of propensity scores for multiple treatments

propensity score function should return a matrix where each column represents the probability of a particular treatment. Should it be K-1 or K columns? K may be easier, but need to make sure enforcement of ordering with respect to the treatments is clear to the user

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.