View source: R/family.binomial.R
| betabinomial.rho | R Documentation |
Fits a beta-binomial distribution by maximum likelihood estimation, where the correlation coefficient rho is inputted. The parameter estimated is the mean.
betabinomial.rho(lmu = "logitlink", imethod = 1, ishrinkage = 0.95)
lmu, imethod, ishrinkage |
Same as |
This family function conducts a logistic-like regression
where the correlation parameter \rho of
a betabinomial distribution is
inputted by the user.
The family function is somewhat like a simplified
betabinomial.
The argument form2
(see vglm)
is used to input the
\rho values, which must lie in [0, 1].
The default model has \eta_1 = logit(\mu).
Same as betabinomial.
T. W. Yee
betabinomial,
extbetabinomial,
betabinomialff,
Betabinom,
vglm,
binomialff,
betaff.
## Not run:
# Example 1
nn <- 10000; NN <- 100
bdata <- data.frame(N = NN, x2 = rnorm(nn),
x3 = rnorm(nn))
bdata <-
transform(bdata,
mu1 = logitlink(-0.5, inverse = TRUE),
rho1 = logitlink( 0.5, inverse = TRUE),
mu2 = logitlink(-0.5 + x2, inverse = TRUE),
rho2 = logitlink(-0.5 + x3, inverse = TRUE))
bdata <- transform(bdata,
y1 = rbetabinom(nn, size = N, prob = mu1, rho = rho1),
y2 = rbetabinom(nn, size = N, prob = mu2, rho = rho2))
fit1 <- vglm(cbind(y1, N - y1) ~ 1, betabinomial.rho,
form2 = ~ rho1, crit = "c", bdata, trace = TRUE)
coef(fit1, matrix = TRUE)
head(fit1@extra$rho)
max(abs(fitted(fit1) - with(bdata, mu1))) # Should be 0
# Example 2
fit2 <- vglm(cbind(y2, N - y2) ~ x2, form2 = ~ rho2,
betabinomial.rho, crit = "c",
bdata, trace = TRUE)
coef(fit2, matrix = TRUE)
max(abs(fit2@extra$rho - with(bdata, rho2))) # Should be 0
max(abs(fitted(fit2) - with(bdata, mu2))) # Should be 0
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.