erlang.RdEstimates the scale parameter of the Erlang distribution by maximum likelihood estimation.
erlang(shape.arg, lscale = "loglink", imethod = 1, zero = NULL)The shape parameters.
The user must specify a positive integer,
or integers for multiple responses.
They are recycled by.row = TRUE
according to matrix.
Link function applied to the (positive) \(scale\) parameter.
See Links for more choices.
See CommonVGAMffArguments for more details.
The Erlang distribution is a special case of
the gamma distribution
with shape that is a positive integer.
If shape.arg = 1
then it simplifies to the exponential distribution.
As illustrated
in the example below, the Erlang distribution is
the distribution of
the sum of shape.arg independent and
identically distributed
exponential random variates.
The probability density function of the Erlang
distribution is given by
$$f(y) = \exp(-y/scale)
y^{shape-1} scale^{-shape} / \Gamma(shape)$$
for known positive integer \(shape\),
unknown \(scale > 0\) and \(y > 0\).
Here,
\(\Gamma(shape)\) is the gamma
function, as in gamma.
The mean of Y
is \(\mu=shape \times scale\) and
its variance is \(shape \times scale^2\).
The linear/additive predictor, by default, is
\(\eta=\log(scale)\).
An object of class "vglmff"
(see vglmff-class).
The object is used by modelling functions
such as vglm
and vgam.
Most standard texts on statistical distributions describe this distribution, e.g.,
Forbes, C., Evans, M., Hastings, N. and Peacock, B. (2011). Statistical Distributions, Hoboken, NJ, USA: John Wiley and Sons, Fourth edition.
Multiple responses are permitted.
The rate parameter found in gammaR
is 1/scale here—see also rgamma.
rate <- exp(2); myshape <- 3
edata <- data.frame(y = rep(0, nn <- 1000))
for (ii in 1:myshape)
edata <- transform(edata, y = y + rexp(nn, rate = rate))
fit <- vglm(y ~ 1, erlang(shape = myshape), edata, trace = TRUE)
#> Iteration 1: loglikelihood = 90.323664
#> Iteration 2: loglikelihood = 145.19052
#> Iteration 3: loglikelihood = 145.69841
#> Iteration 4: loglikelihood = 145.69845
#> Iteration 5: loglikelihood = 145.69845
coef(fit, matrix = TRUE)
#> loglink(scale)
#> (Intercept) -2.013973
Coef(fit) # Answer = 1/rate
#> scale
#> 0.1334574
1/rate
#> [1] 0.1353353
summary(fit)
#>
#> Call:
#> vglm(formula = y ~ 1, family = erlang(shape = myshape), data = edata,
#> trace = TRUE)
#>
#> Coefficients:
#> Estimate Std. Error z value Pr(>|z|)
#> (Intercept) -2.01397 0.01826 -110.3 <2e-16 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Name of linear predictor: loglink(scale)
#>
#> Log-likelihood: 145.6985 on 999 degrees of freedom
#>
#> Number of Fisher scoring iterations: 5
#>
#> No Hauck-Donner effect found in any of the estimates
#>