The Two-parameter Beta Distribution Family Function
betaR.RdEstimation of the shape parameters of the two-parameter beta distribution.
Usage
betaR(lshape1 = "loglink", lshape2 = "loglink",
i1 = NULL, i2 = NULL, trim = 0.05,
A = 0, B = 1, parallel = FALSE, zero = NULL)Arguments
- lshape1, lshape2, i1, i2
Details at
CommonVGAMffArguments. SeeLinksfor more choices.- trim
An argument which is fed into
mean(); it is the fraction (0 to 0.5) of observations to be trimmed from each end of the responseybefore the mean is computed. This is used when computing initial values, and guards against outliers.- A, B
Lower and upper limits of the distribution. The defaults correspond to the standard beta distribution where the response lies between 0 and 1.
- parallel, zero
See
CommonVGAMffArgumentsfor more information.
Details
The two-parameter beta distribution is given by
\(f(y) =\)
$$(y-A)^{shape1-1} \times
(B-y)^{shape2-1} / [Beta(shape1,shape2)
\times (B-A)^{shape1+shape2-1}]$$
for \(A < y < B\), and \(Beta(.,.)\) is the beta function
(see beta).
The shape parameters are positive, and
here, the limits \(A\) and \(B\) are known.
The mean of \(Y\) is \(E(Y) = A + (B-A) \times shape1 /
(shape1 + shape2)\), and these are the fitted values of the object.
For the standard beta distribution the variance of \(Y\) is \(shape1 \times shape2 / [(1+shape1+shape2) \times (shape1+shape2)^2]\). If \(\sigma^2= 1 / (1+shape1+shape2)\) then the variance of \(Y\) can be written \(\sigma^2 \mu (1-\mu)\) where \(\mu=shape1 / (shape1 + shape2)\) is the mean of \(Y\).
Another parameterization of the beta distribution involving the mean
and a precision parameter is implemented in betaff.
Value
An object of class "vglmff"
(see vglmff-class).
The object is used by modelling functions
such as vglm,
rrvglm
and vgam.
References
Johnson, N. L. and Kotz, S. and Balakrishnan, N. (1995). Chapter 25 of: Continuous Univariate Distributions, 2nd edition, Volume 2, New York: Wiley.
Gupta, A. K. and Nadarajah, S. (2004). Handbook of Beta Distribution and Its Applications, New York: Marcel Dekker.
Note
The response must have values in the interval (\(A\),
\(B\)). VGAM 0.7-4 and prior called this function
betaff.
Examples
bdata <- data.frame(y = rbeta(1000, shape1 = exp(0), shape2 = exp(1)))
fit <- vglm(y ~ 1, betaR(lshape1 = "identitylink",
lshape2 = "identitylink"), bdata, trace = TRUE, crit = "coef")
#> Iteration 1: coefficients = 0.94886618, 2.81704941
#> Iteration 2: coefficients = 0.95450916, 2.83087867
#> Iteration 3: coefficients = 0.95454583, 2.83096779
#> Iteration 4: coefficients = 0.95454583, 2.83096779
fit <- vglm(y ~ 1, betaR, data = bdata, trace = TRUE, crit = "coef")
#> Iteration 1: coefficients = -0.050861872, 1.035706702
#> Iteration 2: coefficients = -0.046531622, 1.040605914
#> Iteration 3: coefficients = -0.046519624, 1.040618628
#> Iteration 4: coefficients = -0.046519624, 1.040618628
coef(fit, matrix = TRUE)
#> loglink(shape1) loglink(shape2)
#> (Intercept) -0.04651962 1.040619
Coef(fit) # Useful for intercept-only models
#> shape1 shape2
#> 0.9545458 2.8309678
bdata <- transform(bdata, Y = 5 + 8 * y) # From 5 to 13, not 0 to 1
fit <- vglm(Y ~ 1, betaR(A = 5, B = 13), data = bdata, trace = TRUE)
#> Iteration 1: loglikelihood = -1659.1546
#> Iteration 2: loglikelihood = -1659.1478
#> Iteration 3: loglikelihood = -1659.1478
Coef(fit)
#> shape1 shape2
#> 0.9545458 2.8309678
c(meanY = with(bdata, mean(Y)), head(fitted(fit),2))
#> meanY
#> 7.025732 7.017260 7.017260