Learn R Programming

VGAM (version 1.1-3)

gtbinomial: Generally-Truncated Binomial Distribution Family Function

Description

Fits a generally-truncated binomial distribution.

Usage

gtbinomial(truncate = 0, zero = NULL, link = "logitlink",
           type.fitted = c("mean", "prob", "prob.t"),
           multiple.responses = FALSE, parallel = FALSE)

Arguments

truncate

Vector of truncated values, i.e., integers between 0 and size inclusive. Must have unique values only. May be a NULL, which stands for empty set (same as binomialff). The default is the 0-truncated or positive-binomial.

link, zero

See CommonVGAMffArguments for information.

multiple.responses, parallel

See CommonVGAMffArguments for information.

type.fitted

See CommonVGAMffArguments for information. The choice "prob.t" means the probability of having a truncated value, given the estimate of prob from an ordinary binomial distribution. The mean can be be obtained by the extractor function fitted applied to the object (the default).

Value

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

Warning

Under- or over-flow may occur if the data is ill-conditioned. The response is checked to see that no values equal any values of the truncate vector. It is easy to misuse this function; the truncate vector should ideally not be very long and have values that can be justified by the application on hand.

Details

The generally-truncated binomial distribution is the ordinary binomial distribution with the probability of certain values (truncate argument) being zero. Thus the other probabilities are scaled up. The positive-binomial (0-truncated) distribution is a special case and is the default.

Note that the argument truncate is integer-valued even though the response is converted into a sample proportion.

See Also

Gaitbinom.mlm, rposbinom, posbinomial, binomialff, simulate.vlm.

Examples

Run this code
# NOT RUN {
nnn <- 1000; tvec <- c(2, 3, 6); size <- 10
pdata <- data.frame(x2 = runif(nnn), x3 = runif(nnn))
pdata <- transform(pdata,
     y1  = rgaitbinom.mlm(nnn, prob = logitlink(-1, inverse = TRUE),
                          truncate = tvec, size = size),
     y2  = rgaitbinom.mlm(nnn, prob = logitlink(-1 + x2 + x3, inverse = TRUE),
                          truncate = tvec, size = size))
with(pdata, table(y1))
with(pdata, table(y2))
head(pdata)
fit1 <- vglm(cbind(y1, size - y1) ~ 1,
             gtbinomial(truncate = tvec), trace = TRUE, data = pdata)
coef(fit1, matrix = TRUE)
summary(fit1)

fit2 <- vglm(cbind(y2, size - y2) ~ x2 + x3, crit = "coef",
             gtbinomial(truncate = tvec), trace = TRUE, data = pdata)
coef(fit2, matrix = TRUE)
summary(fit2)
# }

Run the code above in your browser using DataLab