Statistics & probability

Dirichlet regression calculator for compositional proportions

Fit continuous positive compositions using reference-softmax mean regression and one common Dirichlet concentration.

Your numbers

Each line: 3–5 strictly positive parts summing to one; 30–150 observations.
One aligned row per composition; one or two columns, including any intercept.

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

Fit continuous positive compositions using reference-softmax mean regression and one common Dirichlet concentration. Return fitted compositions and local likelihood diagnostics with the last part as reference.

THE FORMULAμᵢⱼ=exp(xᵢᵀβⱼ)/[1+Σh<K exp(xᵢᵀβh)], μᵢK=1/[1+Σh<K exp(xᵢᵀβh)]; αᵢⱼ=φμᵢⱼ; ℓᵢ=logΓ(φ)−ΣlogΓ(αᵢⱼ)+Σ(αᵢⱼ−1)log yᵢⱼ.

A worked example

The forty-five displayed compositions give last-part-reference coefficient rows [0.424563987, 0.630168230] and [−0.066725378, −0.414608966], with common concentration 14.350464594.

Good to know

30–150 independent strictly positive compositions with 3–5 parts, entries >10⁻⁸ and row sums within 10⁻⁷ of one; no automatic renormalization. 1–2 explicit full-rank design columns including any intercept, entries within ±20. Last part reference, constant precision, coefficient bounds ±12 and −3<logφ<9; three local starts with score/curvature checks. No zeros, multinomial counts, precision covariates, intervals or global-optimum claim.

Model a whole composition

A composition divides one whole among several parts. Increasing one part necessarily changes the room available to the others. Fitting separate unconstrained regressions to each proportion can predict negative values or totals different from one; a Dirichlet mean model keeps the joint fitted composition inside the simplex.

The input is continuous positive proportions, not multinomial count vectors. A recorded share of 0.25 has no implicit denominator of four. If observations arise from small integer totals, a count model that includes those totals may better represent measurement uncertainty than a continuous density on proportions.

Dirichlet fitted shares preserve the wholeFitted mean sharePredictor-10100.51Blue 1 · Green 2 · Gray 3
Scroll across to see the full diagram.
Three fitted mean-share curves sum to one at each predictor value; part three is the reference category.

Compare this with the Dirichlet multinomial overdispersion fit calculator from count rows. Fit covariate-dependent continuous compositions rather than overdispersed multinomial count rows.

Prepare strictly positive rows

Enter three through five parts in a fixed column order, with each row summing to one within the stated tolerance. Every value must exceed the numerical positivity floor. Exact zeros and ones are unsupported because the logarithmic density and ordinary interior Dirichlet assumptions require strictly positive parts.

Do not silently replace a structural zero with a tiny number merely to pass validation. A detection limit, rounding zero and genuinely impossible category are different data-generating situations. Decide how to address them before analysis and document any scientifically justified preprocessing alongside the original recorded values.

Use a reference mean parameterization

The last part is the reference for the mean regression. Each other part has a linear predictor, whose exponential is normalized together with a reference value of one. This softmax construction yields positive means summing to one for every entered design row without fitting a redundant coefficient vector.

A common concentration phi determines alpha for each part as phi times its mean. The same concentration applies to all observations here. Predictor columns are explicit, so the usual intercept requires a column of ones. With two columns, each nonreference part receives an intercept and one predictor coefficient.

Inspect the default three-part fit

Forty-five synthetic compositions accompany a predictor ranging from minus one to one. The fitted coefficients for the first part relative to part three are approximately 0.424564 and 0.630168. For the second part they are approximately minus 0.066725 and minus 0.414609, using intercept then predictor order.

The estimated common concentration is approximately 14.350465. At predictor zero, exponentiating the two intercepts, appending one and normalizing gives the fitted mean composition. The positive first slope and negative second slope describe changes in their mean ratios to the reference, rather than constant percentage-point changes.

Read concentration and dependence correctly

For a fixed fitted mean, marginal variance of a part is mu times one minus mu divided by phi plus one. Distinct parts have covariance minus their mean product divided by phi plus one. These restrictions explain both the usefulness and the limitations of this familiar composition model.

The output includes the fitted compositions for the supplied rows, the coefficient matrix, concentration and likelihood diagnostic. A negative negative-log-likelihood is possible because a continuous density can exceed one. Density units differ from discrete probability masses, so its sign alone is not evidence of a computation error.

Check local fitting diagnostics

Three starts optimize the same bounded likelihood. The best converged solution must have a small numerical score and positive observed local curvature. The code rejects coefficients or concentration near the search boundary. This protects against printing unresolved fits while leaving the possibility of other local solutions explicit.

Thirty through one hundred fifty independent observations are accepted, with one or two explicit design columns. The design must have full rank and predictors must be scaled within the supported range. Nearly deterministic compositions can imply very large concentration and make the finite search boundary relevant.

Decide what the model cannot explain

The ordinary Dirichlet imposes a particular negative covariance structure conditional on the predictors. Compositions with more complicated dependence, mixtures or parts that co-vary relative to an omitted total may need another model. Residual patterns and subject-matter expectations matter even when the numerical likelihood is well behaved.

This implementation provides constant precision, a last-part reference and local maximum-likelihood fitting. It does not estimate precision regressions, support zeros, fit latent mixtures, provide coefficient intervals or establish causality. Changing the reference changes coefficient coordinates; reordering composition columns consistently should preserve fitted compositions after their order is restored.

A few questions, answered

May I enter percentages totaling one hundred?

Convert them to proportions totaling one before entry. The calculator deliberately does not renormalize rows because a wrong total can reveal a data or unit error.

Why are zeros rejected?

The continuous interior Dirichlet density uses log proportions and does not model structural zeros. Handling zeros requires a separately justified measurement or probability model.

Which part is the reference?

The last composition column. Each coefficient row models a mean ratio to that part through the reference-softmax parameterization.

Can negative negative-log-likelihood be valid?

Yes. A continuous density may exceed one, unlike a discrete probability mass. A negative value alone is not a sign or numerical error.

Find your calculator

Start typing to explore the library.