Skip to content

standsurv for flexsurvspline incorporating competing risk? #210

@XinyuZou97

Description

@XinyuZou97

thanks for all your work on this amazing package! I'm trying to incorporate competing risk in a flexsurvspline() object. I've read the vignette for multi-state modelling and it mentioned that spline models may also be fitted. Is it possible to calculate the marginal effect of the fitted spline model object using standsurv()?

here is a simple example:

#trans=1 from initial status to event of interest
#trans=2 from initial status to competing event
#trans=3 from event of interest to competing event

dt_trans<-data.frame(
id=c(1,1,2,2,3,3,3),
time=c(8.6,8.6,11,11,0.6,4.7,4.1),
status=c(0,0,0,0,1,0,1),
trans=c(1,2,1,2,1,2,3),
x=c('good','good','good','good','medium','medium','medium'),#covariate of interest
age=c(60,60,65,65,70,70,70))

#fit spline model incorporate competing risk, time-varying effect of x, and covariate age

#the joint likelihood model was fitted because it seems that standsurv() did not support transition-specific models

fit_joint<-flexsurvspline(
Surv(time,status) ~ x +gamma1(x)+trans+age,
scale = "hazard",
k = 2,
data = dt_trans
)

#calculate marginal survival probability for event of interest (i.e, trans=1)

dt_standsurv <- standsurv(fit_joint,
type = 'survival',
at = list(
list(x = "good",trans='1'),
list(x = "medium",trans='1')
),
t = 10,
ci = TRUE
)

is the code above correct? I tried to run these codes in R and it did not return any warnings and error.

huge thanks if you could help solving this question!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions