R/predict.coxr.R

Defines functions predict.coxr

predict.coxr <- function(object, newdata, ...) {

    if ( !inherits(object, "coxr") ) {
        stop("use only with \"coxr\" objects")
    }
    
    beta = object$coef
    if ( length(object$skip) > 0 ) {
        beta[object$skip] = 0
    }

    if ( missing(newdata) ) {
        predictor <- as.vector(object$x %*% beta)
    } else {
        predictor <- as.vector(newdata %*% beta)
    }

    predictor

}

Try the coxrobust package in your browser

Any scripts or data that you put into this service are public.

coxrobust documentation built on April 6, 2022, 5:06 p.m.