seq2binomial {VGAM}R Documentation

The Two-stage Sequential Binomial Distribution Family Function

Description

Estimation of the probabilities of a two-stage binomial distribution.

Usage

seq2binomial(lprob1 = "logitlink", lprob2 = "logitlink",
             iprob1 = NULL,    iprob2 = NULL,
             parallel = FALSE, zero = NULL)

Arguments

lprob1, lprob2

Parameter link functions applied to the two probabilities, called pp and qq below. See Links for more choices.

iprob1, iprob2

Optional initial value for the first and second probabilities respectively. A NULL means a value is obtained in the initialize slot.

parallel, zero

Details at Links. If parallel = TRUE then the constraint also applies to the intercept. See CommonVGAMffArguments for details.

Details

This VGAM family function fits the model described by Crowder and Sweeting (1989) which is described as follows. Each of mm spores has a probability pp of germinating. Of the y1y_1 spores that germinate, each has a probability qq of bending in a particular direction. Let y2y_2 be the number that bend in the specified direction. The probability model for this data is P(y1,y2)=P(y_1,y_2) =

(my1)py1(1p)my1(y1y2)qy2(1q)y1y2 {m \choose y_1} p^{y_1} (1-p)^{m-y_1} {y_1 \choose y_2} q^{y_2} (1-q)^{y_1-y_2}

for 0<p<10 < p < 1, 0<q<10 < q < 1, y1=1,,my_1=1,\ldots,m and y2=1,,y1y_2=1,\ldots,y_1. Here, pp is prob1, qq is prob2.

Although the Authors refer to this as the bivariate binomial model, I have named it the (two-stage) sequential binomial model. Fisher scoring is used.

Value

An object of class "vglmff" (see vglmff-class). The object is used by modelling functions such as vglm and vgam.

Note

The response must be a two-column matrix of sample proportions corresponding to y1y_1 and y2y_2. The mm values should be inputted with the weights argument of vglm and vgam. The fitted value is a two-column matrix of estimated probabilities pp and qq. A common form of error is when there are no trials for y1y_1, e.g., if mvector below has some values which are zero.

Author(s)

Thomas W. Yee

References

Crowder, M. and Sweeting, T. (1989). Bayesian inference for a bivariate binomial distribution. Biometrika, 76, 599–603.

See Also

binomialff, cfibrosis.

Examples

sdata <- data.frame(mvector = round(rnorm(nn <- 100, m = 10, sd = 2)),
                    x2 = runif(nn))
sdata <- transform(sdata, prob1 = logitlink(+2 - x2, inverse = TRUE),
                          prob2 = logitlink(-2 + x2, inverse = TRUE))
sdata <- transform(sdata, successes1 = rbinom(nn, size = mvector,    prob = prob1))
sdata <- transform(sdata, successes2 = rbinom(nn, size = successes1, prob = prob2))
sdata <- transform(sdata, y1 = successes1 / mvector)
sdata <- transform(sdata, y2 = successes2 / successes1)
fit <- vglm(cbind(y1, y2) ~ x2, seq2binomial, weight = mvector,
            data = sdata, trace = TRUE)
coef(fit)
coef(fit, matrix = TRUE)
head(fitted(fit))
head(depvar(fit))
head(weights(fit, type = "prior"))  # Same as with(sdata, mvector)
# Number of first successes:
head(depvar(fit)[, 1] * c(weights(fit, type = "prior")))
# Number of second successes:
head(depvar(fit)[, 2] * c(weights(fit, type = "prior")) *
                          depvar(fit)[, 1])

[Package VGAM version 1.1-11 Index]