intnobs (Input) The number of observations in the time series (y).
floaty[] (Input) An array of length nobs containing the time series.
int*npcs (Input/Output) The number of requested/estimated pieces or segments of the time series. npcs is considered input only when IMSLS_AR_MODEL is provided.
Return Value
A pointer to an array (arp) of length npcs × 2 containing the break points and AR orders for the derived model. If IMSLS_AR_MODEL is used, the return value is NULL.
IMSLS_AR_MODEL, intarp[] (Input) A user specified array of length npcs × 2 containing the break points and AR orders. When this argument is used, only the AR parameters and quality of the fit are determined.
Column Index
Description
0
Structural break points
1
AR order ( ) for each segment
IMSLS_PRINT, intprint (Input) Printing option.
print
Action
0
No printing
1
Prints final results only
2
Prints intermediate and final results
Default: print = 0.
IMSLS_RANDOM_SEED, intseed (Input) Seed of the random number generator. For the same data and parameter settings, imsls_f_auto_parm will return the same results each time if a seed is set. If seed = 0, the system clock will be used to generate a seed. The result will be nondeterministic.
Default: seed = 0.
Note: The following input arguments are for setting up and running the embedded Genetic Algorithm. In most situations, the default values should be used for these arguments. Users may wish to change some or all for testing or research purposes.
IMSLS_PROB_DISTRIBUTION, floatpdistn[] (Input) Array of length max_ar_order + 1 giving the probability distribution over the AR order variable p = 0,…, max_ar_order. i = 0,…, max_ar_order is used to randomly assign an AR order to breakpoint position for a given chromosome. pdistn[i] > = 0 and if Σpdistn is not equal to 1, the values will be normalized, i.e., pdistn[i] = pdistn[i]/ Σpdistn.
Default: pdistn[i] = 1/(max_ar_order + 1) for all i.
IMSLS_MIN_OBSERVATIONS, intmspan[] (Input) Array of length max_ar_order + 1 containing minimum number of observations required for valid estimates of AR model with order p = 0, …, max_ar_order.
IMSLS_GA_PARAMETERS, floatgaparm[] (Input) Array of length 4 containing parameters that control the behavior of the genetic algorithm. These values should be strictly greater than zero and less than one to avoid unexpected results.
Index
Behavior
0
Probability used to set initial break points in a chromosome. Default: min (mspan) / nobs.
1
Probability of crossover used to decide between a crossover and a mutation.
Default: 1 – min (mspan) / nobs.
2
In the mutation operation, probability an AR(p) model is enforced at the current position.
Default: 0.4.
3
In the mutation operation, probability a break point is disallowed at the current position.
Default: 0.3.
Note: gaparm[2] and gaparm[3] must be valid probabilities and their sum must be between 0 and 1. 1 – gaparm[2] – gaparm[3] is the probability that the chromosome j inherits the parent's chromosome j.
IMSLS_ISLAND, intisland[] (Input) Array of length 5 containing the migration policy parameters.
Index
Policy
0
Number of islands.
Default: 40.
1
Number of generations that pass before migration occurs. Note that the convergence of the algorithm is revised whether migrations take place or not (see argument island[4]).
Default: 5.
2
Number of subjects that migrate at each migration event.
Default: 2.
3
Population size (number of chromosomes) per island.
Default: 40.
4
Migration flag. If 1, migration is performed.
Default: 1.
IMSLS_MAX_MIGRATIONS, intmaxmig (Input) Maximum number of times that migrations may take place before the function is stopped if convergence has not occurred.
Default: maxmig = 20.
IMSLS_STOP_ITERATIONS, intstopiters (Input) Number of iterations. The function will declare convergence and stop the iterations if the criterion value (MDL/AIC) has not changed after stopiters consecutive migrations. Otherwise, the algorithm will declare non-convergence and stop after maxmig migrations have taken place. See also IMSLS_MAX_MIGRATIONS and island[1]. Note that logically, stopiters < maxmig.
Default: stopiters = 10.
IMSLS_SELECTION_CRITERION_VALUE, float*value (Output) Final value of the selection criterion.
IMSLS_AR_FIT, float**arfit (Output) Address of a pointer to an internally allocated array of length npcs × max_ar_order containing the AR coefficient estimates φ for each segment. arfit[i*max_ar_order+j] is the j‑th coefficient for segment i where i = 0, …, npcs- 1 and j = 0, …, arp[i×2 + 1].
Note that the intercept is not reported.
IMSLS_AR_FIT_USER, floatarfit[] (Output) Storage for array arfit is provided by the user. If npcs is output, the user should allocate (nobs‑ 1) × max_ar_order to assure sufficient space. See IMSLS_AR_FIT.
IMSLS_AR_STATS, float**arstat (Output) Address of a pointer to an internally allocated array of length npcs × 2.
Column Index
Description
0
Likelihood values for each of the fitted AR models
1
Residual variances for each of the fitted AR models
IMSLS_AR_STATS_USER, floatarstat[] (Output) Storage for array arstat is provided by the user. If npcs is output, the user should allocate (nobs‑ 1) × 2 to assure sufficient space. See IMSLS_AR_STATS.
Description
Function imsls_f_auto_parm estimates the structural breaks of a non-stationary time series using, with permission from the authors, the method developed by Davis et al (2006). imsls_f_auto_parm estimates a partition of the time index and models the time series in each segment as a separate auto-regressive (AR(p)) process. The function returns the estimated breakpoints, the estimated AR(p) models, and supporting statistics.
For the observed time series the problem is to find m, the number of breaks, their locations, , and , , the order of the AR process in which the j‑th segment is modeled. That is, for (for convenience, and ), where {Xt,j} is an AR process of order
and , the noise sequence, is independent and identically distributed with mean 0 and variance 1. Note that a series with m breaks will have m + 1 segments (m + 1 = npcs).
The vector completely specifies a piecewise AR model. To estimate this vector imsls_f_auto_parm optimizes, with respect to this vector, one of two selection criteria: the first is a Minimum Description Length (MDL) criterion, and the second is the Akaike's Information Criterion (AIC). The MDL is defined as
while the AIC criterion is given by
where, given a candidate value of the vector , is the likelihood of the fitted piecewise AR model evaluated at the parameter estimates,
The parameters of the j‑th AR segment are estimated by the choice of one of three estimation methods: Yule‑Walker, Burg, or Least Squares.
For simplicity, assume the mean of each series {Xt,j} is 0 and that the errors are Gaussian. Then, the piecewise AR model has Gaussian likelihood
where is the variance-covariance of the j‑th AR segment (of order ) and is the vector of observations of the j‑th segment, i.e., .
To find the minimizer of either MDL or AIC, imsls_f_auto_parm employs a Genetic Algorithm with islands, migration, cross-over and mutations. See Davis et.al. (2006) for further details.
Remarks
Function imsls_f_auto_parm approximates locally stationary time series by independent auto‑regressive processes. Experimental results suggest that imsls_f_auto_parm gives reasonable estimates of the structural breaks of a given time series, even if the segment series are not autoregressive. Also, based on experimental results, MDL gives better results than AIC as a selection criterion.
If seed is set out of range, an informational (error) message is issued indicating that the seed will be reset to 123457. Also if maxmig migrations are reached in the genetic algorithm before the selection criterion value converges an informational message is issued suggesting the increase of maxmig or the use of the double precision function.
Example
The examples below illustrate different scenarios using imsls_f_auto_parm. The example series used in each case is the airline demand data (Box, Jenkins and Reinsel, 1994), which gives monthly total demand for the period January 1949 through December 1960. Each scenario sets the optional argument, seed = 123457.
#include <imsls.h>
#include <stdio.h>
int main()
{
#define N 144
int n=N, npcs=0, iseed=123457, *arp=NULL, iper, iord, nlost;
int maxarorder, *arpnull=NULL, arp2[4]={0,2,59,1};
float x[N], *arfit=NULL, *arstat=NULL, sc, dx[N];
/* get data */
imsls_f_data_sets(4, IMSLS_RETURN_USER, x, 0);
/* Example 1: Use default values */
printf ("Example 1: Use defaults\n\n");
arp = imsls_f_auto_parm(n, x, &npcs,
IMSLS_PRINT, 1,
IMSLS_RANDOM_SEED, iseed,
IMSLS_SELECTION_CRITERION_VALUE, &sc,
IMSLS_AR_FIT, &arfit,
IMSLS_AR_STATS, &arstat,
0);
imsls_free(arp);
imsls_free(arfit);
imsls_free(arstat);
/* Example 2: differenced series set period for the difference.
“maxmig” migrations or “stopiters” iterations were reached in the genetic algorithm before the selection criterion value converged. Try increasing “maxmig”, “stopiters” or using the double precision routine.