NetLogo banner

 NetLogo Publications
 Contact Us

 Modeling Commons

 User Manuals:
 Farsi / Persian


NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled because this model uses external files.)


To use this model in its full form, please follow the link below:

This model implements a genetic-based classifier system to forecast stock returns. It was developed in Galimberti and da Silva (2012) in order to provide an empirical assessment on the use of computationally intensive algorithms as representative of agent’s process of inductive expectations formation. As such, it is not exactly a simulation model. Instead, it is an input-driven algorithm given that it requires a file with data on prices and other fundamental indicators in order to work.


The algorithm runs in a common cycle for every new point of data. The general processing cycle can be described by the following sequence (see Fig.1 in Galimberti and da Silva, 2012):
1 - The genetic algorithm is applied to the previous period set of forecasting rules.
1.1 - See Algorithm 1 in Galimberti and da Silva (2012) for details on the GA operation.
2 - The current state of the market is evaluated and the rules matching this state are activated.
3 - The forecasting equation associated to each active rule is evaluated to compute the rules return forecasts.
4 - The active rules are aggregated according to each of three possible predictors:
4.1 - Predictor 1: select the forecast from the rule with greater strength.
4.2 - Predictor 2: compute a simple arithmetic mean over rules forecasts.
4.3 - Predictor 3: compute a weighted average over rules forecasts, where the weights are given by the strength of each rule.
5 - The strength of the active rules is adjusted according to their performance.
6 - Merge the strength adjusted active rules to those that were inactive.

The forecasts of interest are those obtained from step 4, but these are recorded only after an initial learning phase has passed (see obs-learning in the Parameters Description below). By the end of the exercise, i.e., when all the data supplied has been processed, the model computes statistics on the 3 predictor’s forecasts. Namely, the Mean Squared Error of forecast, and the Standard Deviation of these squared errors are presented.
For more details about the functioning of the algorithm, please consult the paper.


- Basic Operation:
Press "setup" and choose the file with data, e.g., that used in the paper is available as "Petr4-Monthly-1987-2009.csv". Then press "go" and wait until it finishes processing the whole series of data, or release the "go" button by pressing it again to stop before the end of data. Alternatively, you can also run the algorithm period-by-period by pressing the "go-once" button.
For next runs, you don't need to reload the file with data again. Just press "re-ini" after setting the parameters, and follow the above procedure pressing "go" to start the algorithm execution.

- Advanced Operation:
You can use the BehaviorSpace tool of NetLogo to program the execution of the algorithm for different parameterizations. This may be useful for analysis. As an example, we supply one pre-specified experiment on varying the "tau" parameter value. Just go to "Tools->BehaviorSpace" on NetLogo main menu, and "Run" the experiment named "Varying Tau". Before running the many experiments, however, you need to press the setup button in order to first specify the data file to be used throughout the experiments. Also note that the Final Commands in BehaviorSpace are set to run the "genr-ag-forecasts-results" procedure, which generates a ";"-delimited .csv file with the forecasts (and its squared errors) resulting from the aggregation of each type of predictor.


- obs-learning: the number of observations used for the algorithm learning before start forecasting.
- n-predictors: the number of predictor to generate within each type of predictor.
- n-rules: the number of rules to hold in each predictor, i.e., the classifier system population.
- ga-rep: the maximum number of replications undergone by the genetic algorithm.
- k*%: minimum proportion of active rules required from the GA.
- tau: determines the horizon length considered while evaluating the forecasting performance of each rule, and the speed of adjustment of the forecasting rules.
- a-inf, a-sup, b-inf, b-sup: lower and upper bounds of the coefficients in the linear forecasting rules; a is the intercept, and b is the slope.
- conv-criteria: the number of generations of rules that are required to have provided the same signal of return forecast, until the GA is terminated.
- elitism-%: the max. percentage of rules that are directly replicated into the next generation of rules, before the GA adaptation takes place.
- fix-seed?, seed-val: if active, the random seed is set to the value in seed-val, so as to facilitate replicability.
- bit-1994?: indicates if the dummy bit for the 1994 structural in the Brazilian economy should be included.
- genr-forecasts-results: generates a .csv file containing the series of forecasts of each predictor within the three types.


Please see the analysis in Galimberti and da Silva (2012).


Simple Genetic Algorithm (in NetLogo Models Library\Computer Science)


- Galimberti, J. K. and S. da Silva, (2012) "An empirical case against the use of genetic-based learning classifier systems as forecasting devices", Economics Bulletin, Vol. 32 No. 1 pp. 354-369.
- Galimberti, J. K., (2010) "Previsibilidade dos retornos acionários: avaliando o desempenho de um sistema classificador com aprendizagem baseada em algoritmos genéticos", MSc. dissertation under supervision of S. da Silva, Federal University of Santa Catarina.


Programmer: Jaqueson K. Galimberti
Date of this revision: September 2012 (first version dates from May 2010)
NetLogo version: 5.0.2 (first revision was in NetLogo 4.0.4)

(back to the NetLogo User Community Models)