gas {gasmodel}R Documentation

Estimate GAS Model

Description

A versatile function for estimation of generalized autoregressive score (GAS) models of Creal et al. (2013) and Harvey (2013). Model specification allows for various conditional distributions, different parametrizations, exogenous variables, higher score and autoregressive orders, custom and unconditional initial values of time-varying parameters, fixed and bounded values of coefficients, and NA values. Model estimation is performed by the maximum likelihood method and the Hessian matrix. The function can be supplied with any optimization and Hessian functions.

Usage

gas(y, x = NULL, distr, param = NULL, scaling = "unit",
  regress = "joint", p = 1L, q = 1L, par_static = NULL,
  par_link = NULL, par_init = NULL, lik_skip = 0L,
  coef_fix_value = NULL, coef_fix_other = NULL, coef_fix_special = NULL,
  coef_bound_lower = NULL, coef_bound_upper = NULL, coef_start = NULL,
  optim_function = wrapper_optim_nloptr, optim_arguments = list(opts =
  list(algorithm = "NLOPT_LN_NELDERMEAD", xtol_rel = 0, maxeval = 1e+06)),
  hessian_function = wrapper_hessian_stats, hessian_arguments = list(),
  print_progress = FALSE)

Arguments

y

A time series. For univariate time series, a numeric vector or a matrix with a single column. For multivariate times series, a numeric matrix with observations in rows.

x

Optional exogenous variables. For a single variable common for all time-varying parameters, a numeric vector. For multiple variables common for all time-varying parameters, a numeric matrix with observations in rows. For individual variables for each time-varying parameter, a list of numeric vectors or matrices in the above form. The number of observation must be equal to the number of observations of y.

distr

A conditional distribution. See distr() for available distributions.

param

A parametrization of the conditional distribution. If NULL, default parametrization is used. See distr() for available parametrizations.

scaling

A scaling function for the score. The supported scaling functions are the unit scaling (scaling = "unit"), the inverse of the Fisher information matrix scaling (scaling = "fisher_inv"), and the inverse square root of the Fisher information matrix scaling (scaling = "fisher_inv_sqrt"). The latter two scalings use the Fisher information for the time-varying parameters only. For the full Fisher information matrix for both time-varying and static parameters, there are the "full_fisher_inv" and "full_fisher_inv_sqrt" scalings. For the individual Fisher information for each parameter, there are the "diag_fisher_inv" and "diag_fisher_inv_sqrt" scalings. Note that when the parametrization is orthogonal (see distr()), there are no differences between these scaling variants.

regress

A specification of the regression and dynamic equation with regard to exogenous variables. The supported specifications are exogenous variables and dynamics within the same equation (regress = "joint") and separate equations for exogenous variables and dynamics in the fashion of regression models with dynamic errors (regress = "sep"). In a stationary model without exogenous variables, the two specifications are equivalent, although with differently parametrized intercept.

p

A score order. For order common for all parameters, a numeric vector of length 1. For individual order for each parameter, a numeric vector of length equal to the number of parameters. Defaults to 1L.

q

An autoregressive order. For order common for all parameters, a numeric vector of length 1. For individual order for each parameter, a numeric vector of length equal to the number of parameters. Defaults to 1L.

par_static

An optional logical vector indicating static parameters. Overrides x, p, and q.

par_link

An optional logical vector indicating whether the logarithmic/logistic link should be applied to restricted parameters in order to obtain unrestricted values. Defaults to applying the logarithmic/logistic link for time-varying parameters and keeping the original link for constant parameters.

par_init

An optional numeric vector of initial values of time-varying parameters. For NA values or when NULL, set initial values to unconditional values of time-varying parameters. For example, in the case of GAS(1,1) model with regress = "joint", to omega / (1 - phi1). Not to be confused with starting values for the optimization coef_start.

lik_skip

A numeric value specifying the number of skipped observations at the beginning of the time series or after NA values in the likelihood computation. Defaults to 0L, i.e. the full likelihood. If NULL, it is selected as max(p,q), i.e. the conditional likelihood.

coef_fix_value

An optional numeric vector of values to which coefficients are to be fixed. NA values represent coefficients to be estimated.

coef_fix_other

