Statistics & probability

Random intercept logistic mixed model calculator for grouped binary outcomes

Fit grouped binary outcomes with a Gaussian random intercept and inspect likelihood and quadrature diagnostics.

Your numbers

Valid JSON.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A random intercept lets observations from one group share an unobserved shift in their log odds. It is useful when repeated outcomes within the same classroom, household or subject cannot reasonably be treated as independent.

THE FORMULABernoulli logit p_ij=logistic(X_ij beta+b_j), b_j~N(0,sigma²). Maximize sum_j log integral phi(z) product_i Bernoulli(y_ij;logistic(Xbeta+sigma*z)) dz using Gauss-Hermite quadrature with correct sqrt2 scaling and log-sum-exp. Optimize beta and log sigma; separately evaluate sigma=0 boundary. Compare quadrature orders and report convergence, boundary and separation diagnostics. Posterior cluster random-effect moments use the same normalized quadrature weights. Numerical Hessian SE only if well-conditioned and interior.

A worked example

With the prefilled inputs, randomInterceptSD = 0.

Good to know

Fixed-logistic zero-variance boundary candidate; no interior fit improved the likelihood beyond tolerance. Not a global variance-component test.

Account for repeated binary outcomes

A random intercept lets observations from one group share an unobserved shift in their log odds. It is useful when repeated outcomes within the same classroom, household or subject cannot reasonably be treated as independent.

The group shift is modeled as Gaussian with mean zero. This distributional assumption is part of the model and is stronger than simply attaching a group label to ordinary logistic regression.

Random-intercept variance boundaryBalanced pairs favor zero random-intercept varianceGroup 110Group 210p(1−p) ≤ 1/4Each balanced pair: E[p(1−p)] ≤ 1/4Equality at β=0 and σ=0Two-pair log likelihood = −4 log(2)
Scroll across to see the full diagram.
For two groups containing one success and one failure each, p(1-p)≤1/4 proves the intercept-only maximum occurs at beta0=0 and random-intercept variance zero.

Compare with the Random intercept mixed model calculator for grouped data. Estimate subject-specific binary-response coefficients and an integrated random-intercept variance; Gaussian mixed regression assumes continuous normal errors and GEE supplies marginal rather than integrated likelihood.

Distinguish fixed and random terms

Use the prefilled input structure and preserve the declared column or index order. The fixed intercept describes a group whose random effect is zero. Predictor slopes act conditionally on the group effect; exponentiating a slope gives a conditional odds ratio under the chosen coding.

The random-intercept standard deviation describes between-group variation on the log-odds scale. It is not the standard deviation of the observed binary responses and cannot be interpreted directly as a percentage-point difference. Rows are group label, binary outcome and one to three predictors; a fixed intercept is added automatically. At least ten groups and thirty total rows are needed, and both response values must appear. The group label is a grouping key rather than a numerical predictor. Replacing labels with other distinct integers leaves the model unchanged. Predictors should be scaled to a useful range before fitting: an enormous coefficient attached to a tiny measurement unit can create difficult likelihood curvature even though the scientific model is equivalent after rescaling. The page returns population-level fixed coefficients and one common random-intercept standard deviation.

Enter outcome and group structure

Supply only zero-or-one outcomes with a complete group identifier and the intended fixed-effect columns. The same group label must mean the same shared intercept throughout the data.

A few large groups are not interchangeable with many independent groups. Limited group replication makes variance estimation uncertain even when the overall row count looks substantial.

Integrate rather than average intercepts

The marginal likelihood integrates each group's conditional Bernoulli likelihood over its possible random intercept. Gaussian quadrature approximates that integral and must be checked at more than one numerical resolution.

The integral is evaluated in logarithms to preserve tiny group likelihoods. A fitted result should retain optimization and quadrature diagnostics so an apparently precise coefficient cannot hide an unfinished numerical calculation.

A balanced-pair boundary example

Consider two groups, each with one success and one failure, and no predictor except an intercept. At intercept zero and random-effect variance zero, each group's likelihood is one-quarter.

Spreading the random intercept lowers the expectation of p(1-p), so the maximum occurs on the zero-variance boundary. The total log likelihood is minus four times log two, approximately minus2.7726.

Recognize unstable fits

Groups with only successes or only failures can encourage very large conditional effects. Complete separation among fixed predictors can also prevent a finite maximum-likelihood coefficient from existing.

A zero estimated random-effect variance can be a legitimate boundary solution. It should be reported directly rather than replaced with an arbitrary tiny positive number that suggests the variance was precisely identified.

Keep the interpretation conditional

Predictions for a typical zero-effect group differ from predictions averaged over the random-effect distribution. Choose the target before comparing this model with a population-level probability calculation.

The fitted group effects are shrunken estimates that depend on the Gaussian prior structure. They are not independent measurements of group quality, and small-sample rankings can be particularly sensitive to the model. The numerical fit uses fifteen-node adaptive Gauss-Hermite quadrature and compares the fitted likelihood at twenty-five nodes. A small quadrature difference checks integration at that candidate; it does not prove that no other likelihood maximum exists. The fixed-logistic zero-variance candidate is fitted separately and can be returned when the positive-variance search does not improve it beyond tolerance. That outcome is explicitly a boundary candidate, not a variance-component significance test. Failed score or quadrature checks leave the fit unresolved. No posterior group-specific random effects, prediction intervals or random slopes are supplied by this version. Fixed-logistic zero-variance boundary candidate; no interior fit improved the likelihood beyond tolerance. Not a global variance-component test.

A few questions, answered

Why does my variance estimate equal zero?

The likelihood can be maximized at the boundary when the data do not support positive between-group heterogeneity under this model.

Is the fixed intercept an overall probability?

Its inverse logit is the probability for a zero-random-effect group, not generally the probability averaged over all groups.

Can I use a group only once?

A model may evaluate such rows, but single-observation groups provide weak information about a separate random-intercept variance.

Are quadrature results exact?

No. The approximation should be checked by increasing quadrature resolution and reviewing the resulting parameter and likelihood changes.

Find your calculator

Start typing to explore the library.