- 1 Introduction
- 2 Auto
Regressive Moving-Average Models (ARMA)

- 3 Minimization of
Residuals of ARMA Models
- 1 Optimization of AR Parameters
- 2 Optimization of MA Parameters
- 3 Predicting "Next-Day" Rate
- 4 Evaluation of ARMA Prediction Errors

- 4 External Factors

- 5 Applying ARMA to External Factors
- 6 Auto
Regressive Models (AR-ABS)
- 1 Definitions
- 2 Definition of Residuals
- 3 Minimization of Residuals of AR-ABS Models
- 4 Applying AR-ABS to External Factors
- 5 Applying AR models to Linear Regression (LR)
- 6 Simplest Illustration of AR and AR-ABS Models

- 7 Artificial Neural Networks
Models (ANN)

- 8 Bilinear Models (BL)
- 9 Auto Regressive
Fractionally Integrated

Moving Average Models (ARFIMA)

- 10 Multi-Step Predictions
- 11 Structural Stabilization
- 1 Stabilization of Structures of Time Series
- 2 Simple Example
- 3 Examples of Structural Optimization with

External Factors

- 12 Examples of Squared Residuals Minimization

- 13 Software Examples
- 1 C Version of ARMA Software (ARMAC)
- 2 Java version of ARMA Software (ARMAJ)
- 3 AR-ABS Model
- 4 ANN Software

- 14 Stock Exchange Game Model

15 Exchange Rate Prediction,

Time Series Model

1 Introduction

Mainly, the financial data is predicted. The prediction of call rates, using the same models, are briefly mentioned, just for comparison. The call rate prediction is described in detail considering call center optimization problems in Chapter 16. There the traditional ARMA is supplemented by an expert model.

Modeling economic and financial time series by ARMA has attracted the attention of many researchers in recent years [Diebold and Rudebusch, 1989,Cheung, 1993,Yin-Wong and Lai., 1993,Cheung and Lai, 1993,Koop et al., 1994,Mockus and Soofi, 1995]. Three approaches have been used to estimate the parameters of the ARMA models, : Maximum Likelihood (ML) [Sowel, 1992], approximate ML [Li and McLeod, 1986,Fox and Taqqu, 1986,Hosking, 1981,Hosking, 1984], and two-step procedures [Geweke and Porter-Hudak, 1983,Janacek, 1982]. In all the cases local optimization techniques were applied. Here the optimization results depend on the initial values, what implies that one cannot be sure if the global maximum is found.

The
global optimization is very difficult in many cases^{}. The reason is a high
complexity of multi-modal optimization problems. It is well known
[Ko, 1991] that optimization of polynomial-time computable real functions cannot be done in
polynomial-time, unless ^{}. In practice, this means that we need an
algorithm of exponential time to obtain the -exact
solution. The number of operations in exponential algorithms
grows exponentially with the accuracy of solution and dimension
of the optimization problem. The accuracy means that
. The dimension means that one optimizes a function where
.

The Least Squares (LS) method is a popular approach to
estimate parameters of ARMA models.
Using LS one minimizes the log-sum of square residuals using ARMA models
and their extensions [Mockus and Soofi, 1995]. In this chapter, the
multi-modality problems are considered using different data. The
data include:

daily exchange rates of $/£ and DM/$ ,

closing rates of stocks of AT&T , Intel Co, and some Lithuanian
banks,

the London stock exchange index [Raudys and Mockus, 1999],

call-rates of a commercial call-center.

The graphical images
and comparison of the average prediction results of ARMA and
the Random Walk (RW) models are presented.

2 Auto Regressive Moving-Average Models (ARMA)

We assume that

Next the sum

is minimized. The logarithm is there to decrease the objective variation by improving the scales.

3 Minimization of Residuals of ARMA Models

The residual

or

Here

and

where and .

where and . From expressions (15.11) and (15.8) the minimum condition is

or

Here

and

The minimum of expression (15.11) at fixed parameters is defined by the system of linear equations

Here matrix . Vector , where elements are from (15.14), components are from (15.15), and is an inverse matrix . This way one define the vector that minimize sum (15.11) at fixed parameters .

Here and is from (15.11) at optimal parameter . Denote

3 Predicting "Next-Day" Rate

Here

