confint.gkwfit: Compute Confidence Intervals for gkwfit Parameters

confint.gkwfitR Documentation

Compute Confidence Intervals for gkwfit Parameters

Description

Computes confidence intervals for one or more parameters in a model fitted by gkwfit. It uses the Wald method based on the estimated coefficients and their standard errors derived from the variance-covariance matrix.

Usage

## S3 method for class 'gkwfit'
confint(object, parm, level = 0.95, ...)

Arguments

object

An object of class "gkwfit", typically the result of a call to gkwfit. The object must contain valid coefficient estimates and a corresponding variance-covariance matrix (usually requires fitting with hessian = TRUE).

parm

A specification of which parameters are to be given confidence intervals, either a vector of numbers (indices) or a vector of names. If missing, confidence intervals are computed for all parameters that have a valid standard error available. Parameter indices refer to the order of parameters for which standard errors could be calculated.

level

The confidence level required (default: 0.95).

...

Additional arguments (currently ignored).

Details

This function calculates confidence intervals using the Wald method: Estimate \pm z \times SE, where z is the appropriate quantile from the standard normal distribution for the given confidence level.

It relies on the results from coef.gkwfit and vcov.gkwfit (or directly accesses object$coefficients and object$vcov if those methods aren't defined). It checks for the validity of the variance-covariance matrix before proceeding.

Since all parameters of the GKw family distributions are constrained to be positive, the lower bound of the confidence interval is truncated at a small positive value (.Machine$double.eps^0.5) if the calculated lower bound is non-positive.

If parm is specified, it selects the parameters for which to compute intervals. Numeric indices in parm refer to the parameters that have calculable standard errors, not necessarily all parameters in the model (if some were fixed or had estimation issues).

Value

A matrix with columns giving lower and upper confidence limits for each parameter specified in parm. The columns are labeled with quantile percentages (e.g., "2.5 %" and "97.5 %" for level = 0.95). Row names are taken from the parameter names. Returns NULL or stops with an error if coefficients or a valid variance-covariance matrix cannot be extracted.

Author(s)

Lopes, J. E.

See Also

gkwfit, confint, coef.gkwfit, vcov.gkwfit

Examples


# Generate data and fit model
set.seed(2203)
y <- rkw(50, alpha = 2, beta = 3)
fit <- gkwfit(data = y, family = "kw", plot = FALSE, hessian = TRUE)

# Calculate confidence intervals for all parameters
ci <- confint(fit)
print(ci)

# 90% confidence interval
ci_90 <- confint(fit, level = 0.90)
print(ci_90)

# Confidence interval for specific parameter
ci_alpha <- confint(fit, parm = "alpha")
print(ci_alpha)



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