identify_tve: Determine whether a survival model needs to be run with...

View source: R/create_model_info.r

identify_tveR Documentation

Determine whether a survival model needs to be run with time-varying hazards.

Description

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.

Usage

identify_tve(formula, data, var = NULL, random.effects = F)

Arguments

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.

Details

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.

Value

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.

See Also

Other model setup functions: determine_model(), parse_formula(), produce_model_function()


jacobaro/danalyze documentation built on Oct. 20, 2022, 8:09 a.m.