Estimation of the probabilities of a two-stage binomial distribution.
seq2binomial(lprob1 = "logit", lprob2 = "logit",
iprob1 = NULL, iprob2 = NULL,
parallel = FALSE, zero = NULL)
Parameter link functions applied to the two probabilities,
called Links
for more choices.
Optional initial value for the first and second probabilities respectively.
A NULL
means a value is obtained in the initialize
slot.
Details at Links
.
If parallel = TRUE
then the constraint also applies to the intercept.
An object of class "vglmff"
(see vglmff-class
).
The object is used by modelling functions such as vglm
and vgam
.
This VGAM family function fits the model described by
Crowder and Sweeting (1989) which is described as follows.
Each of prob1
,
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.
Crowder, M. and Sweeting, T. (1989). Bayesian inference for a bivariate binomial distribution. Biometrika, 76, 599--603.
# NOT RUN {
sdata <- data.frame(mvector = round(rnorm(nn <- 100, m = 10, sd = 2)),
x2 = runif(nn))
sdata <- transform(sdata, prob1 = logit(+2 - x2, inverse = TRUE),
prob2 = logit(-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])
# }
Run the code above in your browser using DataLab