Learn R Programming

lpl (version 0.13)

coxScoreHess: Calculate the Score vector / Hessian matrix for the Cox model

Description

Calculate the Score vector or the Hessian matrix for the Cox proportional hazards model with inputs of covariates, survival outcomes and the relative risks

Usage

coxScoreHess(X, y, exb, hess = FALSE)
    coxpl(X, y, beta, sorted = FALSE)

Value

An p by 1 vector of the score of the function calculated at the point relative exp(X*beta). If hess = TRUE, then a list with the following three components is returned:

score

a 1 x p score vector.

Sigma

a p x p matrix for the empirical varaince of the score.

H

a p x p hessian matrix.

Arguments

X

the covariate matrix from model.matrix, without the interecpt term.

y

y is a survival object, y = Surv(time, event).

exb

exb is the relative risks with exb = exp(X*beta).

hess

output the Hessian matrix, with hess = FALSE as the default, which outputs the score vector only.

beta

the p x 1 regression coefficient to be used in calculation of the partial likelihood.

sorted

data were sorted by time from the largest to the smallest, to speed up the algorithm, default is sorted = FALSE, sort by time is recommand when the function will be called multiple times for the same y.

Details

The survival time shall be sorted from the largest to the smallest, an error will occur if y is not sorted.

partial likelihood = sum(event(exp(X*beta)/S0))

score = sum(event*(X - S1/S0))

Sigma = sum(S1*t(S1))

H = sum(event*(S2/S0 - S1*t(S1)/S0))

the robust varaince can be calculated by inv(H)*Sigma*inv(H).

See Also

numHessian numScore multiRoot