R/methods.R

Defines functions weights.coxph weights.survreg nobs.coxph nobs.survreg fitted.coxph fitted.survreg

#
# new generic methods sprout up regularly
# This is a convenient place to add them
#

# The AER package has a deviance function for tobit models, but I don't think
#  that deviance is a useful quantity there.
#
fitted.survreg <- function(object, ...)
  predict(object, type = "response", se.fit = FALSE)

fitted.coxph <- function(object, ...) object$linear.predictors

# The nobs result is intended for computing BIC; for coxph we think that
#  this is the number of events.
nobs.survreg <- function(object, ...)
  length(object$linear.predictors)
nobs.coxph <- function(object, ...) object$nevent

weights.survreg <- function(object, ...)
  model.weights(model.frame(object))

weights.coxph <- function(object, ...) {
    if (!is.null(object$weights)) object$weights
    else model.weights(model.frame(object))
}

Try the survival package in your browser

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

survival documentation built on Aug. 24, 2021, 5:06 p.m.