Sep 27

## Nearest Neighbour Algorithm to forecast Stock Prices

Posted by abiao at 21:34 | Code » Matlab | Comments(0) | Reads(9037)
This is the algorithm involved on the use of the non-linear forecast of asset's prices based on the nearest neighbour method.

The basic idea of the NN algorithm is that the time series copies it's own past behavior, and such fact can be used for forecasting purposes. On the zip file there are two functions: one is the univariate version of NN (nn.m) and the other is the multivariate approach, also called simultaneous NN (snn.m).

The nearest neighbor method is defined as a non-parametric class of regression. Its main idea is that the series copies its own behavior along the time. In other words, past pieces of information on the series have symmetry with the last information available before the observation on t+1. Such way of capturing the pattern on the times series behavior is the main argument for the similarity between NN algorithm and the graphical part of technical analysis, charting.

The way the NN works is very different than the popular ARIMA model. The ARIMA modeling philosophy is to capture a statistical pattern between the locations of the observations in time. For the NN, such location is not important, since the objective of the
algorithm is to locate similar pieces of information, independently of their location in time. Behind all the mathematical formality, the main idea of the NN approach is to capture a nonlinear dynamic of self-similarity on the series, which is similar to the fractal dynamic of a chaotic time series.