calc_risk function

Calculate the Cox Proportional hazards relative risk associated with the covariates of subjects

Calculate the Cox Proportional hazards relative risk associated with the covariates of subjects

This function can be used to calculate the change in the relative risk of a subject pertaining to their covariates under a specified Cox proportional hazards model.

calc_risk(data, coxphmod = NULL)

Arguments

  • data: A data frame containing the covariates to be used for risk-adjustment as named columns.

  • coxphmod: (optional): A cox proportional hazards model generated using coxph() or a list containing:

    • formula:: a formula() in the form ~ covariates;
    • coefficients:: a named vector specifying risk adjustment coefficients for covariates. Names must be the same as in formula and colnames of data.

Returns

A vector of nrow(data) specifying the increased/decreased risk of failure for each subject.

Details

The subject-specific relative risk is exp(βZi)exp(\beta * Z_i), where β\beta is a vector of regression coefficients and ZiZ_i a vector of covariates for subject i.

Examples

#Small example data crdat <- data.frame(age = rnorm(10, 40, 5), BMI = rnorm(10, 24, 3)) #Example risk-adjustment list (can also specify coxphmod) crlist <- list(formula = as.formula("~age + BMI"), coefficients = c("age"= 0.02, "BMI"= 0.009)) #Calculate the increase or decrease of the relative risk for the subjects #in crdat. calc_risk(crdat, crlist)

Author(s)

Daniel Gomon