File: 2A-StableDistribution.Rd

package info (click to toggle)
fbasics 240.10067-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,676 kB
  • ctags: 760
  • sloc: fortran: 5,589; sh: 22; makefile: 1
file content (229 lines) | stat: -rw-r--r-- 6,649 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
\name{StableDistribution}

\alias{StableDistribution}

\alias{dsymstb}
\alias{psymstb}
\alias{qsymstb}
\alias{rsymstb}

\alias{stableMode}
\alias{dstable}
\alias{pstable}
\alias{qstable}
\alias{rstable}

\alias{symstbSlider}
\alias{stableSlider}

\title{Stable Distribution Function}


\description{
    
    A collection and description of functions to compute 
    density, distribution function, quantile function and 
    to generate random variates, the stable distribution,
    and the stable mode. Two different cases are considered,
    the first for the symmetric and the second for the 
    skewed distribution.
    \cr
    
    The functions are:
    
    \tabular{ll}{
    \code{[dpqr]symstb} \tab The symmetric stable distribution, \cr
    \code{[dpqr]stable} \tab the skewed stable distribution, \cr
    \code{symstbSlider} \tab interactive symmetric distribution display, \cr
    \code{stableSlider} \tab interactive stable distribution display. }

}


\usage{
dsymstb(x, alpha)
psymstb(q, alpha)
qsymstb(p, alpha)
rsymstb(n, alpha)

stableMode(alpha, beta)

dstable(x, alpha, beta, gamma = 1, delta = 0, pm = c(0, 1, 2))
pstable(q, alpha, beta, gamma = 1, delta = 0, pm = c(0, 1, 2))
qstable(p, alpha, beta, gamma = 1, delta = 0, pm = c(0, 1, 2))
rstable(n, alpha, beta, gamma = 1, delta = 0, pm = c(0, 1, 2))

symstbSlider()
stableSlider()
}


\arguments{

    \item{alpha, beta, gamma, delta}{
        value of the index parameter \code{alpha} with \code{alpha = (0,2]};
        skewness parameter \code{beta}, in the range [-1, 1];
        scale parameter \code{gamma}; and
        shift parameter \code{delta}.
        }
    \item{n}{
        number of observations, an integer value.
        } 
    \item{p}{
        a numeric vector of probabilities.
        }
    \item{pm}{
        parameterization, an integer value by default \code{pm=0}, 
        the 'S0' parameterization.
        }
    \item{x, q}{
        a numeric vector of quantiles.
        }
    
}


\value{

    All values for the \code{*symstb} and \code{*stable} functions
    are numeric vectors: 
    \code{d*} returns the density, 
    \code{p*} returns the distribution function, 
    \code{q*} returns the quantile function, and
    \code{r*} generates random deviates.
    
    The function \code{stableMode} returns a numeric value, the
    location of the stable mode.
    
    The functions \code{symstbSlider} and \code{stableSlider} 
    display for educational purposes the densities and probabilities
    of the symmetric and skew stable distributions.
    
}


\details{

    \bold{Symmetric Stable Distribution:}
    \cr\cr
    For the density and probability the approach of McCulloch is 
    implemented. Note, that McCulloch's approach has a density 
    precision of 0.000066 and a distribution precision of 0.000022 
    for \code{alpha} in the  range [0.84, 2.00]. 
    Quantiles are evaluated from a root finding process via the
    probability function. Thus, this leads to nonnegligible 
    errors for small quantiles, since the quantile evaluation 
    depends on the quality of the probability function.To achieve 
    higher precisions use the function \code{stable} with argument 
    \code{beta=0}. \cr
    For generation of random deviates the results of Chambers, 
    Mallows, and Stuck are used.
    \cr
    
    \bold{Skew Stable Distribution:}
    \cr\cr
    The function uses the approach of J.P. Nolan for general 
    stable distributions. Nolan derived expressions in form of 
    integrals based on the charcteristic function for standardized 
    stable random variables. These integrals are numerically 
    evaluated using R's function \code{integrate}. 
    \cr
    "S0" parameterization [pm=0]: based on the (M) representation
    of Zolotarev for an alpha stable distribution with skewness
    beta. Unlike the Zolotarev (M) parameterization, gamma and 
    delta are straightforward scale and shift parameters. This
    representation is continuous in all 4 parameters, and gives 
    an intuitive meaning to gamma and delta that is lacking in 
    other parameterizations.
    \cr
    "S" or "S1" parameterization [pm=1]: the parameterization used 
    by Samorodnitsky and Taqqu in the book Stable Non-Gaussian 
    Random Processes. It is a slight modification of Zolotarev's 
    (A) parameterization.
    \cr
    "S*" or "S2" parameterization [pm=2]: a modification of the S0 
    parameterization which is defined so that (i) the scale gamma 
    agrees with the Gaussian scale (standard dev.) when alpha=2 
    and the Cauchy scale when alpha=1, (ii) the mode is exactly at 
    delta.
    \cr
    "S3" parameterization [pm=3]: an internal parameterization. The 
    scale is the same as the S2 parameterization, the shift is 
    \eqn{-beta*g(alpha)}, where \eqn{g(alpha)} is defined in 
    Nolan [1999].
    
}


\author{

    McCulloch for the 'symstb' Fortran program, and \cr
    Diethelm Wuertz for the Rmetrics \R-port.

}


\references{

Chambers J.M., Mallows, C.L. and Stuck, B.W. (1976);
    \emph{A Method for Simulating Stable Random Variables},
    J. Amer. Statist. Assoc. 71, 340--344.

Nolan J.P. (1999);
    \emph{Stable Distributions},
    Preprint, University Washington DC, 30 pages.
    
Nolan J.P. (1999);
    \emph{Numerical Calculation of Stable Densities and Distribution
    Functions},
    Preprint, University Washington DC, 16 pages.

Samoridnitsky G., Taqqu M.S. (1994);
    \emph{Stable Non-Gaussian Random Processes, Stochastic Models
    with Infinite Variance},
    Chapman and Hall, New York, 632 pages.

Weron, A., Weron R. (1999);
    \emph{Computer Simulation of Levy alpha-Stable Variables and
    Processes},
    Preprint Technical Univeristy of Wroclaw, 13 pages.
    
}

\examples{  
## SOURCE("fBasics.2A-StableDistribution")

## Plot:
   par(ask = FALSE)
   
## stable - 
   # Plot rvs Series
   set.seed(1953)
   r = rstable(n = 1000, alpha = 1.9, beta = 0.3)
   plot(r, type = "l", main = "stable: alpha=1.9 beta=0.3", 
     col = "steelblue")
   grid()
 
## stable -  
   # Plot empirical density and compare with true density:
   hist(r, n = 25, probability = TRUE, border = "white", 
     col = "steelblue")
   x = seq(-5, 5, 0.4)
   lines(x, dstable(x = x, alpha = 1.9, beta = 0.3))
   
## stable -   
   # Plot df and compare with true df:
   plot(sort(r), (1:1000/1000), main = "Probability", pch = 19, 
     col = "steelblue")
   lines(x, pstable(q = x, alpha = 1.9, beta = 0.3))
   grid()
   
## stable -
   # Compute quantiles:
   qstable(pstable(seq(-4, 4, 1), alpha = 1.9, beta = 0.3), 
     alpha = 1.9, beta = 0.3) 
}


\keyword{distribution}