where the optimal parameter was obtained using the data available at the day . Variance (15.20) is minimal, if

because the expectation of is under the assumptions.

- simplicity of RW,
- RW is a trivial case of ARMA where , , and ,
- RW represents unpredictable time series, because random numbers are independent.

$/ | - 1.779090e-01 | 1.293609e+00 | 8.454827e-02 |

DM/$ | - 1.191e-02 | 1.092e-01 | 9.985e-02 |

Yen/$ | - 1.086e+00 | 6.369e+00 | 6.446505e+00 |

Fr/$ | - 3.029e-01 | 4.285e-01 | 3.395e-01 |

AT&T | -1.375e+00 | 4.554e+00 | 3.621e+00 |

Intel Co | +2.814e-01 | 2.052e+01 | 1.936e+00 |

Hermis Bank | -4.280e+01 | 2.374e+01 | 1.998e+01 |

London Stock Exchange | -5.107e-01 | 2.751e+02 | 2.346e+01 |

Call Center | +3.076e+01 | 8.453e+02 | 7.111e+02 |

The table uses four data sets

- exchange rates of DM/$, $/, Yen/$, and Fr/$,
- closing rates of AT&T , Intel Co., and Hermis Bank stocks ,
- index of the London Stock Exchange,
- call rates of a call center.

in percentages. Here defines average errors of the Random Walk. means that the ARMA model predicts better.

The data is divided into three
equal parts.

The first part is to estimate parameters
and of an ARMA model using fixed numbers and
.

The best values of and are defined using the
second part of data.

The third part is to compare ARMA and RW
models. The table shows the comparison results.

Table 15.1 shows that the ARMA model predicts all the financial data not better than RW. However, ARMA predicts call rates thirty one percent better then RW. That is a statistically significant difference. The observed deviations between RW and ARMA models of financial data are too small for practical conclusions.

Figure 15.1 shows optimal parameters and . Here the optimal and . The "multi-day" predictions of call rates are shown in Figure 15.2.

4 External Factors

Different symbols are used in ARMA models with external factors. The predicted value is denoted by and the external factors are . An influence of some external factors may be delayed.

For illustration, consider two-dimensional case, omitting the Moving Average (MA) part. This means the two-dimensional Auto Regressive (AR) model with an external factor

Here is the delay parameter. First we minimize the squared deviation at fixed delay and then chose the optimal delay . The minimum of a sum (15.22), as a function of parameters , is defined by the system of linear equations. These are obtained from the condition that all the partial derivatives are zero

We have to solve linear equations with variables and obtain the least squares estimates at given .

Sum (15.25), as a function of delay parameter , is not necessarily uni-modal one. Thus to define the exact minimum

One should consider all the values of the integer . Here is the number of "interesting" values of . Therefore, expression (15.25) is an example of multi-modal function in AR models. We mentioned the delay time just to show a way how to include this important factor into a time series model. Later the delay factor is omitted, to simplify the expressions.

1 Missing Data

The least squares estimates of the regression parameters are obtained using observations before the missing one and minimizing expression (15.22). The same idea can be extended, if two or more values of the factor are missing.

This algorithm is to "fill" the missing data only for the predicted factor . We replace missing values of the external factor by the nearest previous value, because we do not predict the external factors in this model.

5 Applying ARMA to External Factors

Including this expression into the ARMA model (15.6) one obtains the following expression

Extending expression (15.28) to external factors

In expression (15.29), the predicted and the external factors are denoted by the same letter with different upper indices. All the factors are represented as one-dimensional time series of the special type

Here and the index . Using this expression one applies the software developed for the one-dimensional ARMA model to external factors. The data file should correspond to the expression (15.30).

6 Auto Regressive Models (AR-ABS)

We assume that

Next the sum

is minimized. This explains the acronym AR-ABS meaning that one minimizes a sum of absolute values of residuals.

3 Minimization of Residuals of AR-ABS Models

Here

, ,

, ,

. The advantage of AR-ABS is the lesser sensitivity to large deviations.

4 Applying AR-ABS to External Factors

Applying AR-ABS models to external factors is similar to that of ARMA models described in Section 5. One just omits the MA parameters . Then, from (15.29) one can write

In expression (15.39), the predicted and the external factors are denoted by the same letter with different upper indices. All the factors are represented as one-dimensional time series of the special type

