splitmult | R Documentation |
This function allows splitting the original dataset in order to retrieve all the expected mortality rates available according to each individual's follow-up time. Typically, the expected mortality rates come from national mortality tables and values are available for every combination of age and year (often with 1-year increment).
splitmult(data, cut, start = NULL, end, event)
data |
orginal datset |
cut |
vector of timepoints to cut at (usually every year of follow-up) |
start |
character string with name of start variable (will be created and set to zero if it does not exist) |
end |
character string with name of event time variable |
event |
character string with name of censoring indicator |
This function is close to the survsplit function proposed in relsurv package, but it is simpler since fewer features are needed.
split dataset with follow-up time split at specified times. An 'id_row' column is added to identify original row numbers
library(survPen)
data(datCancer)
data(expected.table)
#-------------------- creating split dataset for multiplicative model
splitdat <- splitmult(datCancer, cut = (1:5), end = "fu",
event = "dead")
#-------------------- merging with expected mortality table
# deriving current age and year (closest whole number)
splitdat$age_current <- floor(splitdat$age + splitdat$fu + 0.5)
splitdat$year_current <- floor(splitdat$yod + splitdat$fu + 0.5)
splitdat <- merge(splitdat, expected.table,
by.x=c("age_current","year_current"), by.y=c("Age","Year"),all.x=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.