Learn R Programming

pammtools (version 0.8.1)

hazard_ci: Analytic hazard with confidence interval (coefficient models)

Description

Adds a hazard column and, for ci_type "default"/ "delta", se/ci_lower/ci_upper, using the linear-predictor triplet make_X/get_coefs/get_Vp. This is the analytic CI path (also used to evaluate reference hazard ratios and type = "link"). Simulation-based CIs instead use the get_hazard + sim_hazard primitives.

Usage

hazard_ci(
  object,
  newdata,
  reference = NULL,
  ci = TRUE,
  type = c("response", "link"),
  ci_type = c("default", "delta", "sim"),
  time_var = NULL,
  se_mult = 2,
  ...
)

Arguments

object

a fitted gam object as produced by gam().

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 newdata is provided then it should contain all the variables needed for prediction: a warning is generated if not. See details for use with link{linear.functional.terms}.

reference

A data frame with number of rows equal to nrow(newdata) or one, or a named list with (partial) covariate specifications. See examples.

ci

logical. Indicates if confidence intervals should be calculated. Defaults to TRUE.

type

Either "response" or "link". The former calculates hazard, the latter the log-hazard.

ci_type

The method by which standard errors/confidence intervals will be calculated. Default transforms the linear predictor at respective intervals. "delta" calculates CIs based on the standard error calculated by the Delta method. "sim" draws the property of interest from its posterior based on the normal distribution of the estimated coefficients. See here for details and empirical evaluation. For ci_type = "sim", interval bounds are empirical quantiles (type 6, see quantile) of nsim posterior draws (default nsim = 100L, passed via ...). Type-6 quantiles avoid the systematic inward bias that the quantile default (type 7) exhibits for small nsim, but at the default nsim = 100 the bounds are estimated from few tail draws and thus noisy; increase nsim (e.g., to 500 or more) for more stable interval bounds. Very small nsim (nsim < 2 / alpha - 1, i.e., below 39 for alpha = 0.05) cannot achieve the nominal level at all.

time_var

Name of the variable used for the baseline hazard. Defaults to "tend".

se_mult

Factor by which standard errors are multiplied for calculating the confidence intervals.

...

Further arguments passed to predict.gam and get_hazard