An optional square numeric matrix of multiples of the estimated coefficients, which are to be added to the fixed coefficients. This allows the fixed coefficients to be linear combinations of the estimated coefficients. A coefficient given by row is fixed on coefficient given by column. By this logic, all rows corresponding to the estimated coefficients should contain only NA values. Furthermore, all columns corresponding to the fixed coefficients should also contain only NA values.

coef_fix_special

An optional character vector of predefined structures of coef_fix_value and coef_fix_other. Useful mainly for multidimensional models. Value "panel_structure" forces all regression, autoregression, and score coefficients to be the same for all time-varying parameters within their group. Value "zero_sum_intercept" forces all constant parameters to sum up to zero within their group. Value "random_walk" forces all autoregressive coefficients to be equal to one (should be used with caution due to nonstationarity; par_init must be specified). Multiple predefined structures can be used together. Also can be used in combination with custom coef_fix_value and coef_fix_other.

coef_bound_lower

An optional numeric vector of lower bounds on coefficients.

coef_bound_upper

An optional numeric vector of upper bounds on coefficients.

coef_start

An optional numeric vector of starting values for the optimization. If not supplied, starting values are selected from a small grid of values.

optim_function

An optimization function. For suitable wrappers of common R optimization functions, see wrappers_optim. Can be set to NULL if the optimal solution should not be computed, which can be useful if the goal is only to evaluate the fit for the coefficients specified in argument coef_start.

optim_arguments

An optional list of arguments to be passed to the optimization function.

hessian_function

A Hessian function. For suitable wrappers of common R Hessian functions, see wrappers_hessian. Can be set to NULL if the Hessian matrix should not be computed, which can speed up computations when asymptotic inference is not desired.

hessian_arguments

An optional list of arguments to be passed to the Hessian function.

print_progress

A logical value indicating whether to progressively print a detailed report on computation.

Details

The generalized autoregressive score (GAS) models of Creal et al. (2013) and Harvey (2013), also known as dynamic conditional score (DCS) models or score-driven (SD) models, have established themselves as a useful modern framework for time series modeling.

The GAS models are observation-driven models allowing for any underlying probability distribution p(y_t|f_t) with any time-varying parameters f_t for time series y_t. They capture the dynamics of time-varying parameters using the autoregressive term and the lagged score, i.e. the gradient of the log-likelihood function. Exogenous variables can also be included. Specifically, time-varying parameters f_t follow the recursion

f_t = \omega + \sum_{i=1}^M \beta_i x_{ti} + \sum_{j=1}^P \alpha_j S(f_{t-j}) \nabla(y_{t-j}, f_{t-j}) + \sum_{k=1}^Q \varphi_k f_{t-k},

where \omega is the intercept, \beta_i are the regression parameters, \alpha_j are the score parameters, \varphi_k are the autoregressive parameters, x_{ti} are the exogenous variables, S(f_t) is a scaling function for the score, and \nabla(y_t, f_t) is the score given by

\nabla(y_t, f_t) = \frac{\partial \ln p(y_t | f_t)}{\partial f_t}.

In the case of a single time-varying parameter, \omega, \beta_i, \alpha_j, \varphi_k, x_{ti}, S(f_t), and \nabla(y_t, f_t) are all scalar. In the case of multiple time-varying parameters, x_{ti} are scalar, \omega, \beta_i, and \nabla(y_{t - j}, f_{t - j}) are vectors, \alpha_j and \varphi_k are diagonal matrices, and S(f_t) is a square matrix. Alternatively, a different model can be obtained by defining the recursion in the fashion of regression models with dynamic errors as

f_t = \omega + \sum_{i=1}^M \beta_i x_{ti} + e_{t}, \quad e_t = \sum_{j=1}^P \alpha_j S(f_{t-j}) \nabla(y_{t-j}, f_{t-j}) + \sum_{k=1}^Q \varphi_k e_{t-k}.

The GAS models can be straightforwardly estimated by the maximum likelihood method. For the asymptotic theory regarding the GAS models and maximum likelihood estimation, see Blasques et al. (2014), Blasques et al. (2018), and Blasques et al. (2022).

The use of the score for updating time-varying parameters is optimal in an information theoretic sense. For an investigation of the optimality properties of GAS models, see Blasques et al. (2015) and Blasques et al. (2021).

