Learn R Programming

riskRegression (version 1.4.3)

CoxLP: Compute the linear predictor of a Cox model

Description

Compute the linear predictor of a Cox model

Usage

CoxLP(object, data, center)

# S3 method for cph CoxLP(object, data, center)

# S3 method for coxph CoxLP(object, data, center)

# S3 method for phreg CoxLP(object, data, center)

Arguments

object

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

data

a data.frame or a data.table

center

should the linear predictor be computed after centering the covariates

Details

In case of empty linear predictor returns a vector of 0 with the same length as the number of rows of the dataset

Examples

Run this code
# NOT RUN {
d <- sampleData(1e2, outcome = "survival")
d$entry <- 0
d$id <- 1:NROW(d)

##
library(survival)
mCox <- coxph(Surv(time, event) ~ X1+X2, data = d)
CoxLP(mCox, data = d, center = FALSE)
CoxLP(mCox, data = d, center = TRUE)  

mCoxS <- coxph(Surv(time, event) ~ strata(X1)+X2, data = d)
CoxLP(mCoxS, data = d, center = FALSE) 

mCoxS2 <- coxph(Surv(time, event) ~ strata(X1)+strata(X2), data = d)
CoxLP(mCoxS2, data = d, center = FALSE) 

##
library(rms)
mCox <- cph(Surv(time, event) ~ X1+X2, data = d, y = TRUE)
CoxLP(mCox, data = d, center = FALSE) 
CoxLP(mCox, data = d, center = TRUE) 
CoxLP(mCox, data = NULL, center = FALSE) 
CoxLP(mCox, data = NULL, center = TRUE) 

mCoxS <- cph(Surv(time, event) ~ strat(X1)+X2, data = d)
CoxLP(mCoxS, data = d, center = FALSE) 

mCoxS2 <- cph(Surv(time, event) ~ strat(X1)+strat(X2), data = d, y = TRUE)
CoxLP(mCoxS2, data = d, center = FALSE) 

##
library(mets)
mCox <- phreg(Surv(entry, time, event) ~ X1+X2, data = d)
CoxLP(mCox, data = NULL, center = FALSE) 
CoxLP(mCox, data = d, center = TRUE) 

mCoxS <- phreg(Surv(entry, time, event) ~ strata(X1)+X2+cluster(id), data = d)
CoxLP(mCoxS, data = d, center = FALSE) 

mCoxS2 <- phreg(Surv(entry, time, event) ~ X1*X2, data = d)
CoxLP(mCoxS2, data = d, center = FALSE) 
# }

Run the code above in your browser using DataLab