| binm | R Documentation |
Builds a single proportion response for binomial mmes fits from
counts of successes and failures (or trials). The number of trials travels with
the proportion as an attribute and is used as the binomial prior weight, so the
single-response interface of mmes is preserved.
binm(successes, failures = NULL, trials = NULL)
successes |
Numeric vector of successes. |
failures |
Numeric vector of failures. Provide either |
trials |
Numeric vector with the number of trials. |
The result is successes/trials with class "binm" and attribute
"trials". Subsetting keeps the trials aligned, so the vector can be stored
as a data-frame column. Missing counts give a missing response, handled by the
naMethodY rules of mmes. Fitting a proportion without binm
treats every value as one trial, which is wrong unless all trials equal one.
Counts must be finite integers with positive trial totals. Native Laplace
fitting supports binm() with logit, probit and complementary log-log
links and includes binomial combinatorial constants in its likelihood.
It also accepts cbind(successes, failures) with positive row totals.
Fitted values and response/working residuals stay on the proportion scale;
Pearson variance is p(1-p)/n. Trials are retained as priorWeights.
For mixed-family native fits, familym(trials="column")
can instead declare a trials column with integer success responses for
binomial rows and trial values of one for other families.
A numeric vector of proportions of class "binm".
mmes
set.seed(1)
d <- data.frame(x = rnorm(60), g = factor(rep(1:12, each = 5)))
d$n <- sample(5:10, 60, TRUE)
d$s <- rbinom(60, d$n, plogis(0.3 * d$x))
fit <- mmes(binm(s, trials = n) ~ x,
random = ~ g,
data = d,
family = binomial(),
control = mmes_control(update = list(blendWeight = 0),
diagnostics = list(verbose = FALSE)))
fit$b
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.