Tutorials › Generalized Linear Models › Trial Counts Versus Replication Weights

Grouped Binomial Regression · Tutorial 394 of 981

Trial Counts Versus Replication Weights

Learn how trial totals and replication weights enter binomial likelihoods, and how to check whether weighted software input faithfully represents grouped success-failure data.

Intermediate 9 min read

What You'll Learn

  • Distinguish a binomial group’s number of trials from a frequency weight on a record
  • Write the likelihood for grouped successes and failures
  • Show when replicated Bernoulli records reproduce the grouped-data likelihood
  • Check when weighted proportions give the same parameter-dependent likelihood
  • Recognize software weight conventions that can change the analysis

Why the Type of Weight Matters

A grouped record might report 3 successes in 10 trials, while a software data set might contain one row with a proportion of 0.3 and a weight of 10. These inputs can lead to the same fitted parameter values, but that does not make their weights interchangeable by definition. A trial total says how many Bernoulli trials produced a group’s success count. A frequency weight says how many times a record is replicated in the likelihood. Understanding which meaning a software routine assigns to a weight is essential for representing the data correctly.

The distinction is easiest to see from the likelihood. Let group \(i\) have \(y_i\) successes in \(m_i\) trials, and let \(p_i(\theta)\) be its success probability under a model with parameter \(\theta\). The group’s trial total is \(m_i\); it is not an arbitrary multiplier attached to the success count.

Definition: A grouped binomial record consists of a success count \(y_i\) and a trial total \(m_i\), where \(m_i\) is a positive integer and \(y_i\) is an integer satisfying \(0 \le y_i \le m_i\). Under the binomial model, \(Y_i \sim \operatorname{Bin}(m_i,p_i(\theta))\). A frequency weight \(w_j\) on a record instead represents \(w_j\) replicated copies of that record in the likelihood.

Two Likelihoods, Two Meanings

For independent grouped records, the likelihood is

$$ L_{\mathrm{group}}(\theta) = \prod_i {m_i \choose y_i} p_i(\theta)^{y_i} \{1-p_i(\theta)\}^{m_i-y_i}. $$

The binomial coefficient counts the possible arrangements of \(y_i\) successes among \(m_i\) trials. It is part of the probability of the observed count. For estimating \(\theta\), it is constant in \(\theta\), but it can matter when reporting a likelihood value.

By contrast, suppose record \(j\) is a Bernoulli observation \(z_j\in\{0,1\}\) with success probability \(p_j(\theta)\). Giving this record frequency weight \(w_j\), a nonnegative integer, means its likelihood contribution is raised to the \(w_j\)th power:

$$ L_{\mathrm{freq}}(\theta) = \prod_j \left[ p_j(\theta)^{z_j} \{1-p_j(\theta)\}^{1-z_j} \right]^{w_j}. $$

That operation repeats the entire record, including its outcome and covariates. A frequency weight on a success record replicates successes; a weight on a failure record replicates failures. A trial total attached to one grouped record, on the other hand, specifies how many trials contributed to its single success count.

Worked Example: One Group and Two Likelihood Values

Suppose a group has \(y=3\) successes in \(m=10\) trials, and consider the probability \(p=0.4\). The probability of the grouped count is

$$ P(Y=3) = {10 \choose 3}(0.4)^3(0.6)^7 = 120(0.064)(0.0279936) = 0.214990848. $$

If the ten individual outcomes were observed and consisted of a particular sequence with three successes and seven failures, that sequence would have probability

$$ (0.4)^3(0.6)^7 = 0.0017915904. $$

The grouped-count probability is 120 times the probability of that one specified sequence, because there are \({10 \choose 3}=120\) sequences with three successes. Both likelihoods contain the same parameter-dependent factor \(p^3(1-p)^7\). They differ by a factor that does not depend on \(p\), so they give the same likelihood-based estimate of \(p\), but their likelihood values are not equal.

When Replicated Bernoulli Records Reproduce a Group

A grouped record can be represented by two Bernoulli records at the same covariate value: one success record with frequency weight \(y_i\), and one failure record with frequency weight \(m_i-y_i\). The resulting frequency-weighted likelihood has the same powers of the success and failure probabilities as the grouped binomial likelihood.

Theorem: Suppose the groups are independent, each has \(0\le y_i\le m_i\), and the model assigns the same probability \(p_i(\theta)\) to every trial within group \(i\). Replicate a Bernoulli success record at the group’s covariates \(y_i\) times and a Bernoulli failure record there \(m_i-y_i\) times, using frequency weights for those replications. The resulting likelihood and the grouped binomial likelihood have the same dependence on \(\theta\). They therefore have the same maximizers and the same likelihood ratios between parameter values. The grouped likelihood is the replicated-record likelihood multiplied by \(\prod_i {m_i\choose y_i}\).
1
Write the replicated-record contribution.
At group \(i\)’s covariates, the success row contributes \(p_i(\theta)^{y_i}\), and the failure row contributes \(\{1-p_i(\theta)\}^{m_i-y_i}\).
2
Multiply the contributions across groups.
The frequency-weighted likelihood is \(\prod_i p_i(\theta)^{y_i}\{1-p_i(\theta)\}^{m_i-y_i}\).
3
Compare with the grouped likelihood.
The grouped likelihood is this same product multiplied by \(\prod_i {m_i\choose y_i}\). Each coefficient is positive and independent of \(\theta\), proving the claim.

This equivalence relies on a substantive condition: within each group, the trials must share the same modeled success probability. If individual covariates differ, replacing their records with one success count and one trial total generally loses information about which outcomes occurred at which covariates.

