make_link_structure: Create Link Function Structure for BARMA Models

View source: R/make_link_structure.R

make_link_structureR Documentation

Description

A helper function that constructs a list containing the link function, its inverse, and the derivative of the mean function. It extends the standard 'make.link' by adding support for the "loglog" link.

Usage

make_link_structure(link = link)

Arguments

link

A character string specifying the name of the link function. Accepted values are '"logit"', '"probit"', '"cloglog"', and '"loglog"'.

Details

This function is primarily used internally by the 'barma()' function to process the 'link' argument. It standardizes the way link functions are handled within the model fitting process.

For the "logit", "probit", and "cloglog" links, the function acts as a wrapper around the base R 'make.link'.

For the "loglog" link, which is not available in 'make.link', the necessary components are defined explicitly:

  • Link function: g(\mu) = -\log(-\log(\mu))

  • Inverse link function: g^{-1}(\eta) = \exp(-\exp(-\eta))

  • Derivative \frac{d\mu}{d\eta}: \exp(-\exp(-\eta)) \times \exp(-\eta)

If an unsupported link is provided, the function will stop and return an error message listing the available options.

Value

A list with three components:

linkfun

The link function, which transforms the mean \mu \in (0,1) to the linear predictor \eta \in (-\infty, \infty).

linkinv

The inverse link function, which transforms the linear predictor \eta back to the mean \mu.

mu.eta

The derivative of the inverse link function with respect to \eta, i.e., \frac{d\mu}{d\eta}.

Author(s)

Original R code by: Fabio M. Bayer (Federal University of Santa Maria, <bayer@ufsm.br>) Modified and improved by: Everton da Costa (Federal University of Pernambuco, <everto.cost@gmail.com>)

See Also

barma, make.link

Examples

# --- Create a logit link structure ---
logit_link <- make_link_structure(link = "logit")

# Apply the link function
mu <- 0.5
eta <- logit_link$linkfun(mu)
print(eta) # Should be 0

# Apply the inverse link function
mu_restored <- logit_link$linkinv(eta)
print(mu_restored) # Should be 0.5

# --- Create a loglog link structure ---
loglog_link <- make_link_structure(link = "loglog")

# Apply the loglog link function
mu_loglog <- 0.8
eta_loglog <- loglog_link$linkfun(mu_loglog)
print(eta_loglog)

# Apply the inverse loglog link function
mu_restored_loglog <- loglog_link$linkinv(eta_loglog)
print(mu_restored_loglog) # Should be ~0.8


betaARMA documentation built on March 29, 2026, 5:08 p.m.