Skip to content

Custom model for competing event #49

@demetriomagatti

Description

@demetriomagatti

Dear developer,

I' have been working with the R package of gfoRmula for some time. I would like to report what I deem to be a "deficiency" of the package.

To give you a little more context, I'm working with survival outcomes in Intensive Care Units (ICUs). I have also a competing event, which is the discharge from the ICU and also acts as a censoring event, as I have no information on patients after they are discharged.
After quite some work and tuning, I got to realize that the task I'm working on requires a custom model for the outcome, and I was able to set it up and run things smoothly as gfoRmula allows ymodel_fit_custom and ymodel_predict_custom parameters.
The model for the outcome has been obtained (trained and tested) separately, prior to using gfoRmula for simulations. Specifcially, my ymodel_fit_custom is just an empty function

ymodel_fit_custom <- function(obs_data){
    return ()
}

and in the predict function I load my pre-trained model and use it to predict

ymodel_predict_custom <- function(fit, newdf){
    library(glmnet)
    load(<path_to_trained_model.rdata>) # this contains a glmnet model called `cv_fit`
    stringFormula <- "<my formula, way too long to be written here, written in string format" # same formula used when training `cv_fit`
    formula <- as.formula(stringFormula)
    X <- model.matrix(formula, data = newdf)[, -1]
    probabilities <- predict(cv_fit, newx = X, type = "response", s = "lambda.min")
    return(probabilities)
}

I'm not sure it's the cleanest way to do what I want, but I'm happy with it.

It would be great to add the possibility of doing something similar for the prediction of the competing event. As of last released version, no compevent_fit_custom and compevent_predict_custom are allowed.

Thank you in advance for the answer!
Best regards,
Demetrio

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions