library(dplyr)
# Example 1 with right-censored data
fit1 <- phregr(data = rawdata %>% filter(iterationNumber == 1) %>%
mutate(treat = 1*(treatmentGroup == 1)),
stratum = "stratum",
time = "timeUnderObservation", event = "event",
covariates = "treat")
ressco <- residuals_phregr(fit1, type = "score")
# Example 2 with counting process data
fit2 <- phregr(data = heart %>% mutate(rx = as.numeric(transplant) - 1),
time = "start", time2 = "stop", event = "event",
covariates = c("rx", "age"), id = "id", robust = TRUE)
resssch <- residuals_phregr(fit2, type = "scaledsch")
Run the code above in your browser using DataLab