Closed StephenBarron closed 4 years ago
The cumulative hazard can be calculated from a fitted model for given covariate values using summary.flexsurvreg(..., newdata=..., type="cumhaz")
, or type="survival"
for the survival probability. Alternatively Hsurvspline
calculates the cumulative hazard for given parameter values and knot locations for this class of model, see also psurvspline
.
Have a look at the functions in the source https://github.com/chjackson/flexsurv-dev/blob/master/R/spline.R to see how it works at a lower level. The actual basis functions are implemented in C++ in https://github.com/chjackson/flexsurv-dev/blob/master/src/splines.cpp
Thanks very much.
I'm using your excellent flexsurv package and I'd appreciate your help with a question. I'm trying to calculate the value of the log cumulative hazard linear predictor from the output of flexsurvsline (see below)
In general, I would calculate linear predictors as the linear combination of the variable parameter estimates and the corresponding data values. In this case, I think gamma's should be multiplied by corresponding values of the basis functions? If so, how/where do I get the basis functions used for the model? My aim is to calculate the log cumulative hazard, and then survival probability, for different values of my variable1.
Many thanks for your help and time Stephen