coxnet.deviance {cvwrapr}R Documentation

Compute deviance for Cox model

Description

Compute the deviance (-2 log partial likelihood) for Cox model. This is a pared down version of ‘glmnet'’s 'coxnet.deviance' with one big difference: here, 'pred' is on the scale of 'y' ('mu') while in 'glmnet', 'pred' is the linear predictor ('eta').

Usage

coxnet.deviance(pred = NULL, y, weights = NULL, std.weights = TRUE)

Arguments

pred

Fit vector or matrix. If 'NULL', it is set to all ones.

y

Survival response variable, must be a Surv or stratifySurv object.

weights

Observation weights (default is all equal to 1).

std.weights

If TRUE (default), observation weights are standardized to sum to 1.

Details

Computes the deviance for a single set of predictions, or for a matrix of predictions. Uses the Breslow approach to ties.

coxnet.deviance() is a wrapper: it calls the appropriate internal routine based on whether the response is right-censored data or (start, stop] survival data.

Value

A vector of deviances, one for each column of predictions.

Examples

set.seed(1)
eta <- rnorm(10)
time <- runif(10, min = 1, max = 10)
d <- ifelse(rnorm(10) > 0, 1, 0)
y <- survival::Surv(time, d)
coxnet.deviance(pred = exp(eta), y = y)

# if pred not provided, it is set to ones vector
coxnet.deviance(y = y)

# example with (start, stop] data
y2 <- survival::Surv(time, time + runif(10), d)
coxnet.deviance(pred = exp(eta), y = y2)


[Package cvwrapr version 1.0 Index]