negloglik: Calculate the negative log likelihood from Cox model.

Description Usage Arguments Author(s) References See Also Examples

View source: R/Rfunctions.R

Description

Calculate the negative log likelihood from Cox model from the estimated coefficient matrix theta.

Usage

1
negloglik(dat, theta)

Arguments

dat

A list that contains time, status and X. time is failure or censoring time, status is censoring indicator, and X is n x p matrix and may have p > n.

theta

An n x p matrix of coefficients corresponding to covariates X.

Author(s)

Jiacheng Wu

References

Jiacheng Wu & Daniela Witten (2019) Flexible and Interpretable Models for Survival Data, Journal of Computational and Graphical Statistics, DOI: 10.1080/10618600.2019.1592758

See Also

predict_best_lambda, tfCox_choose_lambda

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#generate training and testing data
dat = sim_dat(n=100, zerof=0, scenario=1)
test_dat = sim_dat(n=100, zerof=0, scenario=1)

#choose the optimal tuning parameter
cv = tfCox_choose_lambda(dat, test_dat, ord=0, alpha=1)
plot(cv$lam_seq, cv$loss)

#optimal tuning parameter
cv$best_lambda

#predict the coefficients of testing covariates from the optimal tuning parameter
#from tfCox_choose_lambda object. 
theta_hat = predict_best_lambda(cv, test_dat$X)

#calculate the loss in the testing data based on the estimated coefficients theta
negloglik(test_dat, theta_hat)

Example output

[1] 0.02995218
[1] 3.166083

tfCox documentation built on Aug. 1, 2019, 5:07 p.m.