smoothpwc | R Documentation |
Utility to use a smooth function in markov_msm based on piece-wise constant values
smoothpwc(midts, rates, tmvar = "t", offsetvar = "", ...)
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 |
Uses splines to smooth the log-rates. This assumes that the rates are strictly greater than zero.
a function that is used in markov_msm
##---- 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")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.