-
Hello, I am wondering if |
Beta Was this translation helpful? Give feedback.
Answered by
pbreheny
Apr 20, 2023
Replies: 3 comments 2 replies
-
Sorry for disturbing, I am using the loss function structure provided by loss<- function(x,beta,y ,total=TRUE) {
eta = x%*%beta
ind <- order(y[,1])
d <- as.double(y[ind,2])
if (is.matrix(eta)) {
eta <- eta[ind, , drop=FALSE]
r <- apply(eta, 2, function(x) rev(cumsum(rev(exp(x)))))
} else {
eta <- eta[ind]
r <- rev(cumsum(rev(exp(eta))))
}
if (total) {
return(-2*(crossprod(d, eta) - crossprod(d, log(r))))
} else {
return(-2*(eta[d==1,] - log(r)[d==1,]))
}
} compare |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fit$loss
returns the loss only (negative of cox partial likelihood), not the penalty.The internal function
ncvreg:::loss.ncvsurv()
, as well as the modified version of it that you show above, assumes that the data has been ordered by survival time. In addition,loss.ncvsurv()
returns the deviance (2*loss).So: