Package 'smoothHR'

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] , Luis Meira-Machado [aut]
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

Help Index


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.

Details

Package: smoothHR
Type: Package
Version: 1.0.5
Date: 2024-02-25
License: GPL-3
LazyLoad: yes
LazyData: yes

Author(s)

Artur Araújo and Luís Meira-Machado [email protected]
Maintainer: Artur Araújo [email protected]

References

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


Degrees of freedom in multivariate additive Cox models

Description

Provides the degrees of freedom for flexible continuous covariates in multivariate additive Cox models.

Usage

dfmacox(time, time2=NULL, status, nl.predictors, other.predictors,
smoother, method, mindf=NULL, maxdf=NULL, ntimes=NULL, data)

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.

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 time, time2, and status.

Value

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.

Author(s)

Artur Araújo and Luís Meira-Machado

References

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

Examples

# 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)

Flexible hazard ratio curves taking a specific covariate value as reference

Description

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.

Usage

## 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"), ...)

Arguments

x

An object of class HR

predictor

Variable named in the formula or included as a predictor in the coxfit. Usually a continuous predictor of survival for which the results are expressed in terms of hazard ratio curves, taking a specific covariate value as reference.

prob

Value between 0 and 1. If prob=0 the reference value will be the minimum of the hazard ratio curve. If prob=1 the reference value will be the maximum of the hazard ratio curve. For values between 0 and 1 the reference value will be the corresponding quantile of the variable predictor.

pred.value

Value from the variable predictor to be taken as the reference value.

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 predictor) to be shown in the x axis.

ylog

If TRUE plots natural logarithm of hazard ratio.

log

Axis logarithmic scale. See plot.default for details.

...

Other arguments.

Value

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.

Author(s)

Artur Araújo and Luís Meira-Machado

References

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

See Also

smoothHR.

Examples

# 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'.

Description

predict method for an object of class 'HR'.

Usage

## 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, ...)

Arguments

object

An object of class HR.

predictor

Variable named in the formula or included as a predictor in the coxfit. Usually a continuous predictor of survival for which the results are expressed in terms of hazard ratio curves, taking a specific covariate value as reference.

prob

Value between 0 and 1. If prob=0 the reference value will be the minimum of the hazard ratio curve. If prob=1 the reference value will be the maximum of the hazard ratio curve. For values between 0 and 1 the reference value will be the corresponding quantile of the variable predictor.

pred.value

Value from the variable predictor to be taken as the reference value.

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 predictor.

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.

Value

Returns a matrix with the prediction values.

Author(s)

Artur Araújo and Luís Meira-Machado

References

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

See Also

smoothHR.

Examples

# 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.")

print method for a Smooth Hazard Ratio Object

Description

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.

Usage

## S3 method for class 'HR'
print(x, ...)

Arguments

x

An object of class HR.

...

Other arguments.

Value

No value is returned.

Author(s)

Artur Araújo and Luís Meira-Machado

References

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

See Also

smoothHR.

Examples

# 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)

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.

Usage

smoothHR(data, time=NULL, time2=NULL, status=NULL, formula=NULL, coxfit,
status.event=NULL)

Arguments

data

A data.frame in which to interpret the variables named in the formula or in the arguments time, time2, status and coxfit.

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 time, time2, status and formula.

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 status.event indicates which value denotes the event of interest.

Value

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.

Author(s)

Artur Araújo and Luís Meira-Machado

References

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

Examples

# 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)

Worcester Heart Attack Study WHAS500 Data

Description

Data from the Worcester Heart Attack Study

Usage

data(whas500)

Format

A data frame with 500 observations with 22 variables.

Details

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.

Source

Worcester Heart Attack Study data from Dr. Robert J. Goldberg of the Department of Cardiology at the University of Massachusetts Medical School.

References

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.

Examples

data(whas500)