smoothpwc {rstpm2} | R Documentation |
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 = "", ...)
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.
Value
a function that is used in markov_msm
Examples
##---- 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")
}
[Package rstpm2 version 1.6.3 Index]