Description Usage Arguments Details Value References Examples
View source: R/geneticAlgorithm.R
GAfit
estimates the specified GMVAR, StMVAR, or GStMVAR model using a genetic algorithm.
It's designed to find starting values for gradient based methods.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  GAfit(
data,
p,
M,
model = c("GMVAR", "StMVAR", "GStMVAR"),
conditional = TRUE,
parametrization = c("intercept", "mean"),
constraints = NULL,
same_means = 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
)

data 
a matrix or class 
p 
a positive integer specifying the autoregressive order of the model. 
M 

model 
is "GMVAR", "StMVAR", or "GStMVAR" model considered? In the GStMVAR model, the first 
conditional 
a logical argument specifying whether the conditional or exact loglikelihood function 
parametrization 

constraints 
a size (Mpd^2 x q) constraint matrix C specifying general linear constraints
to the autoregressive parameters. We consider constraints of form
(φ_{1},...,φ_{M}) = C ψ,
where φ_{m} = (vec(A_{m,1}),...,vec(A_{m,p}) (pd^2 x 1), m=1,...,M,
contains the coefficient matrices and ψ (q x 1) contains the related parameters.
For example, to restrict the ARparameters to be the same for all regimes, set C=
[ 
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

structural_pars 
If
See Virolainen (2020) for the conditions required to identify the shocks and for the Bmatrix as well (it is W times a timevarying diagonal matrix with positive diagonal entries). 
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, φ_{m,0} is the intercept parameter, A_{m,i} denotes the ith coefficient matrix of the mth
mixture component, Ω_{m} denotes the error term covariance matrix of the m:th mixture component, and
α_{m} is the mixing weight parameter. The W and λ_{mi} are structural parameters replacing the
error term covariance matrices (see Virolainen, 2020). If M=1, α_{m} and λ_{mi} are dropped.
If In the GMVAR model, M1=M and ν is dropped from the parameter vector. In the StMVAR model, M1=0.
In the GStMVAR model, the first The notation is similar to the cited literature. 
mu_scale 
a size (dx1) vector defining means of the normal distributions from which each
mean parameter μ_{m} is drawn from in random mutations. Default is 
mu_scale2 
a size (dx1) strictly positive vector defining standard deviations of the normal
distributions from which each mean parameter μ_{m} is drawn from in random mutations.
Default is 
omega_scale 
a size (dx1) strictly positive vector specifying the scale and variability of the
random covariance matrices in random mutations. The covariance matrices are drawn from (scaled) Wishart
distribution. Expected values of the random covariance matrices are 
W_scale 
a size (dx1) strictly positive vector partly specifying the scale and variability of the
random covariance matrices in random mutations. The elements of the matrix W are drawn independently
from such normal distributions that the expectation of the main diagonal elements of the first
regime's error term covariance matrix Ω_1 = WW' is 
lambda_scale 
a length M  1 vector specifying the standard deviation of the mean zero normal
distribution from which the eigenvalue λ_{mi} parameters are drawn from in random mutations.
As the eigenvalues should always be positive, the absolute value is taken. The elements of If the lambda parameters are constrained with the (d(M  1) x r) constraint matrix C_lambda, then provide a length r vector specifying the standard deviation of the (absolute value of the) mean zero normal distribution each of the γ parameters are drawn from (the γ is a (r x 1) vector). The expected value of the main diagonal elements of the covariance matrices then depend on the constraints. This argument is ignored if M==1 or a reduced form model is considered. Default is 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 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 nonnegative 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 [0,1] giving a probability of a "smart mutation" occuring randomly in each
iteration before the iteration given by the argument 
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 loglikelihood 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 
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 loglikelihood value without the redundant regimes and there is no purpose to have redundant regimes in a model.
Returns the estimated parameter vector which has the form described in initpop
.
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, 99106.
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, 5366.
Kalliovirta L., Meitz M. and Saikkonen P. 2016. Gaussian mixture vector autoregression. Journal of Econometrics, 192, 485498.
Patnaik L.M. and Srinivas M. 1994. Adaptive Probabilities of Crossover and Mutation in Genetic Algorithms. Transactions on Systems, Man and Cybernetics 24, 656667.
Smith R.E., Dike B.A., Stegmann S.A. 1995. Fitness inheritance in genetic algorithms. Proceedings of the 1995 ACM Symposium on Applied Computing, 345350.
Virolainen S. 2020. Structural Gaussian mixture vector autoregressive model. Unpublished working paper, available as arXiv:2007.04713.
Virolainen S. 2021. Gaussian and Student's t mixture vector autoregressive model. Unpublished working paper, available as arXiv:2109.13648.
1 2 3 4 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.