Page 1 of 6
Contents Print
Implementing the Probability Density Function Calculation of the Stable Paretian Distribution in R
Sessions
CPMs
Dedi Rosadi Department of Mathematics, Gadjah Mada University, Indonesia. E-mail:
[email protected]
1.
Background
It has been widely known that many large empirical data sets from diverse fields of studies, for instance from telecommunications and network traffics, signal processing, physics and finance, are found to be leptokurtic (i.e., heavy-tailed and peaked around the center). An important and attractive class of distributions for modeling heavy-tailed data is the stable distribution (e.g., Rachev and Mittnik, 2000). The stable random variable X is often parameterized using their characteristics function (for θ ∈ R) , which is called S1 parameterization
T
⎧ ⎧ α ⎪exp ⎨ −σ θ ⎪ ⎩ Φ X (θ ) = E (exp(iθ X )) = ⎨ ⎪ exp ⎧ −σ θ ⎨ ⎪ ⎩ ⎩
α
⎫ πα ⎞ ⎛ ⎜ 1 − i β sign(θ ) tan ⎟ + i μθ ⎬ , untukα ≠ 1 2 ⎠ ⎝ ⎭
2 ⎫ ⎛ ⎞ ⎜ 1 + i β sign(θ ) ln θ ⎟ + i μθ ⎬ , untukα = 1 π ⎝ ⎠ ⎭
(1)
Contents
Page 2 of 6
Print
There are four parameters to describe the univariate laws: α , β , σ and μ . Here α (0 < α ≤ 2) is the index of stability; β ( −1 ≤ β ≤ 1) is the skewness; σ (σ ≥ 0) is the scale parameter and μ ∈ R is the location parameter. If α = 2 , X is N( μ ,2 σ 2 ) distributed. When α is smaller, X is more leptokurtic. Stable random variables have continuous probability density functions, however, except for a few cases, it cannot be written in a closed form. Therefore, one has to rely on the numerical method to obtain its pdf. Some
Sessions
CPMs
numerical algorithms have been proposed to calculate the pdf of stable non normal (stable Paretian) such as approximation using Bergstrom series expansion (DuMouchel, 1971), Holt and Crow approximation to inversion integral (Holt and Crow, 1973), interpolation between normal and Cauchy pdfs and fitting splines (Mc Culloch, 1998), direct integration of characteristics functions (Nolan, 1999), Fast Fourier Transform/FFT (Mittnik, Doganoglu, and Chenyao, 1999) and polynomial-based approximation procedure (Doganoglu and Mittnik, 1998). In this paper, we present an implementation of the stable pdf calculation using R version 2.9. (R Development Core Team, 2009) and compare its performance with the existing implementations in literature. 2.
Pdf Approximation via FFT
From its characteristic function, the pdf of stable distribution can be written as the inverse Fourier Transform ∞ 1 − ixt (3) p ( x;α , β ,σ , μ ) = ∫ e Φ X (t )dt 2π −∞
T
Page 3 of 6
Contents Print
This integral can be computed efficiently using Fast Fourier Transform (FFT), see Mittnik, Doganoglu, and Chenyao, 1999. We briefly discuss it below. This integral is calculate for N equidistant grid points with distant h, namely x = (k − 1 − ( N / 2))h . By setting t = 2πω, this equation can be written as k p ( x;α , β ,σ , μ ) =
∞
∫e
− i 2πω ( k −1− ( N / 2)) h
Φ (2πω )d ω
(4)
−∞
This integral can be approximate as
Sessions
CPMs
N
p ( x;α , β , σ , μ ) ≈ s ∑ Φ (2π s (n − 1 − ( N / 2))e − i 2π ( n −1− ( N / 2))( k −1− ( N / 2)) hs
(5)
n =1
By setting s = (hN)-1, we obtain approximation N
p ( x; α , β , σ , μ ) ≈ s ( −1) ( k −1−( N /2)) ∑ ( −1) ( n −1) Φ (2π s ( n − 1 − ( N / 2))e − i 2π ( n −1)( k −1)/ N (6) n =1
This equation is efficiently compute using Fast Fourier Transform to the sequence
(−1)( n −1) Φ(2π s(n − 1 − ( N / 2)) , n = 1,L , N and multiply each point with s (−1)( k −1−( N /2)) to obtain the pdf value for each points. Mittnik et.al. (1999) propose to calculate the normalized PDF p( x;α , β ,σ , μ ) , where the asymmetric case is estimated using
transformation. In our implementation, we apply the method directly to the cf (1)-(2). In practical
T
implementation Mittnik et.al. (1999) propose to apply the method on the equidistant grid points x = (k − 1 − ( N / 2))h, k = 1,L, N ), where the optimal choice in most of the cases is N = 2 q , q=13 and k
Page 4 of 6
Contents Print
h=0.01. From our experience, the choice of q=13 sometimes needs to be increased to cover the range of data. To obtain the pdf on the required points falling between the equidistant points, we will apply the linear double interpolation. 3. Computation of Stable Density Function
Sessions
CPMs
Currently, only limited numbers of statistical computing environment have offers the computation of stable density in its standard release. Some of them are as follows: John Nolan offers the free stand-alone and the commercial
version
of
STABLE
program
through
Robust
Analysis
Inc.
(see
http://www.robustanalysis.com/), where the commercial version provides library and and interfaces for matlab, S-Plus, R, and Mathematica. Xplore (see http://www.xplore-stat.de), provides pdfstab quantlet for pdf calculation. Pdf calculation also can be done using function dstable of Rmetrics packages (www.rmetrics.org/), which implements direct integration method and McCulloch approximation. We have implemented an R package called as stabledistrib and contain an implementation of FFT based method above, called the function dstablefft function. Currently we only implement S1 parameterization in calculation, which can be improved to include other parameterizations for the future version of the library. We perform simulation study to compare the accuracy of our implementation of FFT based-approach with that of the DNI method. We compute stable density function for x ∈ {0, 0.1, 0.2,L , 4.9} ,
T
α ∈ {1.25,1.5,1.75} , β ∈ {0, ±0.5, ±1} and σ = 1, μ = 0 .To assess the accuracy, we compare the difference
Page 5 of 6
Contents Print
of our implementation with that of Nolan’s STABLE program (the freeware version) using the mean K
absolute deviation D1 = ∑ yi − zi / K and the maximum absolute deviation D2 = max yi − zi , where yi i =1
i =1,L, K
and zi denotes the values of pdf obtained using DNI and FFT method, respectively and K denotes the length of the vector x .We found that the accuracy of estimation depends on the choice of N and α. The choice of
N = 213 gives sufficiently accurate pdf values the differences only on the 5-th to 6-th last digit, and the accuracy
Sessions
CPMs
is increases when α gets larger. To save space, the detail is omitted.
T
REFERENCES
[1]
Doganoglu, T and Mittnik, S., 1998, An Approximation Procedure for Asymmetric Stable Paretian Densities, Computational Statistics, 13, 463-475.
[2]
DuMouchel, W.H., 1971, Stable Distributions in Statistical Inference, Ph.D. Thesis, Department of Statistics, Yale Univ.
[3]
Holt, D.R. and Crow, E.L., 1973, Tables and graphs of the stable probability density functions, Journal of Research of the National Bureau of Standards B, 77B, 143-198
[4]
McCulloch, J.H., 1998, Numerical approximation of the Symmetric Stable Distribution and Density, in R.Adler, R.Feldman, M.Taqqu (eds.), A Practical Guide to Heavy Tails, Birkhause, pp. 489-500.
[5]
Mittnik, S., S.T. Rachev, T. Doganoglu, and D. Chenyao., 1999, Computing the probability density function of the stable Paretian distribution Mathematical and Computer Modelling, 29, 10-12, 235240.
Contents
Page 6 of 6
Sessions
CPMs
Print
T
[6]
Nolan, J.P. (1999).An algorithm for evaluating Stable Densities in Zolotarev’s (M) parametrization, Mathematical and Coputer Modelling, 29, 229-233.
[7]
R Development Core Team., 2009, R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. ISBN 3-900051-00-3.
[8]
Rachev, S.T. and Mittnik, S., 2000, Stable Paretian Models in Finance, Wiley, Chichester.