Here and the index . Using this expression one applies the software developed for the one-dimensional AR-ABS model to external factors. The data file should correspond to the expression (15.40).

5 Applying AR models to Linear Regression (LR)

AR models with external factors can be applied to estimate Linear Regression parameters, too. The difference of LR models from those of AR is that in the former case denotes the test number. It is supposed that the observed values of the main parameter and external parameters at different tests and are independent. For example the diagnosis of some patient does not depend on the health of others patients . In such a case the "memory" and and expression (15.39) is modified this way

where defines the test number. Here the main and the external factors are denoted by the same letter with different upper indices where index means the main factor, for example a diagnosis, that is known for and should be predicted for . The external factors are supposed to be known for all Here numbers denote known cases, number denotes a new case, for example a new patient just arrived.

Let us to represent the multi-factorial LR model (15.41) by one-dimensional time series of the special type

where . Using this expression one applies the software developed for the one-dimensional AR model to factors of Linear Regression if data file corresponds to expression (15.42).

6 Simplest Illustration of AR and AR-ABS Models

then the least squares estimate is

and the ABS estimate is

Condition (15.44) provides the minimum of square deviations, condition (15.45) corresponds to the minimum of absolute deviations. In the case (15.45) one minimizes a piece-wise linear function with breaking points . Therefore optimum is obtained at the point that minimizes the sum of (15.45). In one-dimensional cases this can be done by comparing all values of . In general, minimization of (15.45) is performed by linear programming (15.35).

7 Artificial Neural Networks Models (ANN)

The idea lurking behind ANN-AR model is that the activation function roughly represents the activation of a real neuron. We minimize the sum

Here the objective depends on unknown parameters given as a -dimensional vector .

One see from expression (15.46) that
residuals are non-linear functions of parameters
^{}. This means that
the minimum conditions

is a system of non-linear equations with multiple solutions.

An interesting activation function is derived using the Gaussian distribution function

Here . is a scale parameter. The function (15.49) is different from the activation of a real neuron

In the traditional ANN models the activation functions are selected by their resemblance to the natural ones from biophysical experimentation. In this research the resemblance factor is neglected. The activation function (15.49) is considered just as a reasonable non-linearity that should be adapted to the available data. The multi-modality problems of ANN models are discussed in [Mockus et al., 1997].

8 Bilinear Models (BL)

An illustrative example is in [Mockus et al., 1997].

9 Auto Regressive Fractionally Integrated

Moving Average Models (ARFIMA)

1 Definitions

We define an ARFIMA^{} process as the following
time series ^{}

Here

and

where . We define the transformation as follows:

Here

where is a fractional integration parameter, and is a gamma function. We assume that

We truncate sequence (15.54)

Here is the truncation parameter, the number of non-zero components.

Next, the sum

is minimized.

The logarithm is used to decrease the objective variation by improving the scales. The objective depends on unknown parameters. They are represented as an -dimensional vector .

It follows from (15.59), (15.54), and (15.52) that residuals are linear functions of the parameters . This means that the minimum conditions

are given by a system of linear equations. They estimate linear parameters as a function of non-linear ones . It reduces the number of parameters of non-linear optimization to .

The system

may have a multiple solution, because the residuals depend on as polynomials of degree .

The equation

may have multiple solutions, too, because the residuals depend on as a polynomial of degree , where is a truncation parameter.

The objective is a
multi modal function of parameters and
^{}. Therefore, one uses methods of
global optimization (see, [Mockus et al., 1997]). Denote

Here

This means that condition (15.61) defines those - components that represent parameters .

There is no variance in expressions (15.64) and (15.59). If necessary, we have to estimate the variance by another well-known technique.

$/ | -1.195 | -0.169 | 0.0005 | 1.51675 |

DM/$ | -1.019 | 0.0120 | 0.0007 | 1.60065 |

AT&T | -1.017 | 0.0118 | 0.00005 | 9.83208 |

Intel Co | 0.9975 | 0.0055 | 0.012 | 7.35681 |

Table 15.2 shows that 's are very close to zero (see also Figures 15.3). An exception is Intel Co shares.

This apparent contradiction may be resolved by dropping the assumption that the parameters of the ARFIMA model remain constant. This assumption is common for most of the traditional methods. An alternative is the structural stabilization model described in Chapter 11.

10 Multi-Step Predictions

The
illustration is in Figure 15.2.
The line
shows the observed call rate. Lines

,
, and show the
minimal, the average, and the maximal results of MSP predictions.
The "min" and "max" lines denote the lower and the upper values
of simulation. Therefore, these lines are called "MSP-
confidence intervals," meaning that if the model is true, one
may expect those "intervals" to cover the real data with some
"MSP-confidence level" .

It is difficult to define exactly. If "interval deviations" may be considered as independent and uniformly distributed random variables, we obtain . Here is the number of Monte-Carlo repetitions. In the example, , thus .

This assumption over-simplifies the statistical model. Therefore, the "MSP-confidence level" is just a Monte Carlo approximation.

11 Structural Stabilization

The objective of traditional time series models is
to define such parameters that minimize a deviation from the
available data. One may call them as the best fit models. The
goodness of fit is described by continuous parameters called
as state variables. For example, in the ARMA model (see
expression (15.1)) the state variables are

.

If the parameters remain constant, then models that fit best to the past data will predict the future data as well. Otherwise, the best fit to the past data can be irrelevant or even harmful for predictions. Therefore, one needs models which are not sensitive to the changes of parameters. Such models may predict the uncertain future better by eliminating the nuisance parts from the structure of the model.

Trying to solve this problem, one introduces a notion of the model structure. The model structure is determined by the Boolean parameters called as structural variables. A structural variable is equal to unit, if the corresponding component of time series model is included. Otherwise, the structural variable is equal to zero.

For example, in the ARMA
model
. Here
, if the parameter is included into the ARMA model.
Otherwise, ^{}. We search for such structure of the model that
minimizes the prediction errors in the changing environment.
To achieve this we divide available data
into two parts
and
.

The first part is to estimate continuous parameters that depends on Boolean structural parameters . The estimates are obtained for a set of all feasible by minimizing the least square deviation using data .

The second part is used to select such that minimize the least square deviation. This means that the second part is to estimate Boolean structural parameters.

Denote by the predicted value of a model with fixed parameters using the data . The difference between the prediction and the actual data is denoted by . Denote by the fitting parameters which minimize the sum of squared deviations using the first data set at fixed structure parameters .

We stabilize the structure by minimizing the sum of squared deviations using the second data set and the fitting parameters that were obtained from the first data set

This is a way to reach a tradeoff between the fitting parameters and the structural ones. The fitting parameters provide the best fit to the first data set at fixed structure . One stabilizes the structure by minimizing the prediction errors for the second set of data using the fitting parameters . Here stabilization is achieved because the fitting parameters are defined by the first set of data . The stabilized structure of is obtained by eliminating unstable

We consider two data sets and just for simplicity. One may partition the data into many data subsets . In this case we minimize the sum

where

Here

Note, that dividing the data into many parts one may obtain sequences too short for the meaningful estimate of parameters , if is not large. If is large, one may expect that most of the fitting parameters would be different in different data subsets . Thus, they will be eliminated by the stabilization procedure (15.69). Therefore, seems a reasonable number, at the first stabilization attempt. One may try later.

The idea of the structural stabilization follows from the following observation. The best estimate of time series parameters, using a part of the data , is optimal for another part only if all the parameters remain the same. Otherwise, one may obtain a better estimate by elimination of the changing parameters from the model. For example, in the case of changing parameters of the ARMA model, the best prediction is obtained by elimination of all these parameters, except (see Table 15.1).

The observed values are . The first data set is to estimate continuous parameters . The second data set is to estimate Boolean parameters . Equality to zero suggests the elimination of the continuous parameter . There are three feasible , namely

Assume that unknown parameters depend on this way

In the case , the least square estimates are and . The prediction is .

If , the least squares estimate of the only remaining parameter is . The prediction is .

In the case , the least square estimate is and the prediction is .

The best prediction is provided by the structure . The reason is obvious: this structure eliminates the highly unstable parameter . Applying the structural stabilization one eliminates the nuisance parameter and simplifies AR model (15.72)

Note, that we eliminate the larger parameter ( ) because it changes (see expression (15.73)).

3 Examples of Structural Optimization with

External Factors

Various examples of structural optimization are described in [Mockus, 1997]. Here the structural optimization is considered in time series models with external factors.

If predictions depend on several factors, the multi-dimensional ARMA should be used. Denote by the main statistical component and by the external factors. One extends the traditional ARMA model this way

Here the number of the Auto Regressive (AR) components is denoted by and the number of the Moving Average (MA) ones is denoted by . The continuous variables and define the state of the ARMA model. We call them the state variables. The discrete parameters , , and define the structure. One calls them the structural variables. The structural variable defines the time when one starts scanning the time series for the optimization of state variables . Denote by the scanning end.

One minimizes the squared deviation at fixed structural variables

Here and is from expression (15.75). Denote the optimal values and .

If is fixed, the optimal values of are defined by a system of linear equations. These equations follows from the condition that all the partial derivatives of sum (15.75) are equal to zero . Therefore, to obtain the least squares estimates at given one solves linear equations with variables (see Chapter 3 for details).

To optimize discrete structural variables one uses another data set. It starts at and ends at . During optimization of structural variables one keeps the best fitting values of state variables and . These values are obtained by minimization of the sum . The data is from to . Here the sum

12 Examples of Squared Residuals Minimization

- exchange rates of $/, DM/$, yen/$, and franc/$,
- closing rates of stocks of AT&T, Intel Corporation, and
Hermis bank
^{}, - London stock exchange index,
- daily call rates of a call center.

Figures 15.4, 15.5, and
15.6 consider exchange rates of $/ and
DM/$.

Figures 15.7, 15.8, and
15.9 consider exchange rates of yen/$ and
franc/$.

Figures 15.10 reflect closing rates of AT&T (top) and Intel Co.(bottom) stocks.

Figures 15.13 , 15.14, and
15.15 consider the London stock exchange index.

Figures 15.16, 15.17, and
15.17 shows stock rates of the Hermis bank and
optimization results.

Figures 15.18 and
15.19 show the daily call rates of a call center
and illustrate optimization results.

To estimate unknown ARMA parameters we minimize a log-sum of squared residuals defined by expression (15.60). Estimates of parameters are from expression (15.13). In most of the cases, figures show the multi-modality of log-sum (15.60), as a function of parameters . Areas in vicinity of the global minima, often appear flat. A reason is that differences between values of the deviation function in an area around the global minimum are smaller as compared with these outside this area (see Figures 15.15).

The maximal number of Auto Regressive (AR) parameters was . Here , if no external factors are involved. The optimal number is defined by structural stabilization (see Chapter 11). Only two Moving Average (MA) parameters were considered while plotting surfaces and contours. The results of Table 15.1 were obtained by optimization of both structural variables and .

The objective of this part of research is to show a multi-modality arising in the prediction problem. Therefore, to save the computing time, the global optimization is carried out approximately, using not many iterations. The results of global optimization are starting points for local optimization. The reason is that the squared deviation as a function of parameters becomes uni-modal near the global minimum (see Figures 15.15). Therefore, the results are at least as good as those obtained by the traditional local optimization.

The high-accuracy global optimization is very expensive. In the global optimization, the computing time is an exponential function of accuracy , in the sense that . Therefore, the problem of future investigations is how to balance computing expenses and accuracy of estimates. This task is important in both the time series prediction and the global optimization.

The investigation of multi-modality of
squared deviation and variability of the parameters is the natural first step. The multi- modality is involved in
non-linear regression models, including the ARFIMA
ones^{}.

13 Software Examples

1 C Version of ARMA Software (ARMAC)

We consider a version of an extended ARMA model that includes external factors (see expressions 15.28 and 15.29). The programs are in the files 'main.C', 'fi.C', and 'fitimeb.h' on the web-site (see Section 4). The first version of ARMA software is designed for data sets with no future data. That means that no future factors are not known. Therefore, the external factors are treated as missing data. It is assumed that future values of external factors are equal to the last ones. In the ARMA software under development, this is considered as the default case. In the new software version, the known future values of external factors will replace the default ones.

The results of a simple test are in the files 'test.out' and 'test.progn.out'. The data is in the file 'test.data', the initiation file is 'test.ini'. The results of the call rate example are in the files 'call.out' and 'call.progn.out'. The data is in the file 'call.data'. The initiation file is 'call2.ini'. The names of the data files are referred as INP in the initiation file INIFILE. The software is compiled and run this way:

