spell_features: Find features of a spell that are useful for estimating...

Description Usage Arguments Details Value Examples

Description

Find features of a spell that are useful for estimating survival models with interval censored observations

Usage

1
spell_features(df, var, group, right_censored = TRUE)

Arguments

df

data frame with the spell variable

var

character string specifying the variable in df with information specifying the spell.

group

character string specifying a group variable (if any) to find spell features within groups.

right_censored

logical. If TRUE the final observation is treated as right-censored, i.e. coded as 0. If FALSE the the final observation is treated as an event.

Details

Note: assumes that var is in time order and that observations are equally spaced in time.

Value

Four columns in addition to the original data frame of the spell_id, a binary spell_event variable, as well as spell_time1 and spell_time2 with the interval start and end times within each spell.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Create fake data
group_id <- c(rep('aa', 7), rep('bb', 4))
x <- c(rep('a', 4), rep('b', 3), 'c', rep('a', 2), 'c')
fake_data <- data.frame(group_id = group_id, spell = x)

# Find spell features
spell_features(fake_data, var = 'spell')
spell_features(fake_data, var = 'spell', group = 'group_id')
spell_features(fake_data, var = 'spell', group = 'group_id',
               right_censored = FALSE)

christophergandrud/SurvSetup documentation built on May 13, 2019, 7:01 p.m.