loglik_barma: Compute Conditional Log-Likelihood for Beta Autoregressive...

View source: R/loglik_barma.R

loglik_barmaR Documentation

Compute Conditional Log-Likelihood for Beta Autoregressive Moving Average Models

Description

Computes the conditional log-likelihood of a Beta Autoregressive Moving Average (BARMA) model. This function is designed for users who:

  • Implement custom optimization algorithms

  • Verify theoretical properties

  • Conduct simulation studies

  • Debug model fitting

  • Integrate BARMA models into their own workflows

Usage

loglik_barma(
  y,
  ar,
  ma,
  alpha,
  varphi,
  theta,
  phi,
  link,
  xreg = NULL,
  beta = NULL
)

Arguments

y

A numeric vector representing the time series data, with values strictly in (0, 1).

ar

A numeric vector specifying the autoregressive (AR) lags (e.g., c(1, 2)). Can be NA or NULL if no AR component.

ma

A numeric vector specifying the moving average (MA) lags (e.g., 1). Can be NA or NULL if no MA component.

alpha

The intercept term (numeric scalar).

varphi

A numeric vector of autoregressive (AR) parameters. Use numeric(0) or empty vector if no AR component. Length must match ar specification.

theta

A numeric vector of moving average (MA) parameters. Use numeric(0) or empty vector if no MA component. Length must match ma specification.

phi

The precision parameter of the BARMA model (must be positive and finite). Larger values indicate less variance for a given mean.

link

A character string specifying the link function: "logit" (default), "probit", or "cloglog".

xreg

A matrix or data frame of static regressors (optional). Must have the same number of rows as length of y.

beta

A numeric vector of regression coefficients for xreg (optional). Length must match number of columns in xreg.

Details

Log-Likelihood for BARMA Models

The log-likelihood is computed as:

\ell = \sum_{t=m+1}^{n} \log f(y_t | \mu_t, \phi)

where f is the Beta density with shape parameters shape1 = \mu_t * \phi and shape2 = (1-\mu_t)*\phi.

The linear predictor is constructed as:

\eta_t = \alpha + X_t \beta + \sum_{i=1}^{p} \varphi_i (y_{t-i} - X_{t-i}\beta) + \sum_{j=1}^{q} \theta_j \epsilon_{t-j}

**Important**: This function implements the corrections from the 2017 Erratum (Rocha & Cribari-Neto, 2017) for moving average components. See References section for details.

**Parameter Order**: Parameters should be supplied in the order: alpha, varphi (AR), theta (MA), phi, beta (regressors). This matches the parameter order used by barma.

Value

A numeric scalar representing the conditional log-likelihood value. Returns -Inf if:

  • phi is non-positive or non-finite

  • Insufficient observations for specified lag structure

  • Fitted values are outside (0, 1)

  • Any numerical issues occur

References

Rocha, A.V., & Cribari-Neto, F. (2009). Beta autoregressive moving average models. TEST, 18(3), 529-545. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s11749-008-0112-z")}

Rocha, A.V., & Cribari-Neto, F. (2017). Erratum to: Beta autoregressive moving average models. TEST, 26, 451-459. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s11749-017-0528-4")}

See Also

barma for model fitting, score_vector_barma for gradient computation, fim_barma for Fisher Information Matrix

Examples


  # Example 1: Log-likelihood for a BAR(1) model
  set.seed(2025)
  y_sim_bar <- simu_barma(
    n = 250,
    alpha = 0.0,
    varphi = 0.6,
    phi = 25.0,
    link = "logit",
    freq = 12
  )

  loglik_barma(
    y = y_sim_bar,
    ar = 1,
    ma = NA,
    alpha = 0.0,
    varphi = 0.6,
    theta = numeric(0),
    phi = 25.0,
    link = "logit"
  )

  # Example 2: Log-likelihood for a BARMA(1,1) model
  set.seed(2025)
  y_sim_barma <- simu_barma(
    n = 250,
    alpha = 0.0,
    varphi = 0.6,
    theta = 0.3,
    phi = 25.0,
    link = "logit",
    freq = 12
  )

  loglik_barma(
    y = y_sim_barma,
    ar = 1,
    ma = 1,
    alpha = 0.0,
    varphi = 0.6,
    theta = 0.3,
    phi = 25.0,
    link = "logit"
  )




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