define_wtd_surv_table: combine multiple columns into a survival table

Description Usage Arguments Details Value Examples

View source: R/survival_define.R

Description

combine multiple columns into a survival table

Usage

1
2
3
4
5
6
7
define_wtd_surv_table(x, time_col, weights, by_age)

## S3 method for class 'character'
define_wtd_surv_table(x, time_col, weights, by_age)

## S3 method for class 'data.frame'
define_wtd_surv_table(x, time_col, weights, by_age)

Arguments

x

a data frame, or a string pointing to such a data frame

time_col

the column of x measuring time

weights

a named vector of weights. Names correspond to the columns of x to which the weights should be applied.

by_age

is time in the table measured by age instead of cycle (as is typical for a mortality table, for example).

Details

weights are not checked for adding to 1.

Value

a surv_pooled object (see mix()).

Examples

1
2
3
4
5
6
7
8
df <- data.frame(age = c(50, 55, 60, 65), 
                 male = c(1, 0.9, 0.8, 0.7),
                 female = c(1, 0.8, 0.7, 0.6)
                 )
wtd_table <- 
   define_wtd_surv_table(df, time_col = "age",
                         weights = c(male = 0.52, female = 0.48),
                         by_age = TRUE)                

MattWiener/heemodFits documentation built on May 19, 2019, 8:21 a.m.