| loglik_barma | R Documentation |
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
loglik_barma(
y,
ar,
ma,
alpha,
varphi,
theta,
phi,
link,
xreg = NULL,
beta = NULL
)
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., |
ma |
A numeric vector specifying the moving average (MA) lags
(e.g., |
alpha |
The intercept term (numeric scalar). |
varphi |
A numeric vector of autoregressive (AR) parameters.
Use |
theta |
A numeric vector of moving average (MA) parameters.
Use |
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:
|
xreg |
A matrix or data frame of static regressors (optional).
Must have the same number of rows as length of |
beta |
A numeric vector of regression coefficients for |
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.
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
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")}
barma for model fitting,
score_vector_barma for gradient computation,
fim_barma for Fisher Information Matrix
# 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"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.