File: methods.R

package info (click to toggle)
survival 3.8-6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,496 kB
  • sloc: ansic: 8,088; makefile: 77
file content (26 lines) | stat: -rw-r--r-- 816 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#
# 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))
}