Learn R Programming

xhaz (version 2.1.0)

as.xhaz: Coerce a fitted object to have "xhaz" as first class

Description

Ensures S3 dispatch hits predict.xhaz() by putting "xhaz" first in the class vector.

Usage

as.xhaz(x)

Value

The same object with reordered classes.

Arguments

x

An object with class vector containing "xhaz" (and usually "mexhaz").

Examples

Run this code

# \donttest{
library(survival)
data("breast")
# The life table to be used is survexp.us. Note that SEX is coded 2 instead of female in survexp.us.
breast$sexe <- "female"

fit.haz <- exphaz(
                  formula = Surv(temps, statut) ~ 1,
                  data = breast, ratetable = survexp.us,
                  only_ehazard = FALSE,
                  rmap = list(age = 'age', sex = 'sexe', year = 'date'))

breast$expected <- fit.haz$ehazard

res <- mexhaz(formula = Surv(temps, statut) ~ agecr + armt,
    data = breast, degree = 3,
     knots=quantile(breast[breast$statut==1,]$temps, probs=c(1:2/3)),
     expected = "expected", base = "exp.bs", random = "hosp")
resLT <- as.xhaz(res)
# }

Run the code above in your browser using DataLab