Title: | INGARCH and GLARMA Models for Count Time Series in Fable Framework |
---|---|
Description: | Provides a tidy R interface for count time series analysis. It includes implementation of the INGARCH (Integer Generalized Autoregressive Conditional Heteroskedasticity) model from the 'tscount' package and the GLARMA (Generalized Linear Autoregressive Moving Averages) model from the 'glarma' package. Additionally, it offers automated parameter selection algorithms based on the minimization of a penalized likelihood. |
Authors: | Gustavo Almeida [aut, cre] , Marcel Vieira [aut] , Conselho Nacional de Desenvolvimento Científico e Tecnológico - CNPq [fnd], JFSalvando Todos - Plataforma de Análises Estatísticas [fnd, cph] |
Maintainer: | Gustavo Almeida <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-12-02 06:37:56 UTC |
Source: | CRAN |
Extracts the fitted values.
## S3 method for class 'GLARMA' fitted(object, ...)
## S3 method for class 'GLARMA' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
tsibbledata::aus_production |> fabletools::model(manual_gla = GLARMA(Beer ~ pq(1,0))) |> dplyr::select(manual_gla) |> fitted()
tsibbledata::aus_production |> fabletools::model(manual_gla = GLARMA(Beer ~ pq(1,0))) |> dplyr::select(manual_gla) |> fitted()
Extracts the fitted values.
## S3 method for class 'INGARCH' fitted(object, ...)
## S3 method for class 'INGARCH' fitted(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted values.
tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1))) |> dplyr::select(manual_ing) |> fitted()
tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1))) |> dplyr::select(manual_ing) |> fitted()
Produces forecasts from a trained model.
## S3 method for class 'GLARMA' forecast(object, new_data, ...)
## S3 method for class 'GLARMA' forecast(object, new_data, ...)
object |
A model for which forecasts are required. |
new_data |
Tsibble, it has to contains the time points and exogenous regressors to produce forecasts for. |
... |
Other arguments passed to methods |
Predict future observations based on a fitted GLM-type model for time series of counts. Futher informations about the forecast method can be obtained typing ?glarma::forecast
A list of forecasts.
tsibbledata::aus_production |> fabletools::model(manual_gla = GLARMA(Beer ~ pq(1,0))) |> dplyr::select(manual_gla) |> fabletools::forecast(h = 2)
tsibbledata::aus_production |> fabletools::model(manual_gla = GLARMA(Beer ~ pq(1,0))) |> dplyr::select(manual_gla) |> fabletools::forecast(h = 2)
Produces forecasts from a trained model.
## S3 method for class 'INGARCH' forecast(object, new_data, ...)
## S3 method for class 'INGARCH' forecast(object, new_data, ...)
object |
A model for which forecasts are required. |
new_data |
Tsibble, it has to contains the time points and exogenous regressors to produce forecasts for. |
... |
Other arguments passed to methods |
Predict future observations based on a fitted GLM-type model for time series of counts. For 1 step ahead, it returns parametric forecast, based on the 'distr' param especified distribution, for multiples steps forecast, the distribution is not know analytically, so it uses a parametric bootstrap
A list of forecasts.
# 1 step ahead parametric forecast tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1) + PQ(1,1))) |> dplyr::select(manual_ing) |> fabletools::forecast(h = 1) # Multiples steap ahead parametric bootstrap forecast tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1) + PQ(1,1))) |> dplyr::select(manual_ing) |> fabletools::forecast(h = 4)
# 1 step ahead parametric forecast tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1) + PQ(1,1))) |> dplyr::select(manual_ing) |> fabletools::forecast(h = 1) # Multiples steap ahead parametric bootstrap forecast tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1) + PQ(1,1))) |> dplyr::select(manual_ing) |> fabletools::forecast(h = 4)
Construct a single row summary of the GLARMA model.
## S3 method for class 'GLARMA' glance(x, ...)
## S3 method for class 'GLARMA' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
A data frame with 1 row, with columns:
The unbiased variance of residuals. Calculated as 'sum(residuals^2) / (num_observations - num_pararameters + 1)'
The log-likelihood
Akaike information criterion
A one row tibble summarising the model's fit.
tsibbledata::aus_production |> fabletools::model(manual_ing = GLARMA(Beer ~ pq(1,1))) |> dplyr::select(manual_ing) |> glance()
tsibbledata::aus_production |> fabletools::model(manual_ing = GLARMA(Beer ~ pq(1,1))) |> dplyr::select(manual_ing) |> glance()
Construct a single row summary of the INGARCH model.
## S3 method for class 'INGARCH' glance(x, ...)
## S3 method for class 'INGARCH' glance(x, ...)
x |
model or other R object to convert to single-row data frame |
... |
other arguments passed to methods |
A data frame with 1 row, with columns:
The unbiased variance of residuals. Calculated as 'sum(residuals^2) / (num_observations - num_pararameters + 1)'
The log-likelihood
Akaike information criterion
Bayesian information criterion
A one row tibble summarising the model's fit.
tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1))) |> dplyr::select(manual_ing) |> glance()
tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1))) |> dplyr::select(manual_ing) |> glance()
Estimate Generalized Linear Autoregressive Moving Average model with Poisson or Negative Binomial distribution. Also is provide a automatic parameter algorithm selection for the Autorregressive and Moving Average params
GLARMA( formula, ic = c("aic", "bic"), distr = c("Poi", "NegBin"), method = c("FS", "NR"), residuals = c("Pearson", "Score"), trace = FALSE )
GLARMA( formula, ic = c("aic", "bic"), distr = c("Poi", "NegBin"), method = c("FS", "NR"), residuals = c("Pearson", "Score"), trace = FALSE )
formula |
Model specification (see "Specials" section). |
ic |
Character, can be 'AIC','BIC'. The information criterion used in selecting the model. |
distr |
Character, can be 'poisson' or 'nbinom'. The probabilty distribution used for the generalized model |
method |
Character, can be 'FS' (Fisher scoring) or 'NR' (Newton-Raphson). The method of iteration to be used |
residuals |
Character, can be 'Pearson' or 'Score'. The type of residuals to be used |
trace |
Logical. If the automatic parameter algorithm is runnig, print the path to the best model estimation |
A model specification.
pq defines the non-seasonal autoregressive and moving avarages terms, it can be define by the user, or if it's omited, the automatic parameter selection algorithm is trigered The automatic parameter selection algorithm gonna fit the best model based on the information criterion
PQ defines the seasonal autoregressive and moving avarages terms, it can be define by the user, or if it's omited, the automatic parameter selection algorithm is trigered (only for 'arma_to_GLARMA' algorithm) The automatic parameter selection algorithm gonna fit the best model based on the information criterion
Exogenous regressors can be included in an GLARMA model without explicitly using the 'xreg()' special. Common exogenous regressor specials as specified in ['common_xregs'] can also be used. These regressors are handled using [stats::model.frame()], and so interactions and other functionality behaves similarly to [stats::lm()].
The inclusion of a constant in the model follows the similar rules to ['stats::lm()'], where including '1' will add a constant and '0' or '-1' will remove the constant. If left out, the inclusion of a constant will be determined by minimising 'ic'.
If a xreg is provided, the model forecast is not avaliable
xreg(..., fixed = list())
`...` | Bare expressions for the exogenous regressors (such as `log(x)`) |
`fixed` | A named list of fixed parameters for coefficients. The names identify the coefficient, and should match the name of the regressor. For example, `fixed = list(constant = 20)`. |
# Manual GLARMA specification tsibbledata::aus_production |> fabletools::model(manual_gla = GLARMA(Beer ~ pq(1,0))) # Automatic GLARMA specification tsibbledata::aus_production |> fabletools::model(auto_gla = GLARMA(Beer, ic = 'aic'))
# Manual GLARMA specification tsibbledata::aus_production |> fabletools::model(manual_gla = GLARMA(Beer ~ pq(1,0))) # Automatic GLARMA specification tsibbledata::aus_production |> fabletools::model(auto_gla = GLARMA(Beer, ic = 'aic'))
Estimate Integer-valued Generalized Autoregressive Conditional Heteroscedasticity model with Poisson or Negative Binomial distribution. Also is provide a automatic parameter algorithm selection for the Autorregressive and Moving Avarege params
INGARCH( formula, ic = c("aic", "bic", "qic"), link = c("identity", "log"), distr = c("poisson", "nbinom"), algorithm = c("naive_search", "arma_to_ingarch"), trace = FALSE )
INGARCH( formula, ic = c("aic", "bic", "qic"), link = c("identity", "log"), distr = c("poisson", "nbinom"), algorithm = c("naive_search", "arma_to_ingarch"), trace = FALSE )
formula |
Model specification (see "Specials" section). |
ic |
Character, can be 'aic' 'bic' or 'qic'. The information criterion used in selecting the model. |
link |
Character, can be 'identity' or 'log' The link function used for the generalized model |
distr |
Character, can be 'poisson' or 'nbinom'. The probabilty distribution used for the generalized model |
algorithm |
Character, specifies the automatic parameter selection algorithm. Can be 'naive_search' or 'arma_to_ingarch'. If 'naive_search' is selected, a search in a 4x4 matrix parameter space is performed, where the model to minimize the criterion value is selected. If 'arma_to_ingarch' is selected, uses an auto_arma as the starting point for the selection algorithm. The ‘arma_to_ingarch’ is the only one to perform a seasonal adjustment |
trace |
Logical. If the automatic parameter algorithm is runnig, print the path to the best model estimation |
A model specification.
pq defines the non-seasonal autoregressive and moving avarages terms, it can be define by the user, or if it's omited, the automatic parameter selection algorithm is trigered The automatic parameter selection algorithm gonna fit the best model based on the information criterion
PQ defines the seasonal autoregressive and moving avarages terms, it can be define by the user, or if it's omited, the automatic parameter selection algorithm is trigered (only for 'arma_to_ingarch' algorithm) The automatic parameter selection algorithm gonna fit the best model based on the information criterion
Exogenous regressors can be included in a INGARCH model without explicitly using the 'xreg()' special. Common exogenous regressor specials as specified in ['common_xregs'] can also be used. These regressors are handled using [stats::model.frame()], and so interactions and other functionality behaves similarly to [stats::lm()].
The inclusion of a constant in the model follows the similar rules to ['stats::lm()'], where including '1' will add a constant and '0' or '-1' will remove the constant. If left out, the inclusion of a constant will be determined by minimising 'ic'.
If a xreg is provided, the model forecast is not avaliable
xreg(..., fixed = list())
`...` | Bare expressions for the exogenous regressors (such as `log(x)`) |
`fixed` | A named list of fixed parameters for coefficients. The names identify the coefficient, and should match the name of the regressor. For example, `fixed = list(constant = 20)`. |
# Manual INGARCH specification tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1))) # Automatic INGARCH specification tsibbledata::aus_production |> fabletools::model(auto_ing_naive = INGARCH(Beer, ic = 'aic', trace = TRUE, algorithm = 'naive_search'), auto_ing_arm_ing = INGARCH(Beer, ic = 'aic', trace = TRUE, algorithm = 'arma_to_ingarch'))
# Manual INGARCH specification tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1))) # Automatic INGARCH specification tsibbledata::aus_production |> fabletools::model(auto_ing_naive = INGARCH(Beer, ic = 'aic', trace = TRUE, algorithm = 'naive_search'), auto_ing_arm_ing = INGARCH(Beer, ic = 'aic', trace = TRUE, algorithm = 'arma_to_ingarch'))
Extracts the residuals.
## S3 method for class 'GLARMA' residuals(object, ...)
## S3 method for class 'GLARMA' residuals(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
tsibbledata::aus_production |> fabletools::model(manual_gla = GLARMA(Beer ~ pq(1,0))) |> dplyr::select(manual_gla) |> residuals()
tsibbledata::aus_production |> fabletools::model(manual_gla = GLARMA(Beer ~ pq(1,0))) |> dplyr::select(manual_gla) |> residuals()
Extracts the residuals.
## S3 method for class 'INGARCH' residuals(object, ...)
## S3 method for class 'INGARCH' residuals(object, ...)
object |
A model for which forecasts are required. |
... |
Other arguments passed to methods |
A vector of fitted residuals.
tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1) + PQ(1,1))) |> dplyr::select(manual_ing) |> residuals()
tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1) + PQ(1,1))) |> dplyr::select(manual_ing) |> residuals()
Returns the coefficients from the model in a 'tibble' format.
## S3 method for class 'GLARMA' tidy(x, ...)
## S3 method for class 'GLARMA' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a 'tibble'.
tsibbledata::aus_production |> fabletools::model(manual_gla = GLARMA(Beer ~ pq(1,0))) |> dplyr::select(manual_gla) |> fabletools::tidy()
tsibbledata::aus_production |> fabletools::model(manual_gla = GLARMA(Beer ~ pq(1,0))) |> dplyr::select(manual_gla) |> fabletools::tidy()
Returns the coefficients from the model in a 'tibble' format.
## S3 method for class 'INGARCH' tidy(x, ...)
## S3 method for class 'INGARCH' tidy(x, ...)
x |
An object to be converted into a tidy |
... |
Additional arguments to tidying method. |
The model's coefficients in a 'tibble'.
tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1))) |> dplyr::select(manual_ing) |> fabletools::tidy()
tsibbledata::aus_production |> fabletools::model(manual_ing = INGARCH(Beer ~ pq(1,1))) |> dplyr::select(manual_ing) |> fabletools::tidy()