Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

coxsurv.fit

A direct interface to the ‘computational engine’ of survfit.coxph


Description

This program is mainly supplied to allow other packages to invoke the survfit.coxph function at a ‘data’ level rather than a ‘user’ level. It does no checks on the input data that is provided, which can lead to unexpected errors if that data is wrong.

Usage

coxsurv.fit(ctype, stype, se.fit, varmat, cluster, 
            y, x, wt, risk, position, strata, oldid,
            y2, x2, risk2, strata2, id2, unlist=TRUE)

Arguments

stype

survival curve computation: 1=direct, 2=exp(-cumulative hazard)

ctype

cumulative hazard computation: 1=Breslow, 2=Efron

se.fit

if TRUE, compute standard errors

varmat

the variance matrix of the coefficients

cluster

vector to control robust variance

y

the response variable used in the Cox model. (Missing values removed of course.)

x

covariate matrix used in the Cox model

wt

weight vector for the Cox model. If the model was unweighted use a vector of 1s.

risk

the risk score exp(X beta + offset) from the fitted Cox model.

position

optional argument controlling what is counted as 'censored'. Due to time dependent covariates, for instance, a subject might have start, stop times of (1,5)(5,30)(30,100). Times 5 and 30 are not 'real' censorings. Position is 1 for a real start, 2 for an actual end, 3 for both, 0 for neither.

strata

strata variable used in the Cox model. This will be a factor.

oldid

identifier for subjects with multiple rows in the original data.

y2, x2, risk2, strata2

variables for the hypothetical subjects, for which prediction is desired

id2

optional; if present and not NULL this should be a vector of identifiers of length nrow(x2). A non-null value signifies that x2 contains time dependent covariates, in which case this identifies which rows of x2 go with each subject.

unlist

if FALSE the result will be a list with one element for each strata. Otherwise the strata are “unpacked” into the form found in a survfit object.

Value

a list containing nearly all the components of a survfit object. All that is missing is to add the confidence intervals, the type of the original model's response (as in a coxph object), and the class.

Note

The source code for for both this function and survfit.coxph is written using noweb. For complete documentation see the inst/sourcecode.pdf file.

Author(s)

Terry Therneau

See Also


survival

Survival Analysis

v3.2-11
LGPL (>= 2)
Authors
Terry M Therneau [aut, cre], Thomas Lumley [ctb, trl] (original S->R port and R maintainer until 2009), Atkinson Elizabeth [ctb], Crowson Cynthia [ctb]
Initial release
2021-04-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.