Learn R Programming

rprev (version 0.2.4)

functional_form_age: View the suitability of a linear effect of age on hazard.

Description

Inspects whether a non-linear transform of age is more appropriate for survival modeling than the linear method which is currently used in the calculations in prevalence.

Usage

functional_form_age(form, data, df = 4, plot_fit = TRUE, num_points = 200)

Arguments

form

Formula where the LHS is represented by a standard Surv object, and the RHS provides the name of the variable containing age in the supplied dataset.

data

A data frame with the corresponding column names provided in form.

df

The desired degrees of freedom for the cubic spline, must be >= 3.

plot_fit

Whether to plot the relationship between age and relative hazard.

num_points

The number of values of age to calculate the hazard ratio at.

Value

An rms::cph object containing the Cox model fit between a cubic spline transform of age and the survival outcomes.

Examples

Run this code
# NOT RUN {
data(prevsim)

functional_form_age(Surv(time, status) ~ age, prevsim)

functional_form_age(Surv(time, status) ~ age, prevsim, df=3)

functional_form_age(Surv(time, status) ~ age, prevsim, df=3, plot_fit=FALSE)

# }

Run the code above in your browser using DataLab