Generally, the GAS models perform quite well when compared to alternatives, including parameter-driven models. For a comparison of the GAS models to alternative models, see Koopman et al. (2016) and Blazsek and Licht (2020).

The GAS class includes many well-known econometric models, such as the generalized autoregressive conditional heteroskedasticity (GARCH) model of Bollerslev (1986), the autoregressive conditional duration (ACD) model of Engle and Russel (1998), and the Poisson count model of Davis et al. (2003). More recently, a variety of novel score-driven models has been proposed, such as the Beta-t-(E)GARCH model of Harvey and Chakravarty (2008), the discrete price changes model of Koopman et al. (2018), the circular model of Harvey (2019), the bivariate Poisson model of Koopman and Lit (2019), and the ranking model of Holý and Zouhar (2022). For an overview of various GAS models, see Harvey (2022).

The extensive GAS literature is listed on www.gasmodel.com.

Value

A list of S3 class gas with components:

data$y

The time series.

data$x

The exogenous variables.

model$distr

The conditional distribution.

model$param

The parametrization of the conditional distribution.

model$scaling

The scaling function.

model$regress

The specification of the regression and dynamic equation.

model$t

The length of the time series.

model$n

The dimension of the model.

model$m

The number of exogenous variables.

model$p

The score order.

model$q

The autoregressive order.

model$par_static

The static parameters.

model$par_link

The parameters with the logarithmic/logistic links.

model$par_init

The initial values of the time-varying parameters.

model$lik_skip

The number of skipped observations at the beginning of the time series or after NA values in the likelihood computation.

model$coef_fix_value

The values to which coefficients are fixed.

model$coef_fix_other

The multiples of the estimated coefficients, which are added to the fixed coefficients.

model$coef_fix_special

The predefined structures of coef_fix_value and coef_fix_other.

model$coef_bound_lower

The lower bounds on coefficients.

model$coef_bound_upper

The upper bounds on coefficients.

model$num_obs

The actual number of observations used in the likelihood.

model$num_coef

The actual number of estimated coefficients.

control$optim_function

The optimization function.

control$optim_arguments

The arguments which are passed to the optimization function.

control$hessian_function

The Hessian function.

control$hessian_arguments

The arguments which are passed to the Hessian function.

solution$status_start

The status of the starting values computation.

solution$theta_start

The computed starting values.

solution$status_optim

The status of the optimization computation.

solution$theta_optim

The computed optimal values.

solution$status_hessian

The status of the Hessian computation.

solution$theta_hessian

The computed Hessian.

fit$coef_est

The estimated coefficients.

fit$coef_vcov

The estimated variance-covariance matrix.

fit$coef_sd

The estimated standard deviations.

fit$coef_zstat

The statistics of the Z-test.

fit$coef_pval

The p-values of the Z-test.

fit$par_unc

The unconditional values of time-varying parameters.

fit$par_tv

The individual values of time-varying parameter.

fit$score_tv

The individual scores of time-varying parameters.

fit$mean_tv

The expected values given by the model.

fit$var_tv

The variances given by the model.

fit$resid_tv

The residuals of the model.

fit$loglik_tv

The log-likelihoods for the individual observations.

fit$loglik_sum

The overall log-likelihood.

fit$aic

The Akaike information criterion.

fit$bic

The Bayesian information criterion.

Note

Supported generic functions for S3 class gas include summary(), plot(), coef(), vcov(), fitted(), residuals(), logLik(), AIC(), BIC(), and confint().

References

Blasques, F., Gorgi, P., Koopman, S. J., and Wintenberger, O. (2018). Feasible Invertibility Conditions and Maximum Likelihood Estimation for Observation-Driven Models. Electronic Journal of Statistics, 12(1), 1019–1052. doi: 10.1214/18-ejs1416.

Blasques, F., Koopman, S. J., and Lucas, A. (2014). Stationarity and Ergodicity of Univariate Generalized Autoregressive Score Processes. Electronic Journal of Statistics, 8(1), 1088–1112. doi: 10.1214/14-ejs924.

Blasques, F., Koopman, S. J., and Lucas, A. (2015). Information-Theoretic Optimality of Observation-Driven Time Series Models for Continuous Responses. Biometrika, 102(2), 325–343. doi: 10.1093/biomet/asu076.

