Extbetabinom | R Documentation |
Density, distribution function, quantile function and random generation for the extended beta-binomial distribution.
dextbetabinom(x, size, prob, rho = 0,
log = FALSE, forbycol = TRUE)
pextbetabinom(q, size, prob, rho = 0,
lower.tail = TRUE, forbycol = TRUE)
qextbetabinom(p, size, prob, rho = 0,
forbycol = TRUE)
rextbetabinom(n, size, prob, rho = 0)
x , q |
vector of quantiles. |
p |
vector of probabilities. |
size |
number of trials. |
n |
number of observations.
Same as |
prob |
the probability of success |
rho |
the correlation parameter |
log , lower.tail |
Same meaning as |
forbycol |
Logical.
A |
The extended beta-binomial
distribution allows for a slightly negative
correlation parameter between binary
responses within a cluster (e.g., a litter).
An exchangeable error structure with
correlation \rho
is assumed.
dextbetabinom
gives the density,
pextbetabinom
gives the
distribution function,
qextbetabinom
gives the quantile function
and
rextbetabinom
generates random
deviates.
Setting rho = 1
is not recommended
as NaN
is returned,
however the code may be
modified in the future to handle this
special case.
Currently most of the code is quite slow.
Speed improvements are a future project.
Use forbycol
optimally.
extbetabinomial
,
Betabinom
,
Binomial
.
set.seed(1); rextbetabinom(10, 100, 0.5)
set.seed(1); rbinom(10, 100, 0.5) # Same
## Not run: N <- 9; xx <- 0:N; prob <- 0.5; rho <- -0.02
dy <- dextbetabinom(xx, N, prob, rho)
barplot(rbind(dy, dbinom(xx, size = N, prob)),
beside = TRUE, col = c("blue","green"), las = 1,
main = paste0("Beta-binom(size=", N,
", prob=", prob, ", rho=", rho, ") (blue) vs\n",
" Binom(size=", N, ", prob=", prob, ") (green)"),
names.arg = as.character(xx), cex.main = 0.8)
sum(dy * xx) # Check expected values are equal
sum(dbinom(xx, size = N, prob = prob) * xx)
cumsum(dy) - pextbetabinom(xx, N, prob, rho) # 0?
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.