Monday 14 February 2011

Friday 8 October 2010

Book Review: R in a Nutshell


R in a Nutshell includes a quick introduction to the R statistical software; so if you are new to working with R you can catch up in a few pages. But it also is a full reference for the R programming language and a great variety of R packages which are available.

More in detail, it includes a description of the R syntax, objects, functions, saving and loading data, and graphics as well as more advanced topics like object-oriented programming and high-performance R. The packages that it presents deal with basic statistics, probability distributions, statistical tests, and power tests. The packages for regression models go further to nonlinear models, splines, smoothing as well as machine learning algorithms like neural networks, and support vector machines for regression. The classification models that the book describes include linear models as well as nearest neighbors, random forests and other algorithms. A chapter is devoted to time series analysis.

Finally a complete example is presented for a bioconductor application. I think that the book makes a good desktop quick reference. Of course it does not captures all subjects possible, for example solving ODEs with R is possible, but the variety of R packages are so great that in a book one has to concentrate on the most important parts.

Thursday 7 October 2010

Fibonacci retracement

Fibonacci numbers are the legendary sequence 0, 1, 1, 2, 3, 5, 8, 11, ... , named after Leonardo of Pisa, also known as Fibonacci, filius Bonacci, "son of Bonaccio". The sequence is given by the recursive formula:
F_n = F_{n-1} + F_{n-2},\!\,
with starting values:
F_0 = 0 \quad\text{and}\quad F_1 = 1.
As you can imagine Fibonacci numbers have also application in economics. Here is what wikipedia* says:

"In financial mathematics, Fibonacci retracements are a method of technical analysis. They are named after their use of the Fibonacci sequence. Fibonacci retracement levels are based on Fibonacci ratios.

Fibonacci retracement is based on the idea that markets will retrace a predictable portion of a move, after which they will continue to move in the original direction.

These pullbacks are often traded or used as an opportunity to position for the direction of the original move.

Fibonacci retracements occur at distinct levels of the original move. Each Fibonacci level is considered to be an area where the market will likely find levels of support or resistance.

The four basic Fibonacci retracement levels are calculated as 23.6%, 38.2% 50.0% and 61.8%, signifying the portion of the move in the opposite direction of the original move. 0.0% is considered to be the start of the retracement, while 100.0% is a complete reversal to the original part of the move."


But what about the tribonacci numbers? These are similar to the Fibonacci numbers but including three terms in the sum. Do they have an application in finance? And what about the generalization of this sequence?


* This content is available under the Creative Commons Attribution-ShareAlike License.

Wednesday 6 October 2010

Black-Scholes coupled system



In the previous post we have seen a simple example of the Black-Scholes equation, where a single option have been considered. What happens in the case where more than options have to be studied at the same time? Well, simple extend the model to many variablesas following:
The coefficients σ, μ and r are of course different between the two equations. However, one can simply raise the question what happens when a coupling of the two dependent variables takes place. At the beginning we can assume a simple linear coupling of the two prices which will then lead to the Black-Scholes system:
As we can see now both prices u1 and u2 appear in both equations. This means that we need some robust and at the same time flexible numerical method for the solution of the above system, which leads us of course to the finite element method.

The Black-Scholes equation


The Black-Scholes equation is a parabolic partial differential equation (PDE) for option prices discovered by Black and Scholes in 1973. This discovery revolutionized financial markets in 1990-s. In 1997 Merton and Scholes were awarded the Nobel prize in economics. For any stock price s,
and time t,
the price u for an option expiring at time T satisfies the following Black-Scholes PDE:
where σ(s,t) is the volatility coefficient,
and μ and r are respectively the risk neutral drift and risk free interest which are assumed to be constants.

Tuesday 14 September 2010

Tools of the trade

In order to analyze the financial data many commercial tools exist, that of course cost a lot of money. On the other hand there exists free software, or open source as it is often called, that can be downloaded for free and used without any fee. You would expect that this software is missing something but no; in the right hands it can become really powerful. To take a taste what you can find out there* I'll summarize here the major tools I am using:
  • octave: for general purpose numerical computations (an alternative is scilab)
  • R: for statistics specific calculations, includes clustering, machine learning, among the others
  • python: a powerful programming language that can be combined with many mathematical packages
  • perl: another programming language better suited for text processing (you don't want to do all the work by hand, right?)
  • maxima: symbolic mathematics software can be handy if the calculations become tough
  • ruby: this programming language is not really needed, but gives a fresh way of thinking
  • inkscape: a vector graphics tool for drawing flow diagrams (an alternative is dia)
All these programs can be downloaded from the links above for any platform, windows, mac os x, or linux.

You might be thinking "but I do not know all these stuff"; that's the purpose of this blog: to teach you something different.

*with out there I mean the internet.

Chaos economics?

What is meant by chaos economics? In most economics schools the economics that are taught are standard and classic. The mathematics involved are kept to the minimum in order to be everything well understood, and all problems to be solvable. However, in real life is not like this; this, at least, has shown many economical crisis over the last two centuries. So, we need something different?

One important part of modern economics is time series forecasting. The aim of time series forecasting is to predict how a given variable will evolve in the future knowing its past behavior. Time series forecasting was a hot subject of discussion from the beginnings of the human civilization, see fortune-telling, astrology, hand-reading, etc. Humans wanted and still want to know the future in advance.

The situation today has not changed a lot. There aren't any wizards, but there are still published thousands of papers and books about time series forecasting. Many software have been also designed to solve such hard problems. Techniques vary from statistical methods, to optimal control, to neural networks and many more.

The purpose of this blog is to present uncommon techniques that can be implemented with open source software. This means that 0€ must be paid in order to apply these methods, since all the software is freely downloadable from the internet. Some of the software I am going to use includes octave (or scilab), R, python, and others. All these programs will be used to study and forecast time series from stock markets and weather (cliche?), to client orders, or even number of
blog followers.

However, there is a warning. All these stuff wont predict the future for you. There is no crystal ball. The methods and techniques presented here are just to show you alternative ways of analysing your data.

But why chaos? Well, chaos theory, including also bifurcation theory and some of singularity theory, is something different. It deals with the non-linear character of the phenomena and how they behave at singularities.

Have fun!
Dimitris