vcov.gkwfit: Extract Variance-Covariance Matrix from a gkwfit Object

vcov.gkwfitR Documentation

Extract Variance-Covariance Matrix from a gkwfit Object

Description

Extracts the variance-covariance matrix of the estimated parameters from a model fitted by gkwfit. This matrix is typically derived from the inverse of the observed Hessian matrix calculated during fitting (requires hessian = TRUE in the gkwfit call). This is an S3 method for the generic vcov function.

Usage

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

Arguments

object

An object of class "gkwfit", typically the result of a call to gkwfit.

...

Additional arguments (currently ignored).

Value

A numeric matrix representing the variance-covariance matrix of the estimated model parameters. Row and column names correspond to the parameter names (e.g., "alpha", "beta", etc.). Returns NULL or raises a warning/error if the matrix is not available (e.g., if hessian=FALSE was used or if the Hessian computation failed).

Author(s)

Lopes, J. E.

See Also

gkwfit, vcov, coef.gkwfit, logLik.gkwfit

Examples


# Generate data and fit model (ensure hessian = TRUE for vcov)
set.seed(2203)
y <- rbkw(50, alpha = 2, beta = 3, gamma = 1.5, delta = 0.5)
fit <- gkwfit(data = y, family = "bkw", plot = FALSE, hessian = TRUE)

# Extract variance-covariance matrix
vcov_matrix <- vcov(fit)
print(vcov_matrix)

# Extract standard errors from the diagonal
std_errors <- sqrt(diag(vcov_matrix))
print(std_errors)

# Compare with standard errors from summary
summary_se <- summary(fit)$coefficients[, "Std. Error"]
all.equal(std_errors, summary_se)



gkwreg documentation built on April 16, 2025, 1:10 a.m.