Do stock prices live in Mediocristan? An Apple case study 2: Levy alpha stable distribution

20Jul12

We continue the previous post here that analysed the distribution of the Apple stock price daily %changes. We concluded that the distribution (if it is a static distribution) cannot be Gaussian. What can the probability distribution be then?

There is a distribution called Levy distribution

http://en.wikipedia.org/wiki/L%C3%A9vy_distribution

which has 2 parameters and it is not really what we are looking for.

A generalization of it is the Levy alpha stable distribution:

http://en.wikipedia.org/wiki/Stable_distributions

(a quote from the wiki page that is relevant to our case

It was the seeming departure from normality along with the demand for a self-similar model for financial data that led Benoît Mandelbrot to propose that cotton prices follow an alpha-stable distribution with a equal to 1.7. Lévy distributions are frequently found in analysis of critical behavior and financial data (Voit 2003, § 5.4.3).

“)

The Levy alpha stable distribution has the following 4 parameters:

alpha = 1.5;    % characteristic exponent, and describes the tail of the distribution
beta = 0;       % skewness, asymmetry
gamma = 1;      % scale, c, (almost like variance),
delta = 0;      % location, (almost like a mean),

A good summary is here:

http://math.bu.edu/people/mveillet/html/alphastablepub.html

that shows that the Gaussian, Cauchy, simple Levy are all special case of the Levy alpha stable distribution.

Also, that link shows a package that in theory could be used to calculate the parameters from the samples, or calculate the PDF, CDF from the parameters. Unfortunately, that Matlab code is buggy, so we couldn’t use it to estimate the parameters.

However, we later used it to generate the PDF and CDF from the parameters.

Luckily, we found another software package that seems to work for generating the 4 parameters from the samples:

http://www.mathworks.com/matlabcentral/fileexchange/34783-estimation-of-alpha-stable-distribution-parameters-using-a-quantile-method

1.

Let’s see how to code it in Matlab:

1.1. Generating the parameters:

aMean = mean(pChanges);
stDev = std(pChanges);  % it uses the n-1 as a denominator
params=alpha_loglik(pChanges);
disp(sprintf('The optimizing value of alpha is: %d',params.alph));
disp(sprintf('The optimizing value of beta is:  %d',params.bet));
disp(sprintf('The optimizing value of gamma is: %d',params.gamm));
disp(sprintf('The optimizing value of delta is: %d',params.delt));

1.2 Plotting the PDF:


x=-0.59:0.01:0.39;
yGauss=gaussmf(x,[stDev aMean]);
plotGauss = plot(x,min(yGauss, 5.2));
set(plotGauss,'Color','green','LineWidth',2)
yAlphaLevy=stblpdf(x,params.alph,params.bet,params.gamm,params.delt,1e-12);
plotLevy = plot(x , min(5.2, yAlphaLevy ./ max(yAlphaLevy)));        % normalize maximum to 1
set(plotLevy,'Color','red','LineWidth',2)
xlabel('Gaussian vs. Alpha Stable Levy'

1.3 Calculating the CDF:


cdfGauss = normcdf(x,aMean,stDev);
cdfLevy = stblcdf(x,params.alph,params.bet,params.gamm,params.delt,1e-12);

2.

There is a question that what are the synthetized parameters of the Levy alpha stable distribution for AAPL daily %change? Here they are:

params =
alph: 1.6228 % characteristic exponent, and describes the tail of the distribution
bet: 0.20171 % skewness, asymmetry
gamm: 0.016158 % scale, c, (almost like variance)
delt: 0.0015028  % location, (almost like a mean),

Alpha is 1.62. So it has a long tail. It is comparable to the cotton price alpha of 1.7 that was calculated by Mandelbrot.

Beta is 0.2, there is some positive skew, asymmetry. No wonder, since Apple stock prices trended up mostly, and in general as the stock market is trending up, there are more Up days than down days.

The Delta is 0.0015, that is not exactly like an arithmetic mean, but you can interpret it that the daily %change is about +0.15% (a positive number). Again! It is not a mean! Alpha stable distributions hasn’t got a concept of mean; The mean is not determined, because the mean is not stable. Just remember that the Cauchy distribution has infinite variance, and therefore undetermined mean. (We can talk about the median though)

3.

Let’s see visually how the Levy alpha stable distribution fits to the real life samples. So, plot the PDF of the samples (blue bars), the Gaussian (green line) and the Levy alpha stable (red).

It is amazing how nicely the Levy version fits the samples. In contrast the Gaussian estimation looks clumsy.

It seems that in the center part of the plot, the Levy is under the Gaussian, however, we know that at the tails, the Levy should be above the Gaussian, since Levy correctly estimates the ‘fat tails’ of the distribution. So, let’s zoom to 0-0.2 range to see when the two distributions cross each other.

4.

As an illustration what is the difference of probabilities at the tail, when using Levy vs. Gaussian.

For example, let’s go back to the day, when AAPL dropped -52% on a single day.

The PDF at -0.52 is:

Gaussian: 1E-60

Levy: 0.0016 = 1.6E-3

That is much of a difference.

Note, it is the PDF! (not the CDF), so don’t use it for calculating chances. It only illustrates the difference of the two. And that the Gaussian PDF is so small, that no integration of those small values can result a significant probability (CDF) at that level.

5.

We have to confess that in the previous post, we used the PDF for probabilities calculation. That was wrong, but after recalculating those numbers, the main message is still the same. We partially amend that in this post. Now, we correctly use the CDF for probability calculation.

  • p(-10% drop)=
    Gauss: 0.04%, every 2500 trading days, every 10 years
    Levy: 0.7%  // (every 140 trading days; about 2 times per year); yes; fundamentally, it is possible, because there are 4 earnings dates per year
  • p(-20% drop)=
    Gauss:1.3e-11, about once in every 1e+11 days.
    As Earth is 10^12 days old, it can happen 10 times in the lifetime of the Earth.
    Levy: 0.02%  // every 500 trading days: every 2 years
  • p(-52% drop)=
    Gauss: 5.6e-67, more than the lifetime of the known Universe
    Levy: 0.045%: every 2200 trading days; every 9 years
  • p(+33% gain)=
    Gauss: 1.07e-26; about once in every 1e+26 days.
    Levy: 0.15%, every 666 trading days, every 3 years;  Maybe that is an exaggeration.

We let the reader decide which mathematical model (Gaussian or alpha stable Levy) fits the real life data better.

Just for curiosity, according to Levy, every day

– there is 0.74% chance of a -10% drop

– there is 1.1% chance of a 10% gain   (strange asymmetry); One expect the chance of the same percent gain to be less, because drops are more violent;

That is true, but in general AAPL trended up, therefore the whole distribution skewed to the right: more samples show gains than losses; that is the reason;

Obviously, if a stock goes up a little in every 99 out of 100 days, the distribution is skewed to the right.

About the same thing, but in another words:

On every single day:

– there is 1% chance of a -8.5% drop

– there is 1% chance of a 11% gain                            // there are more gains than drops

(1% chance: realistically happen every 100 trading days = 5 months)

It means that any Good Risk Management strategy should consider that

– a -10% drop can occur twice per year (Gaussians thinks it happens every 10 years),

– and a 20% drop can occur every 2 years. (Gaussians thinks it is impossible)

Conclusion

This post is tries to be a similar eye opening material in AAPL price changes as Mandelbrot’s book ‘The (Mis)Behaviour of Markets’ in many real life events.

http://www.amazon.co.uk/The-Mis-Behaviour-Markets-Fractal/dp/1846682622/ref=sr_1_1?ie=UTF8&qid=1342045407&sr=8-1

We showed how useless is the Gaussian based risk estimations and Gaussian based probability and likelihood calculations in real life stock price estimations (Apple). A much better estimation is based on Levy alpha stable distribution.

Advertisements


3 Responses to “Do stock prices live in Mediocristan? An Apple case study 2: Levy alpha stable distribution”

  1. Ahaa, its nice discussion regarding this paragraph here at this blog,
    I have read all that, so now me also commenting at this place.

  2. HI! What were the parameters for the Gaussian, punching in mean=0.12 and sigma=3 from the previous post doesn’t yield the same probabilities as the gaussian listed for the market moves on this post.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: