GAfit {gmvarkit} | R Documentation |
Genetic algorithm for preliminary estimation of a GMVAR, StMVAR, or G-StMVAR model
Description
GAfit
estimates the specified GMVAR, StMVAR, or G-StMVAR model using a genetic algorithm.
It's designed to find starting values for gradient based methods.
Usage
GAfit(
data,
p,
M,
model = c("GMVAR", "StMVAR", "G-StMVAR"),
conditional = TRUE,
parametrization = c("intercept", "mean"),
constraints = NULL,
same_means = NULL,
weight_constraints = NULL,
structural_pars = NULL,
ngen = 200,
popsize,
smart_mu = min(100, ceiling(0.5 * ngen)),
initpop = NULL,
mu_scale,
mu_scale2,
omega_scale,
W_scale,
lambda_scale,
ar_scale = 0.2,
upper_ar_scale = 1,
ar_scale2 = 1,
regime_force_scale = 1,
red_criteria = c(0.05, 0.01),
pre_smart_mu_prob = 0,
to_return = c("alt_ind", "best_ind"),
minval,
seed = NULL
)
Arguments
data |
a matrix or class |
p |
a positive integer specifying the autoregressive order of the model. |
M |
|
model |
is "GMVAR", "StMVAR", or "G-StMVAR" model considered? In the G-StMVAR model, the first |
conditional |
a logical argument specifying whether the conditional or exact log-likelihood function |
parametrization |
|
constraints |
a size |
same_means |
Restrict the mean parameters of some regimes to be the same? Provide a list of numeric vectors
such that each numeric vector contains the regimes that should share the common mean parameters. For instance, if
|
weight_constraints |
a numeric vector of length |
structural_pars |
If
See Virolainen (forthcoming) for the conditions required to identify the shocks and for the B-matrix as well (it is |
ngen |
a positive integer specifying the number of generations to be ran through in the genetic algorithm. |
popsize |
a positive even integer specifying the population size in the genetic algorithm.
Default is |
smart_mu |
a positive integer specifying the generation after which the random mutations in the genetic algorithm are "smart". This means that mutating individuals will mostly mutate fairly close (or partially close) to the best fitting individual (which has the least regimes with time varying mixing weights practically at zero) so far. |
initpop |
a list of parameter vectors from which the initial population of the genetic algorithm will be generated from. The parameter vectors should be...
Above, In the GMVAR model, The notation is similar to the cited literature. |
mu_scale |
a size |
mu_scale2 |
a size |
omega_scale |
a size |
W_scale |
a size |
lambda_scale |
a length If the lambda parameters are constrained with the This argument is ignored if As with omega_scale and W_scale, this argument should be adjusted carefully if specified by hand. NOTE that if lambdas are constrained in some other way than restricting some of them to be identical, this parameter should be adjusted accordingly in order to the estimation succeed! |
ar_scale |
a positive real number between zero and one, adjusting how large AR parameter values are typically
proposed in construction of the initial population: larger value implies larger coefficients (in absolute value).
After construction of the initial population, a new scale is drawn from |
upper_ar_scale |
the upper bound for |
ar_scale2 |
a positive real number adjusting how large AR parameter values are typically proposed in some random mutations (if AR constraints are employed, in all random mutations): larger value implies smaller coefficients (in absolute value). Values larger than 1 can be used if the AR coefficients are expected to be very small. If set smaller than 1, be careful as it might lead to failure in the creation of stationary parameter candidates |
regime_force_scale |
a non-negative real number specifying how much should natural selection favor individuals
with less regimes that have almost all mixing weights (practically) at zero. Set to zero for no favoring or large
number for heavy favoring. Without any favoring the genetic algorithm gets more often stuck in an area of the
parameter space where some regimes are wasted, but with too much favouring the best genes might never mix into
the population and the algorithm might converge poorly. Default is |
red_criteria |
a length 2 numeric vector specifying the criteria that is used to determine whether a regime is
redundant (or "wasted") or not.
Any regime |
pre_smart_mu_prob |
A number in |
to_return |
should the genetic algorithm return the best fitting individual which has "positive enough" mixing
weights for as many regimes as possible ( |
minval |
a real number defining the minimum value of the log-likelihood function that will be considered.
Values smaller than this will be treated as they were |
seed |
a single value, interpreted as an integer, or NULL, that sets seed for the random number generator in the beginning of
the function call. If calling |
Details
The core of the genetic algorithm is mostly based on the description by Dorsey and Mayer (1995). It utilizes a slightly modified version of the individually adaptive crossover and mutation rates described by Patnaik and Srinivas (1994) and employs (50%) fitness inheritance discussed by Smith, Dike and Stegmann (1995).
By "redundant" or "wasted" regimes we mean regimes that have the time varying mixing weights practically at zero for almost all t. A model including redundant regimes would have about the same log-likelihood value without the redundant regimes and there is no purpose to have redundant regimes in a model.
Some of the AR coefficients are drawn with the algorithm by Ansley and Kohn (1986). However,
when using large ar_scale
with large p
or d
, numerical inaccuracies caused
by the imprecision of the float-point presentation may result in errors or nonstationary AR-matrices.
Using smaller ar_scale
facilitates the usage of larger p
or d
. Therefore, we bound
upper_ar_scale
from above by when
p*d>40
and by otherwise.
Value
Returns the estimated parameter vector which has the form described in initpop
.
References
Ansley C.F., Kohn R. 1986. A note on reparameterizing a vector autoregressive moving average model to enforce stationarity. Journal of statistical computation and simulation, 24:2, 99-106.
Dorsey R. E. and Mayer W. J. 1995. Genetic algorithms for estimation problems with multiple optima, nondifferentiability, and other irregular features. Journal of Business & Economic Statistics, 13, 53-66.
Kalliovirta L., Meitz M. and Saikkonen P. 2016. Gaussian mixture vector autoregression. Journal of Econometrics, 192, 485-498.
Patnaik L.M. and Srinivas M. 1994. Adaptive Probabilities of Crossover and Mutation in Genetic Algorithms. Transactions on Systems, Man and Cybernetics 24, 656-667.
Smith R.E., Dike B.A., Stegmann S.A. 1995. Fitness inheritance in genetic algorithms. Proceedings of the 1995 ACM Symposium on Applied Computing, 345-350.
Virolainen S. (forthcoming). A statistically identified structural vector autoregression with endogenously switching volatility regime. Journal of Business & Economic Statistics.
Virolainen S. 2022. Gaussian and Student's t mixture vector autoregressive model with application to the asymmetric effects of monetary policy shocks in the Euro area. Unpublished working paper, available as arXiv:2109.13648.
Examples
# Preliminary estimation of a G-StMVAR(1, 1, 1) model with 50 generations.
GA_estimates <- GAfit(gdpdef, p=1, M=c(1, 1), model="G-StMVAR",
ngen=50, seed=1)
GA_estimates