Learn R Programming

rstpm2 (version 1.6.5)

smoothpwc: Utility to use a smooth function in markov_msm based on piece-wise constant values

Description

Utility to use a smooth function in markov_msm based on piece-wise constant values

Usage

smoothpwc(midts, rates, tmvar = "t", offsetvar = "", ...)

Value

a function that is used in markov_msm

Arguments

midts

mid-point values for time in each segment

rates

rates at those mid-points (or for the interval)

tmvar

string for the time variable

offsetvar

string for a time offset variable

...

other arguments

Details

Uses splines to smooth the log-rates. This assumes that the rates are strictly greater than zero.

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (midts, rates, tmvar = "t", offsetvar = "", ...) 
{
    log.smoother <- splinefunx(midts, log(rates), constant.right = TRUE)
    haz <- function(newdata) {
        t <- newdata[[tmvar]] + (if (offsetvar != "") 
            newdata[[offsetvar]]
        else 0)
        exp(log.smoother(t))
    }
    structure(list(haz = haz), class = "smoothpwc")
  }

Run the code above in your browser using DataLab