get_hazard_1d {TwoTimeScales} | R Documentation |
Get estimated (log-)hazard values with 1 time scale
Description
get_hazard_1d()
takes as input the results of a model
estimated by fit1ts
and it returns the estimated values of the smooth log-hazard
and the smooth hazard together with their standard errors.
If the model includes covariates, then only the baseline (log-)hazard is returned. It is possible to provide values that define a new grid for evaluation of the estimated hazard. If not specified, the hazard is evaluated on the same grid used for the binning of the data, and therefore the estimation of the model. The function will check if the parameters for the new grid provided by the user are compatible with those originally used to construct the B-splines for estimating the model. If not, the grid will be adjusted accordingly and a warning will be returned.
Usage
get_hazard_1d(fitted_model, plot_grid = NULL)
Arguments
fitted_model |
is an object of class |
plot_grid |
(optional) A named vector containing the parameters to build a new
grid of intervals over |
Value
A list with the following elements:
-
new_plot_grid
A list of parameters that specify the new grid, of the form list("ints", "smin", "smax", "ds") -
hazard
A vector containing the estimated hazard values. -
loghazard
A vector containing the estimated log-hazard values. -
log10hazard
A vector containing the estimated log10-hazard values. -
SE_hazard
A vector containing the estimated SEs for the hazard. -
SE_loghazard
A vector containing the estimated SEs for the log-hazard. -
SE_log10hazard
A vector containing the estimated SEs for the log10-hazard.
Examples
## preparing data - no covariates
dt1ts <- prepare_data(
data = reccolon2ts,
s_in = "entrys",
s_out = "timesr",
events = "status",
ds = 180
)
## fitting the model with fit1ts() - default options
mod1 <- fit1ts(dt1ts)
# Obtain 1d hazard
get_hazard_1d(mod1)
# Change grid
get_hazard_1d(mod1,
plot_grid = c(smin = 0, smax = 2730, ds = 30)
)