Blasques, F., Lucas, A., and van Vlodrop, A. C. (2021). Finite Sample Optimality of Score-Driven Volatility Models: Some Monte Carlo Evidence. Econometrics and Statistics, 19, 47–57. doi: 10.1016/j.ecosta.2020.03.010.

Blasques, F., van Brummelen, J., Koopman, S. J., and Lucas, A. (2022). Maximum Likelihood Estimation for Score-Driven Models. Journal of Econometrics, 227(2), 325–346. doi: 10.1016/j.jeconom.2021.06.003.

Blazsek, S. and Licht, A. (2020). Dynamic Conditional Score Models: A Review of Their Applications. Applied Economics, 52(11), 1181–1199. doi: 10.1080/00036846.2019.1659498.

Bollerslev, T. (1986). Generalized Autoregressive Conditional Heteroskedasticity. Journal of Econometrics, 31(3), 307–327. doi: 10.1016/0304-4076(86)90063-1.

Creal, D., Koopman, S. J., and Lucas, A. (2013). Generalized Autoregressive Score Models with Applications. Journal of Applied Econometrics, 28(5), 777–795. doi: 10.1002/jae.1279.

Davis, R. A., Dunsmuir, W. T. M., and Street, S. B. (2003). Observation-Driven Models for Poisson Counts. Biometrika, 90(4), 777–790. doi: 10.1093/biomet/90.4.777.

Engle, R. F. and Russell, J. R. (1998). Autoregressive Conditional Duration: A New Model for Irregularly Spaced Transaction Data. Econometrica, 66(5), 1127–1162. doi: 10.2307/2999632.

Harvey, A. C. (2013). Dynamic Models for Volatility and Heavy Tails: With Applications to Financial and Economic Time Series. Cambridge University Press. doi: 10.1017/cbo9781139540933.

Harvey, A. C. (2022). Score-Driven Time Series Models. Annual Review of Statistics and Its Application, 9(1), 321–342. doi: 10.1146/annurev-statistics-040120-021023.

Harvey, A. C. and Chakravarty, T. (2008). Beta-t-(E)GARCH. Cambridge Working Papers in Economics, CWPE 0840. doi: 10.17863/cam.5286.

Harvey, A., Hurn, S., and Thiele, S. (2019). Modeling Directional (Circular) Time Series. Cambridge Working Papers in Economics, CWPE 1971. doi: 10.17863/cam.43915.

Holý, V. and Zouhar, J. (2022). Modelling Time-Varying Rankings with Autoregressive and Score-Driven Dynamics. Journal of the Royal Statistical Society: Series C (Applied Statistics), 71(5). doi: 10.1111/rssc.12584.

Koopman, S. J. and Lit, R. (2019). Forecasting Football Match Results in National League Competitions Using Score-Driven Time Series Models. International Journal of Forecasting, 35(2), 797–809. doi: 10.1016/j.ijforecast.2018.10.011.

Koopman, S. J., Lit, R., Lucas, A., and Opschoor, A. (2018). Dynamic Discrete Copula Models for High-Frequency Stock Price Changes. Journal of Applied Econometrics, 33(7), 966–985. doi: 10.1002/jae.2645.

Koopman, S. J., Lucas, A., and Scharth, M. (2016). Predicting Time-Varying Parameters with Parameter-Driven and Observation-Driven Models. Review of Economics and Statistics, 98(1), 97–110. doi: 10.1162/rest_a_00533.

See Also

distr(), gas_bootstrap(), gas_filter(), gas_forecast(), gas_simulate(), wrappers_optim, wrappers_hessian

Examples

# Load the Daily Toilet Paper Sales dataset
data("toilet_paper_sales")
y <- toilet_paper_sales$quantity
x <- as.matrix(toilet_paper_sales[3:9])

# Estimate GAS model based on the negative binomial distribution
est_negbin <- gas(y = y, x = x, distr = "negbin", regress = "sep")
est_negbin

# Obtain the estimated coefficients
coef(est_negbin)

# Obtain the estimated variance-covariance matrix
vcov(est_negbin)

# Obtain the log-likelihood, AIC, and BIC
logLik(est_negbin)
AIC(est_negbin)
BIC(est_negbin)

# Obtain the confidence intervals of coefficients
confint(est_negbin)

# Plot the time-varying parameters
plot(est_negbin)


[Package gasmodel version 0.6.0 Index]