GA | R Documentation |
Perform the modified genetic algorithm for changepoint detection. This involves the minimization of an objective function using a genetic algorithm (GA). The algorithm can be run sequentially or with explicit parallelization.
GA(
ObjFunc,
N,
GA_param = .default.GA_param,
GA_operators = .default.operators,
p.range = NULL,
...
)
ObjFunc |
The fitness function to be minimized. Users can specify any R or Rcpp
function as the fitness function, setting the input as the potential solution to
the optimization problem and returning a numerical value as the output/fitness.
Depending on the user-specified chromosome representation, the optimization task
can be changepoint detection only or changepoint detection plus model order selection,
which can be specified via the |
N |
The sample size of the time series. |
GA_param |
A list contains the hyper-parameters for genetic algorithm.
The default values for these hyper-parameters are included in |
GA_operators |
A list includes the functions for population initialization,
new individual selection, and genetic operator of crossover and mutation.
See |
p.range |
Default is |
... |
additional arguments that will be passed to the fitness function. |
Returns a list that has components:
overbestfit |
The obtained minimum value of the objective function after the final iteration. |
overbestchrom |
The locations of the detected changepoints associating
with the |
bestfit |
The minimized fitness function values at each iteration. |
bestchrom |
The detected changepoints at each iteration. |
count |
The number of iterations undertaken by the genetic algorithm. |
convg |
An integer code.
|
N = 1000
XMatT = matrix(1, nrow=N, ncol=1)
Xt = ts.sim(beta=0.5, XMat=XMatT, sigma=1, phi=0.5, theta=NULL,
Delta=c(2, -2), CpLoc=c(250, 750), seed=1234)
TsPlotCheck(X=1:N, Xat=seq(from=1, to=N, length=10), Y=Xt, tau=c(250, 750))
GA.res = GA(ObjFunc=BinSearch.BIC, N=N, Xt=Xt)
GA.res$overbestfit
GA.res$overbestchrom
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.