Learn R Programming

riskRegression (version 1.3.7)

CoxVarCov: Extract the variance covariance matrix of the beta from a Cox model

Description

Extract the variance covariance matrix of the beta from a Cox model

Usage

CoxVarCov(object)

# S3 method for cph CoxVarCov(object)

# S3 method for coxph CoxVarCov(object)

# S3 method for phreg CoxVarCov(object)

Arguments

object

The fitted Cox regression model object either obtained with coxph (survival package), cph (rms package), or phreg (mets package).

Details

Should return NULL if the Cox model has no covariate. The rows and columns of the variance covariance matrix must be named with the names used in the design matrix.

Examples

Run this code

d <- sampleData(1e2, outcome = "survival")
d$entry <- 0

##
library(survival)
mCox <- coxph(Surv(time, event) ~ X1+X2, data = d)
CoxVarCov(mCox)
mCox <- coxph(Surv(time, event) ~ 1, data = d, y = TRUE)
CoxVarCov(mCox)

##
library(rms)
mCox <- cph(Surv(time, event) ~ X1+X2, data = d, y = TRUE)
CoxVarCov(mCox)
mCox <- cph(Surv(time, event) ~ 1, data = d, y = TRUE)
CoxVarCov(mCox)

##
library(mets)
mCox <- phreg(Surv(entry, time, event) ~ X1+X2, data = d)
CoxVarCov(mCox)
mCox <- cph(Surv(time, event) ~ 1, data = d, y = TRUE)
CoxVarCov(mCox)

Run the code above in your browser using DataLab