Compile by 'make onestep', Run by 'onestep > results.out'

#define RAND() drand48(),

defines the random number generator#define S 0 /* number of rows of matrix c */ #define S 0 /* number of rows of matrix c */

defines the bilinear component (see expression 15.50)#define K 5 /*number of "multi-step" repetitions*/,

K 5 means that the multi-step predictions is repeated 5 times (see Section 10 and Figure 15.23)#define W 0 /*W 0 means the one-step structural optimization, W 1 defines the multi-step one*/,

one-step structural optimization minimizes the average error of the "next day" predictions (see Section 11.3), multi-step one minimizes the average error of predictions for longer periods of time#define V 1 /*V 1 means with the multi-step prognoses, V 0 means without*/

the zero value of the indicator V switches off the multi-step prediction (see Section 10) and switches on the next day prediction (see Section 3.3 and Figure 15.23)#define F 1 /*indicator of variance, F 1 involves variance*/,

the unit value of the indicator F means that the variance of the errors is estimated and included into the multi-step prediction process#define EPS 0/*indicator of residual printing*/,

not used in this version#define INP 0 /*indicator of input display*/,

if INP 1 then the input values of the predicted factor are printed with their numbers (see Figure 15.24)#define SA 0 /*indicator of simulated annealing */

if SA 1 then optimization of the parameters p and q are performed using the simulated annealing method, otherwise the exhaustive search is used#define PL 0/*plotting dimension*/,

if PL 1 then the values of objective function depending on the parameter b[PLOT1] will be written in the file 'plot.out',

if PL 2 then the values of objective function depending on two parameters b[PLOT1] and b[PLOT2] will be written in the file 'plot.out' (see Figure 15.25) and plotted as Figures 15.17 using the "Gnuplot" system,

if PL 0 there will be no file 'plot.out'#define PLOT1 0 /*first plotting coordinate is b[PLOT1}*/ #define PLOT2 1/*second plotting coordinate is b[PLOT2}*/,

defines which components of vector-parameter b are considered#define A1 -1.5 /*lower bound of b[PLOT1}*/ #define B1 1.5/*upper bound of b[PLOT2}*/ #define A2 -1.5 /*lower bound of b[PLOT2}*/ #define B2 1.5/*upper bound of b[PLOT2}*/ #define DN 50 /*number of plotting steps*/

defines the range and the density of the plotting points#define ST 10000. /*temperature of simulated annealing */ #define SI 100 /*number of simulated annealing iterations*/

defines the parameters of simulated annealing method (if SA is applied)#define Ps M /*starting number of AR parameters*/ #define Qs 0 /*starting number of MA parameters*/ #define Pmin M /*minimal number of AR parameters*/ #define Qmin 0 /*minimal number of MA parameters*/ #define Pmax 2*M /*maximal number of AR parameters*/ #define Qmax 2 /*maximal number of MA parameters*/

defines the initial, the minimal and the maximal number of parameters p and q in the structural optimization#define T 120*M /* number of data entries in DATAFILE (divisible by M)*/,

defines the total number of entries in DATAFILE#define T0 T/3 /*T0<T number of entries for a and b optimization (divisible by M)*/ #define T1 2*T0 /*T1>=T0, number of entries for P and Q optimization(divisible by M)*/,

divides the DATAFILE (see Figures 15.26 and 15.16) into three parts: the first part for a,b optimization, the second part for p,q optimization, and the third part for testing the results**Figure 15.26:**A fragment of the ten recent days of the DATAFILE 'bank.data' including the date code and data of seven main Lithuanian commercial banks.#define TR -1*M /*TR <= T, TR/M is the number of the first line in DATAFILE used for simple regression (negative TR prints no regression)*/ #define TE 25*M/*TE>TR, TE/M is the number of the last line for regression*/,

is used only in the case when the ARMA model of time series prediction is reduced to the linear regression model of diagnosis.#define INIFILE "bank2.ini",

defines the input control file INIFILE (see Figure 15.27)#define M 2 /*number of factors*/,

defines the number of factors, including the predicted and the external ones#define LOCAL_METH EXKOR,

means that the EXKOR method is used for local optimization#define GLOBAL_METH BAYES1

