Type: | Package |
Title: | Optimal Equal-HR Method to Find Two Cutpoints for U-Shaped Relationships in Cox Model |
Version: | 0.1.2 |
Author: | Yimin Chen, Zhang Jinxin |
Maintainer: | Yimin Chen <chenyimin0226@126.com> |
Description: | Use optimal equal-HR method to determine two optimal cutpoints of a continuous predictor that has a U-shaped relationship with survival outcomes based on Cox regression model. The optimal equal-HR method estimates two optimal cut-points that have approximately the same log hazard value based on Cox regression model and divides individuals into different groups according to their HR values. |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
Imports: | survival |
NeedsCompilation: | no |
RoxygenNote: | 6.1.0.9000 |
Packaged: | 2018-10-10 04:10:48 UTC; ad |
Repository: | CRAN |
Date/Publication: | 2018-10-10 11:50:11 UTC |
Find two optimal cutpoints using optimal equal-HR method
Description
Use optimal equal-HR method to determine two optimal cutpoints of a continuous predictor that has a U-shape relationship with survival outcomes based on Cox regression model.
Usage
findcutpoints(cox_pspline_fit, data, nquantile = 100, exclude = 0.05,
eps = 0.01, shape = "U")
Arguments
cox_pspline_fit |
Cox model with psplined x, e.g. coxph(Surv(t,d)~pspline(x,df=0,caic=T),data=test). |
data |
a dataframe contain survival outcome and a continuous variable which needs to find two optimal cutpoints. |
nquantile |
an integer; the default value is 100, which means using the 100-quantiles of log relative hazard to find cutpoints. |
exclude |
a decimals; it is used for excluding extreme values of log relative hazardthe. The default value is 0.05, which log relative hazard values smaller than 5th percentile or larger than 95th percentile are excluded. |
eps |
a decimals; the default value is 0,01. It restrict the difference between the log relative hazard values of two cadidate cutpoints to be less than 0.01. |
shape |
a string; equals "U" or "inverseU" |
Details
A function to find two optimal cutpoints
Examples
#### Example 1. Find two optimal cutpoints in an univariate Cox model
# Fit an univariate Cox model with pspline
require(survival)
result <- coxph(Surv(t,d)~pspline(x,df=0,caic=TRUE),data=test)
# Visualize the relationship
# Explore whether there is a U-shaped relationship between x and log relative hazard
termplot(result,se=TRUE,col.term=1,ylab='log relative hazard')
# Find two opitmal cutpoints using optimal equal-HR method.
cuts <- findcutpoints(cox_pspline_fit = result, data = test, shape='U')
cuts$optimal # output two optimal cutpoints
#### Example 2. Find two optimal cutpoints in a multivariate Cox model
# Fit a multivariate Cox model with pspline
# The independent variable which is need to find cutpoints should be placed before other covariates.
# To find cutpoints of x, Surv(t,d)~pspline(x)+x1 should be used instead of Surv(t,d)~x1+pspline(x)
require(survival)
result <- coxph(Surv(t,d)~pspline(x,df=0,caic=TRUE)+x1,data=test)
# The rest procedure is the same as example 1
# Visualize the relationship
# Explore whether there is a U-shaped relationship between x and log relative hazard
termplot(result,se=TRUE,col.term=1,ylab='log relative hazard')
# Find two opitmal cutpoints of the first independent variable.
cuts <- findcutpoints(cox_pspline_fit = result, data = test, shape='U')
cuts$optimal # output two optimal cutpoints
A simulation data to test cutpointsOEHR
Description
A dataframe named 'test'contains simulated (t,d,x,x1). The relationship of log relative hazard and x is set to to quandratic, which results in a U-shaped relationship.
Usage
test
Format
a dataframe contains 200 rows and 4 variables. The 4 varibles are
- t
simulated times of developing survival outcomes like deathes, relapes, etc.
- d
censoring indicator, 1 means that survival outcomes are not observed, 0 means survival outcomes are observed. The censoring proportion is set to be 20 percent.
- x
a continuous variable which has U-shaped relationship with log relative hazard.
- x1
a continuous variable which has linear relationship with log relative hazard.