coxphw {coxphw}  R Documentation 
Weighted Cox regression as proposed by Schemper et al. (2009) doi: 10.1002/sim.3623 provides unbiased estimates of average hazard ratios also in case of nonproportional hazards. Timedependent effects can be conveniently estimated by including interactions of covariates with arbitrary functions of time, with or without making use of the weighting option.
coxphw(formula, data, template = c("AHR", "ARE", "PH"), subset, na.action, robust = TRUE, jack = FALSE, betafix = NULL, alpha = 0.05, trunc.weights = 1, control, caseweights, x = TRUE, y = TRUE, verbose = FALSE, sorted = FALSE, id = NULL, clusterid = NULL, ...)
formula 
a formula object with the response on the left of the operator and the model terms
on the right. The response must be a survival object as returned by

data 
a data frame in which to interpret the variables named in 
template 
choose among three predefined templates: 
subset 
expression indicating which subset of the rows of data should be used in the fit. All observations are included by default. 
na.action 
missingdata filtering. Defaults to 
robust 
if set to TRUE, the robust covariance estimate (LinWei) is used; otherwise the LinSasieni covariance estimate is applied. Default is TRUE. 
jack 
if set to TRUE, the variance is based on a complete jackknife. Each individual (as
identified by 
betafix 
can be used to restrict the estimation of one or more regression coefficients to predefined
values. A vector with one element for each model term as given in 
alpha 
the significance level (1α), 0.05 as default. 
trunc.weights 
specifies a quantile at which the (combined normalized) weights are to be truncated.
It can be used to increase the precision of the estimates, particularly if

control 
Object of class 
caseweights 
vector of case weights, equivalent to 
x 
requests copying explanatory variables into the output object. Default is TRUE. 
y 
requests copying survival information into the output object. Default is TRUE. 
verbose 
requests echoing of intermediate results. Default is FALSE. 
sorted 
if set to TRUE, the data set will not be sorted prior to passing it to FORTRAN. This may speed up computations. Default is FALSE. 
id 
a vector of subject identification integer numbers starting from 1 used only if the data are
in the counting process format. These IDs are used to compute the robust covariance matrix.
If 
clusterid 
a vector of cluster identification integer numbers starting from 1. These IDs are used
to compute the robust covariance matrix. If 
... 
additional arguments. 
If Cox's proportional hazards regression is used in the presence of nonproportional hazards, i.e., with underlying timedependent hazard ratios of prognostic factors, the average relative risk for such a factor is under or overestimated and testing power for the corresponding regression parameter is reduced. In such a situation weighted estimation provides a parsimonious alternative to more elaborate modelling of timedependent effects. Weighted estimation in Cox regression extends the tests by Breslow and Prentice to a multicovariate situation as does the Cox model to Mantel's logrank test. Weighted Cox regression can also be seen as a robust alternative to the standard Cox estimator, reducing the influence of outlying survival times on parameter estimates.
Three predefined templates can be requested:
1) "AHR"
, i.e., estimation of average hazard ratios
(Schemper et al., 2009) using Prentice weights with censoring correction and robust variance estimation;
2) "ARE"
, i.e., estimation of average regression effects (Xu and O'Quigley, 2000) using censoring
correction and robust variance estimation; or
3) "PH"
, i.e., Cox proportional hazards regression
using robust variance estimation.
Breslow's tiehandling method is used by the program, other methods to handle ties are currently not available.
A fit of coxphw
with template = "PH"
will yield identical estimates as a fit of
coxph
using Breslow's tie handling method and robust variance estimation
(using cluster
).
If robust = FALSE
, the program estimates the covariance matrix using the Lin (1991)
and Sasieni (1993) sandwich estimate A^{1}BA^{1} with A and B denoting the sum
of contributions to the second derivative of the log likelihood, weighted by w(t_j) and w(t_j)^2,
respectively. This estimate is independent from the scaling of the weights and reduces to the inverse
of the information matrix in case of no weighting. However, it is theoretically valid only in case of
proportional hazards. Therefore, since application of weighted Cox regression usually implies a violated
proportional hazards assumption, the robust LinWei covariance estimate is used by default (robust =
TRUE
).
If some regression coefficients are held constant using betafix
, no standard errors
are given for these coefficients as they are not estimated in the model. The global Wald test
only relates to those variables for which regression coefficients were estimated.
An offset
term can be included in the formula
of coxphw
.
In this way a variable can be specified which is included in the model but its parameter estimate is
fixed at 1.
A list with the following components:
coefficients 
the parameter estimates. 
var 
the estimated covariance matrix. 
df 
the degrees of freedom. 
ci.lower 
the lower confidence limits of exp(beta). 
ci.upper 
the upper confidence limits of exp(beta). 
prob 
the pvalues. 
linear.predictors 
the linear predictors. 
n 
the number of observations. 
dfbeta.resid 
matrix of DFBETA residuals. 
iter 
the number of iterations needed to converge. 
method.ties 
the ties handling method. 
PTcoefs 
matrix with scale and shift used for pretransformation of 
cov.j 
the covariance matrix computed by the jackknife method (only computed if 
cov.lw 
the covariance matrix computed by the LinWei method (robust covariance) 
cov.ls 
the covariance matrix computed by the LinSasieni method. 
cov.method 
the method used to compute the (displayed) covariance matrix and the standard errors.
This method is either "jack" if 
w.matrix 
a matrix with four columns according to the number of uncensored failure
times. The first column contains the failure times, the remaining columns (labeled

caseweights 
if 
Wald 
Waldtest statistics. 
means 
the means of the covariates. 
offset.values 
offset values. 
dataline 
the first dataline of the input data set (required for 
x 
if 
y 
the response. 
alpha 
the significance level = 1  confidence level. 
template 
the requested template. 
formula 
the model formula. 
betafix 
the 
call 
the function call. 
The SAS
macro WCM
with similar functionality is offered for download at
http://cemsiis.meduniwien.ac.at/en/kb/scienceresearch/software/statisticalsoftware/wcmcoxphw/ .
Up to Version 2.13 coxphw used a slightly different syntax (arguments: AHR
,
AHR.norobust
, ARE
, PH
, normalize
, censcorr
, prentice
,
breslow
, taroneware
). From Version 3.0.0 on the old syntax is disabled.
From Version 4.0.0 estimation of fractional polynomials is disabled.
Georg Heinze, Meinhard Ploner, Daniela Dunkler
Dunkler D, Ploner M, Schemper M, Heinze G. (2018) Weighted Cox Regression Using the R Package coxphw. JSS 84, 1–26, doi: 10.18637/jss.v084.i02.
Lin D and Wei L (1989). The Robust Inference for the Cox Proportional Hazards Model. J AM STAT ASSOC 84, 10741078.
Lin D (1991). GoodnessofFit Analysis for the Cox Regression Model Based on a Class of Parameter Estimators. J AM STAT ASSOC 86, 725728.
Royston P and Altman D (1994). Regression Using Fractional Polynomials of Continuous Covariates: Parsimonious Parametric Modelling. J R STAT SOC CAPPL 43, 429467.
Royston P and Sauerbrei W (2008). Multivariable ModelBuilding. A Pragmatic Approach to Regression Analysis Based on Fractional Polynomials for Modelling Continuous Variables. Wiley, Chichester, UK.
Sasieni P (1993). Maximum Weighted Partial Likelihood Estimators for the Cox Model. J AM STAT ASSOC 88, 144152.
Schemper M (1992). Cox Analysis of Survival Data with NonProportional Hazard Functions. J R STAT SOC D 41, 455465.
Schemper M, Wakounig S and Heinze G (2009). The Estimation of Average Hazard Ratios by Weighted Cox Regression. STAT MED 28, 24732489. doi: 10.1002/sim.3623
Xu R and O'Quigley J (2000). Estimating Average Regression Effect Under NonProportional Hazards. Biostatistics 1, 423439.
concord
, plot.coxphw
, predict.coxphw
, plot.coxphw.predict
, coxph
data("gastric") # weighted estimation of average hazard ratio fit1 < coxphw(Surv(time, status) ~ radiation, data = gastric, template = "AHR") summary(fit1) fit1$cov.lw # robust covariance fit1$cov.ls # LinSasieni covariance # unweighted estimation, include interaction with years # ('radiation' must be included in formula!) gastric$years < gastric$time / 365.25 fit2 < coxphw(Surv(years, status) ~ radiation + years : radiation, data = gastric, template = "PH") summary(fit2) # unweighted estimation with a function of time data("gastric") gastric$yrs < gastric$time / 365.25 fun < function(t) { (t > 1) * 1 } fit3 < coxphw(Surv(yrs, status) ~ radiation + fun(yrs):radiation, data = gastric, template = "PH") # for more examples see vignette or predict.coxphw