Learn R Programming

mets (version 1.3.11)

phreg: Fast Cox Proportional Hazards Regression

Description

Fits a Cox proportional hazards model using a fast C++ backend. Robust variance (sandwich estimator) is the default variance estimate in the summary.

Usage

phreg(formula, data, offset = NULL, weights = NULL, ...)

Value

An object of class "phreg" containing:

coef

Vector of estimated coefficients.

var

Robust variance-covariance matrix.

beta.iid

Influence functions for the regression coefficients.

cumhaz

Matrix of cumulative hazard estimates (time, cumhaz).

se.cumhaz

Matrix of standard errors for the cumulative hazard.

cox.prep

List containing preprocessed data for the Cox model.

opt

Optimization results (if optimization was performed).

call

The matched call.

Arguments

formula

Formula with a 'Surv' or 'Event' outcome (similar to coxph).

data

Data frame containing the variables.

offset

Offsets for the Cox model linear predictor.

weights

Weights for the Cox score equations.

...

Additional arguments passed to lower-level functions (e.g., optimization controls).

Author

Klaus K. Holst, Thomas Scheike

Details

The influence functions (IID decomposition) follow the numerical order of the given cluster variable. Ordering the results by `$id` will align the IID terms with the original dataset order.

See Also

plot.phreg, predict.phreg, robust_phreg

Examples

Run this code
data(TRACE)
dcut(TRACE) <- ~.
# Fit model with clustering
out1 <- phreg(Surv(time, status == 9) ~ wmi + age + strata(vf, chf) + cluster(id), data = TRACE)
summary(out1)

# Plotting baselines
par(mfrow = c(1, 2))
plot(out1)

# Computing robust variance for baseline
rob1 <- robust_phreg(out1)
plot(rob1, se = TRUE, robust = TRUE)

# IID decomposition for regression parameters
head(iid(out1))

# IID decomposition for baseline at a specific time-point
Aiiid <- iid(out1, time = 30)
head(Aiiid)

# Combined IID decomposition (beta and baseline)
dd <- iidBaseline(out1, time = 30)
head(dd$beta.iid)
head(dd$base.iid)

# Stratified model
outs <- phreg(Surv(time, status == 9) ~ strata(vf, wmicat.4) + cluster(id), data = TRACE)
summary(outs)
par(mfrow = c(1, 2))
plot(outs)

Run the code above in your browser using DataLab