View source: R/add-functions.R
add_hazard | R Documentation |
Add (cumulative) hazard based on the provided data set and model.
If ci=TRUE
confidence intervals (CI) are also added. Their width can
be controlled via the se_mult
argument. The method by which the
CI are calculated can be specified by ci_type
.
This is a wrapper around
predict.gam
. When reference
is specified, the
(log-)hazard ratio is calculated.
add_hazard(newdata, object, ...)
## Default S3 method:
add_hazard(
newdata,
object,
reference = NULL,
type = c("response", "link"),
ci = TRUE,
se_mult = 2,
ci_type = c("default", "delta", "sim"),
overwrite = FALSE,
time_var = NULL,
...
)
add_cumu_hazard(
newdata,
object,
ci = TRUE,
se_mult = 2,
overwrite = FALSE,
time_var = NULL,
interval_length = "intlen",
...
)
newdata |
A data frame or list containing the values of the model covariates at which predictions
are required. If this is not provided then predictions corresponding to the
original data are returned. If |
object |
a fitted |
... |
Further arguments passed to |
reference |
A data frame with number of rows equal to |
type |
Either |
ci |
|
se_mult |
Factor by which standard errors are multiplied for calculating the confidence intervals. |
ci_type |
The method by which standard errors/confidence intervals
will be calculated. Default transforms the linear predictor at
respective intervals. |
overwrite |
Should hazard columns be overwritten if already present in
the data set? Defaults to |
time_var |
Name of the variable used for the baseline hazard. If
not given, defaults to |
interval_length |
The variable in newdata containing the interval lengths.
Can be either bare unquoted variable name or character. Defaults to |
predict.gam
,
add_surv_prob
ped <- tumor[1:50,] %>% as_ped(Surv(days, status)~ age)
pam <- mgcv::gam(ped_status ~ s(tend)+age, data = ped, family=poisson(), offset=offset)
ped_info(ped) %>% add_hazard(pam, type="link")
ped_info(ped) %>% add_hazard(pam, type = "response")
ped_info(ped) %>% add_cumu_hazard(pam)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.