Worked Example: Reconstructing Two Grouped Records

At covariate value \(x=A\), suppose there are 2 successes and 3 failures. At \(x=B\), suppose there are 6 successes and 2 failures. Write \(p_A(\theta)\) and \(p_B(\theta)\) for the modeled probabilities. The grouped likelihood is

$$ {5\choose 2}p_A(\theta)^2\{1-p_A(\theta)\}^3 {8\choose 6}p_B(\theta)^6\{1-p_B(\theta)\}^2. $$

For frequency-weighted Bernoulli input, create four rows: \((A,1)\) with weight 2, \((A,0)\) with weight 3, \((B,1)\) with weight 6, and \((B,0)\) with weight 2. Multiplying their contributions gives

$$ p_A(\theta)^2\{1-p_A(\theta)\}^3 p_B(\theta)^6\{1-p_B(\theta)\}^2. $$

The grouped likelihood is the weighted-record likelihood multiplied by \({5\choose2}{8\choose6}=10\times28=280\). Since 280 does not depend on \(\theta\), both representations produce the same maximizer and likelihood ratios. The grouped representation retains the binomial coefficients needed for the probability of the observed counts.

Weighted Proportions and Trial Weights

Some software accepts a proportion \(r_i=y_i/m_i\) and a weight \(m_i\) for a binomial response. In that convention, the parameter-dependent log-likelihood contribution is

$$ m_i\left[ r_i\log p_i(\theta) + (1-r_i)\log\{1-p_i(\theta)\} \right] = y_i\log p_i(\theta) + (m_i-y_i)\log\{1-p_i(\theta)\}. $$

This is the parameter-dependent part of the grouped binomial log-likelihood. The equality holds because \(m_ir_i=y_i\) and \(m_i(1-r_i)=m_i-y_i\). A proportion with trial weight \(m_i\) can therefore reproduce the grouped binomial fit when the software uses that weight as the binomial trial total.

The proportion alone does not carry the denominator. For example, \(0.3\) could mean 3 successes in 10 trials or 30 in 100. Those groups have the same observed proportion, but their log-likelihood contributions are multiplied by different trial totals. The denominator affects the amount of information in the likelihood and must not be discarded.

Worked Example: Comparing a Weighted-Proportion Fit

Consider two groups sharing a common success probability \(p\): group 1 has 2 successes in 5 trials, and group 2 has 6 successes in 8 trials. The grouped likelihood, apart from its binomial coefficients, is

$$ p^{2+6}(1-p)^{3+2}=p^8(1-p)^5. $$

Its log-likelihood, ignoring constants that do not depend on \(p\), is \(\ell(p)=8\log p+5\log(1-p)\). Differentiating gives

$$ \frac{d\ell}{dp} = \frac{8}{p}-\frac{5}{1-p} = \frac{8-13p}{p(1-p)}. $$

For \(0<p<1\), the denominator is positive, so the derivative is positive for \(p<8/13\) and negative for \(p>8/13\). The maximum is at \(\hat p=8/13\). Now enter the proportions \(2/5=0.4\) and \(6/8=0.75\), with trial weights 5 and 8. The weighted log-likelihood is

$$ 5\{0.4\log p+0.6\log(1-p)\} + 8\{0.75\log p+0.25\log(1-p)\} = 8\log p+5\log(1-p). $$

It gives the same maximum. Entering the two proportions without their trial weights would instead give \(\log p+\log(1-p)\), whose maximum is \(1/2\), not \(8/13\). Omitting the denominators has changed the likelihood and the fit.

Software Input and a Common Pitfall

Weight names vary across software. A field called a frequency weight often means that a record is repeated that many times. A binomial routine may instead accept a success-failure pair, or a proportion together with a prior or trial weight. These inputs can yield equivalent parameter-dependent likelihoods when used as described above, but their labels are not universal. Check the routine’s documentation to determine whether the weight means trials, replicated rows, or something else.

A frequent mistake is to treat the success count \(y_i\) as though it were a Bernoulli response and then attach \(m_i\) as a replication weight. A Bernoulli response must be 0 or 1; a count such as 3 is not one Bernoulli outcome. Another mistake is to use a group’s proportion as an unweighted response. It discards the denominator and generally changes how much that group contributes. The correction is to provide the success and failure counts, or to provide the proportion with a weight the software explicitly interprets as the trial total.

Thus, “same fitted coefficients” is a useful but limited check. Likelihood values may differ by binomial coefficients, and software can apply further conventions to reported uncertainty or goodness-of-fit quantities. Verify both the response format and the documented meaning of the weight before interpreting those outputs.

Key takeaway: A trial total belongs to a binomial success count; a frequency weight replicates a whole record. Their likelihoods can have identical dependence on the model parameters when the records are constructed appropriately, but the data meanings and likelihood constants are not interchangeable.

Check Your Understanding

Use the likelihood interpretation, rather than the weight’s label alone, to answer each question.

  1. For 4 successes in 12 trials, what do the grouped binomial likelihood and the likelihood of one specified sequence of outcomes have in common, and how do they differ?
  2. How would you represent 5 successes and 7 failures at the same covariate value using frequency-weighted Bernoulli records?
  3. A data set contains a proportion of 0.2 with trial weight 50. What success and failure counts does this represent?
  4. Why can two groups with the same observed proportion contribute different amounts to a binomial likelihood?
  5. What should you check in software documentation before treating a weight as a binomial trial total?
Clinical Biostats