means that the BAYES1 method is used for global optimization#define BAYES1_MAX_IT 5*M /* bayes1 IT */ #define BAYES1_LT 5 /* bayes1 LT */

means that 5*M iterations and 5 initial iterations of the BAYES1 method are used#define EXKOR_MAX_IT 6*M /* exkor IT */ #define EXKOR_INIT_POINTS 6 /* exkor LT */

means that 6*M iterations and 6 initial iterations of the EXKOR method are used

The test file is defined by 'test.ini':

INP test2 COL 1 COL 2Here INP defines the data file 'test2'

1. 1. 2. 1. 1. 1. 2. 1. 1. 1. 2. 1. 1. 1. 2. 1. 1. 1.Here COL 1 means that the first column of the file 'test2' should be considered as the factor to be predicted. COL 2 indicates the second column as an external factor.

A fragment of the optimization results is shown in the Figure 15.28.

'progn.out.old' (see Figure 15.29). The minimal , the average , and the maximal predicted values are equal. Therefore, the prediction variance is zero.

The applet 'index.html' is started by a browser, for example, by Netscape 4.6, or by the appropriate appletviewer. One clicks the button 'Show' (see the top Figure 15.30) to open the main window 'ARMA Frame' (see the bottom Figure 15.30). There are four buttons: 'File,' 'Input,' 'Options,' and 'Output' which open corresponding windows.

**File**- is for data input.

There are two fields: 'INI File' and 'Working directory or URL.'

There is the button 'Browse...' and two options:

'Local file' and 'Local URL.'The option 'Local file' activates the 'Browse...' button to select some local file.

The option 'Local URL' closes this button. Then the contents of fields 'INI File' and 'Working directory or URL' determine the data file.

The file name, for example, 'arma.ini,' is in the field 'INI File.'

The file 'arma.ini' controls the data input from the test file 'arma.test.' The directory is in the field 'Working directory or URL.'

If the 'Local URL' option is on, then the directory is, for example, this:http:/optimum.mii.lt/~jonas/armajavaj

The default URL is the applet directory. **Input**- is to change the default values of parameters (see the top Figures 15.31). The list of parameters is the same as in the C file 'fitimeb.h.'
**Options**- are to select options (see the top Figure 15.32):
**Output options**- defines the output file,
**None**- means no output,
**System output**- means console output,
**Frame**- defines output into separate windows,
**File**- outputs data into local files
^{} **Graphic options**- involves graphics.

**Output**- is for data output (see the bottom Figure 15.32):

one starts computations by clicking the button 'Calculate',

the message ' ARMA Frame: calculated' indicates the end.

acl.read=/home/jonas/public\_html/armajavaj/arma.ini acl.write=/home/jonas/public\_html/armajavaj/arma.outThat permits to read from 'arma.ini' and to write into 'arma.out.'

The file
is the 'jar' archive including all the 'class' files.

or are archives of 'java' files.

'index.html' is a starting applet.

'arma.ini' is the input control file.

'armatest' is the test data file.

The top Figure 15.30 shows the applet sign with the 'Show' button that starts ARMAJ. The bottom Figure 15.30 shows the initial window where the input file 'arma.ini' is defined. button that starts the ARMAJ.

Figures 15.31 show the list of default values of control parameters, similar to those in the ARMA C++ version. The upper part of the list is on the top figure, the middle part is on the bottom one.

The top Figure 15.32 shows the option window. The bottom Figure 15.32 shows the last fragment of the output window. Here the results, similar to those in the ARMA C++ version, are written.

The applet is started by a browser or by the appropriate appletviewer. First one clicks the label 'Model' (see the Figure 15.33) to select the data file, for example, the file 'armatest,

To select the parameters one clicks the label 'Inputs', see Figure 15.34).

The calculations are started by the label 'Count', Figure 15.35 shows the results.

4 ANN Software

The software is compiled and run this way:

Extract files by 'tar -zxf gmc.tgz' Rename the file 'fi.C.anngauss' by 'cp fi.C.anngauss fi.C' Compile by 'make', Run by './test'

It is easy to obtain daily stock rates for a long time. However, this information alone is not always useful while predicting the future stock rates [Mockus et al., 1997,Raudys and Mockus, 1999].

