Skip to contents

Returns the estimated variance-covariance matrix of the fitted coefficients.

Usage

# S3 method for class 'hazard'
vcov(object, ...)

Arguments

object

A hazard object.

...

Unused; for S3 compatibility.

Value

A numeric matrix containing the estimated variance-covariance matrix of the fitted coefficients, with rows and columns named by the coefficient labels (phase-prefixed for multiphase models, e.g. early.x). Rows and columns for parameters held fixed (e.g. fixed shape parameters) are NA because they carry no variance; the finite free-parameter block is still usable. For Conservation-of-Events fits the conserved phase log_mu normally carries a variance: it is removed from the optimizer search but the vcov is the full-information matrix at the optimum (the CoE solution is the unconstrained MLE). That recomputation needs a Hessian (analytic, or from numDeriv for left- or interval-censored rows) that can be inverted; if it fails the fit warns, records why in degraded_causes, and has no covariance matrix, so vcov() returns NA. For a Weibull fit whose scale mu, or its variance, cannot be represented, mu's row and column are NA, the reason is recorded in the fit's degraded_causes, and summary() shows the variance of log(mu) instead. Returns a scalar NA only when the model has not been fitted or no covariance matrix is available.

Examples

set.seed(1)
fit <- hazard(time = rexp(30, 0.5), status = rep(1L, 30),
              theta = c(0.3, 1.0), dist = "weibull", fit = TRUE)
vcov(fit)
#>              mu           nu
#> mu  0.005985736 -0.003822896
#> nu -0.003822896  0.023179654