Learn R Programming

survPen (version 2.0.1)

splitmult: Split original dataset at specified times to fit a multiplicative model

Description

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).

Usage

splitmult(data, cut, start = NULL, end, event)

Value

split dataset with follow-up time split at specified times. An 'id_row' column is added to identify original row numbers

Arguments

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

Details

This function is close to the survsplit function proposed in relsurv package, but it is simpler since fewer features are needed.

Examples

Run this code
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)


Run the code above in your browser using DataLab