Title: | Smooth Hazard Ratio Curves Taking a Reference Value |
---|---|
Description: | Provides flexible hazard ratio curves allowing non-linear relationships between continuous predictors and survival. To better understand the effects that each continuous covariate has on the outcome, results are expressed in terms of hazard ratio curves, taking a specific covariate value as reference. Confidence bands for these curves are also derived. |
Authors: | Artur Araujo [aut, cre] |
Maintainer: | Artur Araujo <[email protected]> |
License: | GPL-3 |
Version: | 1.0.5 |
Built: | 2025-01-20 03:09:16 UTC |
Source: | https://github.com/arturstat/smoothhr |
Provides flexible hazard ratio curves allowing non-linear relationships between continuous predictors and survival. To better understand the effects that each continuous covariate has on the outcome, results are expressed in terms of hazard ratio curves, taking a specific covariate value as reference. Confidence bands for these curves are also derived.
Package: | smoothHR |
Type: | Package |
Version: | 1.0.5 |
Date: | 2024-02-25 |
License: | GPL-3 |
LazyLoad: | yes |
LazyData: | yes |
Artur Araújo and Luís Meira-Machado [email protected]
Maintainer: Artur Araújo [email protected]
Cadarso-Suarez, C. and Meira-Machado, L. and Kneib, T. and Gude, F. (2010). Flexible hazard ratio curves for continuous predictors in multi-state models: an application to breast cancer data. Statistical Modelling, 10(3), 291-314. doi:10.1177/1471082X0801000303
Eilers, Paul H. and Marx, Brian D. (1996). Flexible smoothing with B-splines and penalties. Statistical Science, 11(2), 89-121. doi:10.1214/ss/1038425655
Hosmer, D. W. and Lemeshow, S. and May, S. (2008). Applied Survival Analysis: Regression Modeling of Time to Event Data: Second Edition, John Wiley and Sons Inc., New York, NY.
Hurvich, C. M. and Simonoff, J. S. and Tsai, Chih-Ling (1998). Smoothing parameter selection in nonparametric regression using an improved Akaike information criterion. JRSSB, 60(2), 271-293. doi:10.1111/1467-9868.00125
Meira-Machado, L. and Cadarso-Suárez, C. and Gude, F. and Araújo, A. (2013). smoothHR: An R Package for Pointwise Nonparametric Estimation of Hazard Ratio Curves of Continuous Predictors. Computational and Mathematical Methods in Medicine, 2013, 11 pages. doi:10.1155/2013/745742
Provides the degrees of freedom for flexible continuous covariates in multivariate additive Cox models.
dfmacox(time, time2=NULL, status, nl.predictors, other.predictors, smoother, method, mindf=NULL, maxdf=NULL, ntimes=NULL, data)
dfmacox(time, time2=NULL, status, nl.predictors, other.predictors, smoother, method, mindf=NULL, maxdf=NULL, ntimes=NULL, data)
time |
For right censored data, this is the follow up time. For interval data, the first argument is the starting time for the interval. |
time2 |
Ending time of the interval for interval censored or counting process data only. Intervals are assumed to be open on the left and closed on the right, (start, end]. For counting process data, event indicates whether an event occurred at the end of the interval. |
status |
The status indicator, normally 0=alive, 1=dead. Other choices are TRUE/FALSE (TRUE = death) or 1/2 (2=death). For interval censored data, the status indicator is 0=right censored, 1=event at time, 2=left censored, 3=interval censored. Although unusual, the event indicator can be omitted, in which case all subjects are assumed to have an event. |
nl.predictors |
Vector with covariates to be introduced in the additive Cox model with a nonlinear effect. |
other.predictors |
Vector with remaining covariates to be introduced in the additive Cox model. This will include qualitative covariates or continuous covariates with a linear effect. |
smoother |
Smoothing method to be used in the additive Cox model. Possible options are ‘ns’ for natural spline smoothing or ‘pspline’ for penalized spline smoothing. |
method |
The desired method to obtain the optimal degrees of freedom. If method ="AIC", then the AIC = (loglik -df) is used to choose the "optimal" degrees of freedom. The corrected AIC of Hurvich et. al. (method="AICc") and the BIC criterion (method = "BIC") can also be used. |
mindf |
Vector with minimum degrees of freedom for each nonlinear predictor. By default this value is a vector of of the same length of nl.predictors all with value 1, if smoother is 'ns'; a vector with the same length of nl.predictors all with value 1.5, if smoother is 'pspline'. |
maxdf |
Vector with maximum degrees of freedom for each nonlinear predictor. By default, when penalized spline is used (smoother='pspline'), the corrected AIC from Hurvich obtained in the corresponding univariate additive Cox model is used. When penalized spline is used (smoother='ns') a vector with the same length of nl.predictors all with values 1.5. |
ntimes |
Internel procedure which involves repetion of some convergence steps to attain the optimal degrees of freedom. By deafault is 5. |
data |
A data.frame in which to interpret the variables named in the arguments |
An object of class list
, basically a list including the elements:
df |
Degrees of freedom of the 'nl.predictors'. |
AIC |
Akaike’s Information Criterion score of the fitted model. |
AICc |
Corrected Akaike’s Information Criterion score of the fitted model. |
BIC |
Bayesian Information Criterion score of the fitted model. |
myfit |
Fitted (additive Cox) model based on the chosen degrees of freedom. |
method |
The method used for obtaining the degrees of freedom. |
nl.predictors |
Vector with the nonlinear predictors. |
Artur Araújo and Luís Meira-Machado
Eilers, Paul H. and Marx, Brian D. (1996). Flexible smoothing with B-splines and penalties. Statistical Science, 11(2), 89-121. doi:10.1214/ss/1038425655
Hurvich, C. M. and Simonoff, J. S. and Tsai, Chih-Ling (1998). Smoothing parameter selection in nonparametric regression using an improved Akaike information criterion. JRSSB, 60(2), 271–293. doi:10.1111/1467-9868.00125
Meira-Machado, L. and Cadarso-Suárez, C. and Gude, F. and Araújo, A. (2013). smoothHR: An R Package for Pointwise Nonparametric Estimation of Hazard Ratio Curves of Continuous Predictors. Computational and Mathematical Methods in Medicine, 2013, 11 pages. doi:10.1155/2013/745742
# Example 1 library(survival) data(whas500) mydf_ns <- dfmacox(time="lenfol", status="fstat", nl.predictors=c("los", "bmi"), other.predictors=c("age", "hr", "gender", "diasbp"), smoother="ns", data=whas500) print(mydf_ns) # Example 2 mydf_ps <- dfmacox(time="lenfol", status="fstat", nl.predictors=c("los", "bmi"), other.predictors=c("age", "hr", "gender", "diasbp"), smoother="pspline", data=whas500) print(mydf_ps)
# Example 1 library(survival) data(whas500) mydf_ns <- dfmacox(time="lenfol", status="fstat", nl.predictors=c("los", "bmi"), other.predictors=c("age", "hr", "gender", "diasbp"), smoother="ns", data=whas500) print(mydf_ns) # Example 2 mydf_ps <- dfmacox(time="lenfol", status="fstat", nl.predictors=c("los", "bmi"), other.predictors=c("age", "hr", "gender", "diasbp"), smoother="pspline", data=whas500) print(mydf_ps)
Plots flexible hazard ratio curves allowing non-linear relationships between continuous predictors and survival. To better understand the effects that each continuous covariate has on the outcome, results are expressed in terms of hazard ratio curves, taking a specific covariate value as reference. Confidence bands for these curves are also derived.
## S3 method for class 'HR' plot(x, predictor, prob=NULL, pred.value=NULL, conf.level=0.95, round.x=NULL, ref.label=NULL, col, main, xlab, ylab, lty, xlim, ylim, xx, ylog=TRUE, log=ifelse(ylog, "", "y"), ...)
## S3 method for class 'HR' plot(x, predictor, prob=NULL, pred.value=NULL, conf.level=0.95, round.x=NULL, ref.label=NULL, col, main, xlab, ylab, lty, xlim, ylim, xx, ylog=TRUE, log=ifelse(ylog, "", "y"), ...)
x |
An object of class HR |
predictor |
Variable named in the formula or included as a predictor in the |
prob |
Value between 0 and 1. If |
pred.value |
Value from the variable |
conf.level |
Level of confidence. Defaults to 0.95 (corresponding to 95%). |
round.x |
Rounding of numbers in the plot. |
ref.label |
Label for the reference covariate. By default is the name of the covariate. |
col |
Vector of dimension 3 for the colors to plot. |
main |
These arguments to title have useful defaults here. |
xlab |
The range of x and y values with sensible defaults. |
ylab |
The range of x and y values with sensible defaults. |
lty |
Vector of dimension 2 for the line type. |
xlim |
The range of x and y values with sensible defaults. |
ylim |
The range of x and y values with sensible defaults. |
xx |
Vector of values (from the variable |
ylog |
If |
log |
Axis logarithmic scale. See |
... |
Other arguments. |
Invisibly returns the plot data, a data.frame including the elements:
x |
Predictor. |
y |
Hazard ratio or log hazard ratio. |
y.lower |
Lower bound of confidence interval. |
y.upper |
Upper bound of confidence interval. |
Artur Araújo and Luís Meira-Machado
Cadarso-Suarez, C. and Meira-Machado, L. and Kneib, T. and Gude, F. (2010). Flexible hazard ratio curves for continuous predictors in multi-state models: an application to breast cancer data. Statistical Modelling, 10(3), 291-314. doi:10.1177/1471082X0801000303
Meira-Machado, L. and Cadarso-Suárez, C. and Gude, F. and Araújo, A. (2013). smoothHR: An R Package for Pointwise Nonparametric Estimation of Hazard Ratio Curves of Continuous Predictors. Computational and Mathematical Methods in Medicine, 2013, 11 pages. doi:10.1155/2013/745742
# Example 1 library(survival) data(whas500) fit <- coxph(Surv(lenfol, fstat)~age+hr+gender+diasbp+pspline(bmi)+pspline(los), data=whas500, x=TRUE) hr1 <- smoothHR(data=whas500, coxfit=fit) plot(hr1, predictor="bmi", prob=0, conf.level=0.95) # Example 2 hr2 <- smoothHR( data=whas500, time="lenfol", status="fstat", formula=~age+hr+gender+diasbp+ pspline(bmi)+pspline(los) ) plot(hr2, predictor="los", pred.value=7, conf.level=0.95, xlim=c(0,30), round.x=1, ref.label="Ref.", xaxt="n") xx <- c(0, 5, 10, 15, 20, 25, 30) axis(1, xx)
# Example 1 library(survival) data(whas500) fit <- coxph(Surv(lenfol, fstat)~age+hr+gender+diasbp+pspline(bmi)+pspline(los), data=whas500, x=TRUE) hr1 <- smoothHR(data=whas500, coxfit=fit) plot(hr1, predictor="bmi", prob=0, conf.level=0.95) # Example 2 hr2 <- smoothHR( data=whas500, time="lenfol", status="fstat", formula=~age+hr+gender+diasbp+ pspline(bmi)+pspline(los) ) plot(hr2, predictor="los", pred.value=7, conf.level=0.95, xlim=c(0,30), round.x=1, ref.label="Ref.", xaxt="n") xx <- c(0, 5, 10, 15, 20, 25, 30) axis(1, xx)
predict method for an object of class 'HR'.
## S3 method for class 'HR' predict(object, predictor, prob=NULL, pred.value=NULL, conf.level=0.95, prediction.values=NULL, round.x=NULL, ref.label=NULL, ...)
## S3 method for class 'HR' predict(object, predictor, prob=NULL, pred.value=NULL, conf.level=0.95, prediction.values=NULL, round.x=NULL, ref.label=NULL, ...)
object |
An object of class HR. |
predictor |
Variable named in the formula or included as a predictor in the |
prob |
Value between 0 and 1. If |
pred.value |
Value from the variable |
conf.level |
Level of confidence. Defaults to 0.95 (corresponding to 95%). |
prediction.values |
Vector of values ranging between minimum and maximum of the variable |
round.x |
Rounding of numbers in the predict. |
ref.label |
Label for the reference covariate. By default is the name of the covariate. |
... |
Other arguments. |
Returns a matrix with the prediction values.
Artur Araújo and Luís Meira-Machado
Cadarso-Suarez, C. and Meira-Machado, L. and Kneib, T. and Gude, F. (2010). Flexible hazard ratio curves for continuous predictors in multi-state models: an application to breast cancer data. Statistical Modelling, 10(3), 291-314. doi:10.1177/1471082X0801000303
Meira-Machado, L. and Cadarso-Suárez, C. and Gude, F. and Araújo, A. (2013). smoothHR: An R Package for Pointwise Nonparametric Estimation of Hazard Ratio Curves of Continuous Predictors. Computational and Mathematical Methods in Medicine, 2013, 11 pages. doi:10.1155/2013/745742
# Example 1 library(survival) data(whas500) fit <- coxph(Surv(lenfol, fstat)~age+hr+gender+diasbp+pspline(bmi)+pspline(los), data=whas500, x=TRUE) hr1 <- smoothHR(data=whas500, coxfit=fit) predict(hr1, predictor="bmi", prob=0, conf.level=0.95) # Example 2 hr2 <- smoothHR( data=whas500, time="lenfol", status="fstat", formula=~age+hr+gender+diasbp+ pspline(bmi)+pspline(los) ) pdval <- c(1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 15, 18, 22, 25) predict(hr2, predictor="los", pred.value=7, conf.level=0.95, prediction.values=pdval, ref.label="Ref.")
# Example 1 library(survival) data(whas500) fit <- coxph(Surv(lenfol, fstat)~age+hr+gender+diasbp+pspline(bmi)+pspline(los), data=whas500, x=TRUE) hr1 <- smoothHR(data=whas500, coxfit=fit) predict(hr1, predictor="bmi", prob=0, conf.level=0.95) # Example 2 hr2 <- smoothHR( data=whas500, time="lenfol", status="fstat", formula=~age+hr+gender+diasbp+ pspline(bmi)+pspline(los) ) pdval <- c(1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 15, 18, 22, 25) predict(hr2, predictor="los", pred.value=7, conf.level=0.95, prediction.values=pdval, ref.label="Ref.")
This class of objects is returned by the HR class of functions to represent smooth hazard ratio curve. Objects of this class have methods for print
, predict
and plot
.
## S3 method for class 'HR' print(x, ...)
## S3 method for class 'HR' print(x, ...)
x |
An object of class HR. |
... |
Other arguments. |
No value is returned.
Artur Araújo and Luís Meira-Machado
Meira-Machado, L. and Cadarso-Suárez, C. and Gude, F. and Araújo, A. (2013). smoothHR: An R Package for Pointwise Nonparametric Estimation of Hazard Ratio Curves of Continuous Predictors. Computational and Mathematical Methods in Medicine, 2013, 11 pages. doi:10.1155/2013/745742
# Example 1 library(survival) data(whas500) fit <- coxph(Surv(lenfol, fstat)~age+hr+gender+diasbp+pspline(bmi)+pspline(los), data=whas500, x=TRUE) hr1 <- smoothHR(data=whas500, coxfit=fit) print(hr1) # Example 2 hr2 <- smoothHR( data=whas500, time="lenfol", status="fstat", formula=~age+hr+gender+diasbp+ pspline(bmi)+pspline(los) ) print(hr2)
# Example 1 library(survival) data(whas500) fit <- coxph(Surv(lenfol, fstat)~age+hr+gender+diasbp+pspline(bmi)+pspline(los), data=whas500, x=TRUE) hr1 <- smoothHR(data=whas500, coxfit=fit) print(hr1) # Example 2 hr2 <- smoothHR( data=whas500, time="lenfol", status="fstat", formula=~age+hr+gender+diasbp+ pspline(bmi)+pspline(los) ) print(hr2)
Provides flexible hazard ratio curves allowing non-linear relationships between continuous predictors and survival. To better understand the effects that each continuous covariate has on the outcome, results are expressed in terms of hazard ratio curves, taking a specific covariate value as reference. Confidence bands for these curves are also derived.
smoothHR(data, time=NULL, time2=NULL, status=NULL, formula=NULL, coxfit, status.event=NULL)
smoothHR(data, time=NULL, time2=NULL, status=NULL, formula=NULL, coxfit, status.event=NULL)
data |
A data.frame in which to interpret the variables named in the formula or in the arguments |
time |
For right censored data, this is the follow up time. For interval data, the first argument is the starting time for the interval. |
time2 |
Ending time of the interval for interval censored or counting process data only. Intervals are assumed to be open on the left and closed on the right, (start, end]. For counting process data, event indicates whether an event occurred at the end of the interval. |
status |
The status indicator, normally 0=alive, 1=dead. Other choices are TRUE/FALSE (TRUE = death) or 1/2 (2=death). For interval censored data, the status indicator is 0=right censored, 1=event at time, 2=left censored, 3=interval censored. Although unusual, the event indicator can be omitted, in which case all subjects are assumed to have an event. |
formula |
A formula object, with the terms on the right after the ~ operator. |
coxfit |
An object of class coxph. This argument is optional, being an alternative to the arguments |
status.event |
The status indicator is a qualitative variable where usually the highest value is left for the event of interest (usually 0=alive, 1=dead).
If that is not the case the |
An object of class HR
. There are methods for print
, predict
and plot
.
HR
objects are implemented as a list with elements:
dataset |
Dataset used. |
coxfit |
The object of class 'coxph' used. |
phtest |
Result from testing the proportional hazards assumption. |
Artur Araújo and Luís Meira-Machado
Cadarso-Suarez, C. and Meira-Machado, L. and Kneib, T. and Gude, F. (2010). Flexible hazard ratio curves for continuous predictors in multi-state models: an application to breast cancer data. Statistical Modelling, 10(3), 291-314. doi:10.1177/1471082X0801000303
Meira-Machado, L. and Cadarso-Suárez, C. and Gude, F. and Araújo, A. (2013). smoothHR: An R Package for Pointwise Nonparametric Estimation of Hazard Ratio Curves of Continuous Predictors. Computational and Mathematical Methods in Medicine, 2013, 11 pages. doi:10.1155/2013/745742
# Example 1 library(survival) data(whas500) fit <- coxph(Surv(lenfol, fstat)~age+hr+gender+diasbp+pspline(bmi)+pspline(los), data=whas500, x=TRUE) hr1 <- smoothHR(data=whas500, coxfit=fit) print(hr1) # Example 2 hr2 <- smoothHR( data=whas500, time="lenfol", status="fstat", formula=~age+hr+gender+diasbp+ pspline(bmi)+pspline(los) ) print(hr2)
# Example 1 library(survival) data(whas500) fit <- coxph(Surv(lenfol, fstat)~age+hr+gender+diasbp+pspline(bmi)+pspline(los), data=whas500, x=TRUE) hr1 <- smoothHR(data=whas500, coxfit=fit) print(hr1) # Example 2 hr2 <- smoothHR( data=whas500, time="lenfol", status="fstat", formula=~age+hr+gender+diasbp+ pspline(bmi)+pspline(los) ) print(hr2)
Data from the Worcester Heart Attack Study
data(whas500)
data(whas500)
A data frame with 500 observations with 22 variables.
Data from the Worcester Heart Attack Study whose main goal was to describe factors associated with trends over time in the incidence and survival rates following hospital admission for acute myocardial infarction.
Worcester Heart Attack Study data from Dr. Robert J. Goldberg of the Department of Cardiology at the University of Massachusetts Medical School.
Hosmer, D. W. and Lemeshow, S. and May, S. (2008). Applied Survival Analysis: Regression Modeling of Time to Event Data: Second Edition, John Wiley and Sons Inc., New York, NY.
data(whas500)
data(whas500)