View source: R/create_model_info.r
identify_tve | R Documentation |
This internal function takes a (survival) formula and data and determines if any variables need to be run with time-varying hazards. Optionally focus only on 'var' variables.
identify_tve(formula, data, var = NULL, random.effects = F)
formula |
A formula for the survival model to be run. |
data |
The raw data that the formula will be run on. |
var |
An optional vector indicating which variables to focus on (e.g., when running causal analysis). If 'var' is not null, non-proportional hazards for remaining variables are ignored. |
random.effects |
A logical variable indicating whether the formula has random effets. If so, a mixed-effects Cox model is run. |
The basic logic is to run the model conventionally and test the proportional hazards assumption using 'cox.zph' in the 'survival' package. Test works with normal survival models run using 'coxph' and mixed-effects models run using 'coxme'.
If time-varying hazards are identified than the appropriate variables are modified in the formula.
A data frame with the list of variables (or a subset if 'var' is set) and whether the variable has fails the proportional hazards assumption.
Other model setup functions:
determine_model()
,
parse_formula()
,
produce_model_function()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.