To improve predictions, one adds additional factors,
such as, relations of cash sales^{} to the sum of inventories and credit sales^{}.
However, these factors are available quarterly, as usual.
Therefore, it is difficult to unite them with the daily exchange
rates in the same model.

The aim of the Stock Rate Exchange Model is to explain the poor predictability of stock rates. Therefore, we start by considering the simplest case: a single stock-broker, major customers , and joint-stock companies ..

One assumes that the stock rates of a joint stock company at a time depend on
bying-selling strategies of
customers and some random factors .
At a time the customer orders a stock-broker to buy a number of shares^{} , if

Here is a buying threshold of the customer of the number of shares at the moment . At a time the customer orders a stock-broker to sell a number of shares, if

Here is a selling threshold of the customer of the number of shares at the moment .

The buying threshold is feasible if

Here is the buying capacity of the customer at the time . This is defined, for example, as the initial wealth plus the balance at the time

In this case, the stock rate of the share at a moment

Here

and

The buying and selling thresholds depend on the difference between the expected profit of share and that of certificate of deposit (CD) of the same value.

Here

where is the stock rate of the share predicted by the customer for the time .

Denote the fraction

where is the dividend expected for a share at the moment . Denote the relation

where is the yield of CD of value equal to at the time .

Now one defines the buying threshold

and the selling threshold

Here parameters and shows the risk aversion of the customer and approximately reflects a personal utility function. As usual, and .

The number of shares own by the customer at the time from (15.81) assuming the feasibility condition (15.80)

The profit of the customer during the interval

The profit depends on the accuracy of stock rate predictions and on random deviations .

Suppose, the customer predicts the stock rate of the share for the time using the Auto Regressive (AR) model:

Here the unknown parameters are defined by minimization of squared deviations at fixed number

where

This time series model, hopefully, represents some aspects of stock rates.

The time series generated by Monte Carlo model depend on parameters that are not defined by the model. To define these parameters, the "Nash Model" is used. The Nash Model searches for such numbers that satisfies the Nash equilibrium conditions. This means that no server can obtain higher expected profit by changing individually.

To ensure the existence of the Nash equilibrium one introduces mixed strategies. Here the mixed strategy is to select the integer at random with probabilities

That means that one choses by some lottery where is the probability to win the integer . The lottery is implemented by generating random numbers uniformly distributed in the zero-one interval. This interval is partitioned into parts proportional to .

To make sense of this randomization, one repeates the Monte Carlo simulation times. Denote the -th sample of the profit function obtained by the -th player using mixed strategies .

The average of all the samples:

Denote the "contract" vector by Define the "fraud" vector [Raudys and Mockus, 1999] as

Ones searches for the Nash equilibrium by minimizing the difference between the fraud and contract vectors

The optimization is carried out by methods of stochastic optimization. The convexity of profit functions is tested, if the minimum is greater than simulation errors [Raudys and Mockus, 1999].

To compare the predictions of real and simulated stock rates the well known ARMA model is used. The estimates of parameters of this model are obtained by stabilization procedure.

This Java1.1 software implements the stock excange model in the case , , and . That means two major players buying a single share at a time and one major joint stock company. The purpose of this simplest case is to obtain some starting data and show advantages and disadvantages of the model. This information helps developing more complicated mdels.

Figure 15.36 describes the simulation results in the case when both players are predicting by the Wiener model: .

The working hipothesis is that the behaviour of players based on the predictions obtained by the Wiener model provides the Nash equilibrium. Figure 15.37 describes the simulation results in the case when both players are predicting by the AR model: . One can see that the graphs are similar in both cases, the average deviations are close, too. Thus, there is no incentive for the players to change predictions based on the Wiener model. That means that the Wiener model can be regarded as a sort the equilibrium situation. One may conveniently investigate various examples directly by visiting the web-site: http://mockus.org/optimum and starting the corresponding Java applet (see the task "Stock Exchange Model" in the Section "Global Optimization")This conclusion is supported by the results of AR models and partly supported by the results of ARMA models [Mockus et al., 1997,Raudys and Mockus, 1999]. Using other models one may obtain different results. For example, the AR model predicts better if the relation is included as an external factor, where

Here denotes the cash income during a time period , means the contract price of the sold production during the same time, and is the list price of the unsold production during the time . There exists a positive correlation between the factors and .

jonas mockus 2004-03-20