sahirbhatnagar/casebase

Fit competing risk model using cbData object

Closed this issue · 2 comments

I recently encountered an unexpected result when using fitSmoothHazard to model competing event data using a cbData object I'd created outside of fitSmoothHazard (I have time-varying covariates I'd like to incorporate). However, it appears that fitSmoothHazard creates an S4 object that expects there to be an original dataset and a sampled dataset. Since in this case it only gets a sampled dataset it to throws an error. Here is a reproducible example:

library(casebase)
#> See example usage at http://sahirbhatnagar.com/casebase/

#simulate some data with competing events
dta = data.frame(
  time = exp(rnorm(100)),
  event = sample(0:2, size=100, replace=TRUE)
)

#create dataset with casebase samples
cbdata = sampleCaseBase(data = dta, time = "time", event = "event", comprisk = TRUE)

#try to fit the smooth hazard model for competing events
fitSmoothHazard(event ~ time, data = cbdata, time = "time")
#> Error in validObject(.Object): invalid class "CompRisk" object: invalid object for slot "originalData" in class "CompRisk": got class "NULL", should be or extend class "data.frame"

Created on 2021-07-16 by the reprex package (v1.0.0)

Thanks for your interest in our package, and special thanks for the reprex. We should have a patch shortly.

@colinorourke The recent pull-request #150, which has now been merged to the master branch, should fix this issue. Let us know if you still face any problem!