toTpch: Transform survival data to tabular form

View source: R/toTpch.R

toTpchR Documentation

Transform survival data to tabular form

Description

Transform a "survival data frame" to tabular form aggregating number of events and exposure time by time intervals and covariates.

Usage

toTpch(formula, data, cuts, enter = "enter", exit = "exit",
event = "event", episode = "age")

Arguments

formula

A model formula.

data

A data frame with survival data.

cuts

An ordered, non-negative vector of time points at which a hazard function changes value. Note that data are left truncated at cuts[1] (the smallest value) and right censored at c[n], where n is the length of cuts and cuts[n] == max(cuts).

enter

Character string with the name of the variable representing left truncation values.

exit

Character string with the name of the event/censoring time variable.

event

Character string with the name of the event indicator variable.

episode

Character string with the name of the output variable of the grouped time (a factor variable).

Details

If cuts is missing, nothing is done. Internally, this function first calls survival::survSplit and then stats::aggregate.

Value

A data frame with exposure time and number of events aggregated by time intervals and covariates. If all covariates are factors,this usually results in a huge reduction of the size of thedata frame, but otherwise the size of the output may be larger than the size of the input data frame

Note

Episodes, or parts of episodes, outside min(cuts), max(cuts) are cut off. With continuous covariates, consider rounding them so that the number of distinct oberved values is not too large.

Author(s)

Göran Broström


eha documentation built on Oct. 7, 2024, 1:17 a.m.