View source: R/family.univariate.R
levy | R Documentation |
Estimates the scale parameter of the Levy distribution by maximum likelihood estimation.
levy(location = 0, lscale = "loglink", iscale = NULL)
location |
Location parameter. Must have a known value.
Called |
lscale |
Parameter link function for the (positive) scale parameter
|
iscale |
Initial value for the |
The Levy distribution is one of three stable distributions whose density function has a tractable form. The formula for the density is
f(y;b) = \sqrt{\frac{b}{2\pi}}
\exp \left( \frac{-b}{2(y - a)}
\right) / (y - a)^{3/2}
where a<y<\infty
and b>0
.
Note that if a
is very close to min(y)
(where y
is the response), then numerical problem will
occur. The mean does not exist. The median is returned as
the fitted values.
An object of class "vglmff"
(see vglmff-class
).
The object is used by modelling functions
such as vglm
,
and vgam
.
T. W. Yee
Nolan, J. P. (2005). Stable Distributions: Models for Heavy Tailed Data.
The Nolan article was at
http://academic2.american.edu/~jpnolan/stable/chap1.pdf
.
nn <- 1000; loc1 <- 0; loc2 <- 10
myscale <- 1 # log link ==> 0 is the answer
ldata <-
data.frame(y1 = loc1 + myscale/rnorm(nn)^2, # Levy(myscale, a)
y2 = rlevy(nn, loc = loc2, scale = exp(+2)))
# Cf. Table 1.1 of Nolan for Levy(1,0)
with(ldata, sum(y1 > 1) / length(y1)) # Should be 0.6827
with(ldata, sum(y1 > 2) / length(y1)) # Should be 0.5205
fit1 <- vglm(y1 ~ 1, levy(location = loc1), ldata, trace = TRUE)
coef(fit1, matrix = TRUE)
Coef(fit1)
summary(fit1)
head(weights(fit1, type = "work"))
fit2 <- vglm(y2 ~ 1, levy(location = loc2), ldata, trace = TRUE)
coef(fit2, matrix = TRUE)
Coef(fit2)
c(median = with(ldata, median(y2)),
fitted.median = head(fitted(fit2), 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.