diag_covar: Evaluate covariate effect for regression model

View source: R/user_utilities.R

diag_covarR Documentation

Evaluate covariate effect for regression model

Description

Creates plots to diagnosis fit of covariate effect in a regression model. For a given variable, stratifies the data across different levels of the variable and adjusts for all the other covariates included in fit and then plots a given function to help diagnosis where covariate effect follows model assumption (i.e. either proportional hazards or proportional odds). See details for descriptions of the plots.

If varName is not provided, will attempt to figure out how to divide up each covariate and plot all of them, although this may fail.

Usage

diag_covar(
  object,
  varName,
  data,
  model,
  weights = NULL,
  yType = "meanRemovedTransform",
  factorSplit = TRUE,
  numericCuts,
  col,
  xlab,
  ylab,
  main,
  lgdLocation = NULL
)

Arguments

object

Either a formula or a model fit with ic_sp or ic_par

varName

Covariate to split data on. If left blank, will split on each covariate

data

Data. Unnecessary if object is a fit

model

Type of model. Choices are 'ph' or 'po'

weights

Case weights

yType

Type of plot created. See details

factorSplit

Should covariate be split as a factor (i.e. by levels)

numericCuts

If fractorSplit == FALSE, cut points of covariate to stratify data on

col

Colors of each subgroup plot. If left blank, will auto pick colors

xlab

Label of x axis

ylab

Label of y axis

main

title of plot

lgdLocation

Where legend should be placed. See details

Details

For the Cox-PH and proportional odds models, there exists a transformation of survival curves such that the difference should be constant for subjects with different covariates. In the case of the Cox-PH, this is the log(-log(S(t|X))) transformation, for the proporitonal odds, this is the log(S(t|X) / (1 - S(t|X))) transformation.

The function diag_covar allows the user to easily use these transformations to diagnosis whether such a model is appropriate. In particular, it takes a single covariate and stratifies the data on different levels of that covariate. Then, it fits the semi-parametric regression model (adjusting for all other covariates in the data set) on each of these stratum and extracts the baseline survival function. If the stratified covariate does follow the regression assumption, the difference between these transformed baseline survival functions should be approximately constant.

To help diagnosis, the default function plotted is the transformed survival functions, with the overall means subtracted off. If the assumption holds true, then the mean removed curves should be approximately parallel lines (with stochastic noise). Other choices of yType, the function to plot, are "transform", which is the transformed functions without the means subtracted and "survival", which is the baseline survival distribution is plotted for each strata.

Currently does not support stratifying covariates that are involved in an interaction term.

For variables that are factors, it will create a strata for each level of the covariate, up to 20 levels. If factorSplit == FALSE, will divide up numeric covariates according to the cuts provided to numericCuts.

lgdLocation is an argument placed to legend dictating where the legend will be placed. If lgdLocation = NULL, will use standard placement given yType. See ?legend for more details.

Author(s)

Clifford Anderson-Bergman


icenReg documentation built on May 29, 2024, 5:32 a.m.