Fits a beta-binomial distribution by maximum likelihood estimation. The two parameters here are the mean and correlation coefficient.
betabinomial(lmu = "logit", lrho = "logit", irho = NULL, imethod = 1,
ishrinkage = 0.95, nsimEIM = NULL, zero = "rho")
Link functions applied to the two parameters.
See Links
for more choices.
The defaults ensure the parameters remain in
Optional initial value for the correlation parameter.
If given, it must be in irho = NULL
means an initial value is obtained internally,
though this can give unsatisfactory results.
An integer with value 1
or 2
or …,
which specifies the initialization method for irho
.
Specifyies which
linear/additive predictor is to be modelled as an intercept only.
If assigned, the single value can be either 1
or 2
.
The default is to have a single correlation parameter.
To model both parameters as functions of the covariates assign
zero = NULL
.
See CommonVGAMffArguments
for more information.
See CommonVGAMffArguments
for more information.
The argument ishrinkage
is used only if imethod = 2
.
Using the argument nsimEIM
may offer large advantages for large
values of
An object of class "vglmff"
(see vglmff-class
).
The object is used by modelling functions such as vglm
.
Suppose fit
is a fitted beta-binomial model. Then
fit@y
contains the sample proportions fitted(fit)
returns estimates of weights(fit, type="prior")
returns the number
of trials
If the estimated rho parameter is close to 0 then it pays to
try lrho = "rhobit"
. One day this may become the default
link function.
This family function is prone to numerical difficulties due to
the expected information matrices not being positive-definite
or ill-conditioned over some regions of the parameter space.
If problems occur try setting irho
to some numerical
value, nsimEIM = 100
, say, or else use etastart
argument of vglm
, etc.
There are several parameterizations of the beta-binomial distribution.
This family function directly models the mean and correlation
parameter, i.e.,
the probability of success.
The model can be written
binomialff
, the fitted values are the
estimated probability
of success (i.e.,
The probability function is
beta
function
with shape parameters
The default model is
This family function uses Fisher scoring.
Elements of the second-order expected
derivatives with respect to
Moore, D. F. and Tsiatis, A. (1991) Robust estimation of the variance in moment methods for extra-binomial and extra-Poisson variation. Biometrics, 47, 383--401.
Prentice, R. L. (1986) Binary regression using an extended beta-binomial distribution, with discussion of correlation induced by covariate measurement errors. Journal of the American Statistical Association, 81, 321--327.
betabinomialff
,
Betabinom
,
binomialff
,
betaff
,
dirmultinomial
,
lirat
,
simulate.vlm
.
# NOT RUN {
# Example 1
bdata <- data.frame(N = 10, mu = 0.5, rho = 0.8)
bdata <- transform(bdata,
y = rbetabinom(n = 100, size = N, prob = mu, rho = rho))
fit <- vglm(cbind(y, N-y) ~ 1, betabinomial, data = bdata, trace = TRUE)
coef(fit, matrix = TRUE)
Coef(fit)
head(cbind(depvar(fit), weights(fit, type = "prior")))
# Example 2
fit <- vglm(cbind(R, N-R) ~ 1, betabinomial, lirat,
trace = TRUE, subset = N > 1)
coef(fit, matrix = TRUE)
Coef(fit)
t(fitted(fit))
t(depvar(fit))
t(weights(fit, type = "prior"))
# Example 3, which is more complicated
lirat <- transform(lirat, fgrp = factor(grp))
summary(lirat) # Only 5 litters in group 3
fit2 <- vglm(cbind(R, N-R) ~ fgrp + hb, betabinomial(zero = 2),
data = lirat, trace = TRUE, subset = N > 1)
coef(fit2, matrix = TRUE)
# }
# NOT RUN {
with(lirat, plot(hb[N > 1], fit2@misc$rho,
xlab = "Hemoglobin", ylab = "Estimated rho",
pch = as.character(grp[N > 1]), col = grp[N > 1]))
# }
# NOT RUN {
# cf. Figure 3 of Moore and Tsiatis (1991)
with(lirat, plot(hb, R / N, pch = as.character(grp), col = grp, las = 1,
xlab = "Hemoglobin level", ylab = "Proportion Dead",
main = "Fitted values (lines)"))
smalldf <- with(lirat, lirat[N > 1, ])
for (gp in 1:4) {
xx <- with(smalldf, hb[grp == gp])
yy <- with(smalldf, fitted(fit2)[grp == gp])
ooo <- order(xx)
lines(xx[ooo], yy[ooo], col = gp)
}
# }
Run the code above in your browser using DataLab