TABLE OF CONTENTS


simSurvival/bs.survfn [ Functions ]

NAME

    bs.survfn --- compute survivor function for B-spline hazard

FUNCTION

Given a B-spline baseline hazard, either compute the survivor function at a set of times, or at a single time.

SYNOPSIS

710 bs.survfn <- function(b, w, n, t = NULL)

INPUTS

   b       B-spline basis in the form of bs() output
   w       weights of each basis function
   n       number of intervals to use
   t       time at which to compute survival (whole function if NULL)

OUTPUTS

   If t = NULL, the survivor function at n times, else at time t.

SOURCE

713 {
714     rbound <- attr(b, "Boundary.knots")[2]
715     x <- seq(from = 0, to = rbound, length = n)
716     h <- (predict(b, x)%*%w)
717     if(is.null(t)){
718         H <- cumsum(h * rbound / n)
719         S <- exp(-H)
720         return(S)
721     }else{
722         Ht <- sum(h[x < t] * rbound / n)
723         St <- exp(-Ht)
724         return(St)
725     }
726 }