Tutorials › Generalized Linear Mixed Models (GLMM) › Defining The Trial And Success Event

Responses: Binary, Count, Ordinal, Overdispersed · Tutorial 66 of 698

Defining The Trial And Success Event

Learn to define an eligible trial and code its success event as a binary response without confusing ineligibility, missing outcomes, or different scientific endpoints.

Intermediate 10 min read

What You'll Learn

  • Distinguish the observational unit from the eligible trial and the event being recorded.
  • Define a binary response with an explicit indicator for a prespecified success event.
  • Apply eligibility and event rules consistently across records and follow-up windows.
  • Separate an observed non-event from an ineligible or unknown outcome.
  • Check whether a proposed binary coding answers the intended scientific question.
  • Recognize when the outcome is not naturally a single binary event.

Why Defining the Trial Comes First

A binary response is not defined merely by choosing two labels such as 0 and 1. First, specify what one record represents, which records qualify for assessment, and exactly what event earns a value of 1. If any of these choices is vague, the same raw data can produce different responses and answer different scientific questions.

In a GLMM, the observational units may be clustered: for example, patients within clinics or repeated occasions within a person. The trial is the unit at which the binary outcome is assessed. It need not be a randomized clinical-trial participant; it may be any prespecified eligible opportunity, visit, specimen, or person-time interval. The meaning of “success” comes from the scientific aim, not from the model.

Definition: An observational unit is the entity about which an outcome is recorded. An eligible trial is one observational unit or opportunity that meets the prespecified conditions for having the outcome assessed. A success event is the precisely defined outcome of interest during that trial. For an eligible trial \(i\) in cluster \(j\), define \(Y_{ij}=1\) when the success event occurs and \(Y_{ij}=0\) when it does not.

The distinction between unit and trial matters when the same entity contributes more than one record. If a patient is assessed at several eligible visits, the patient is the observational entity, while each specified visit may be a trial. The data structure must identify the repeated records as belonging to the same patient so the model can represent their dependence. By contrast, if the scientific question concerns whether each patient experiences an event at least once over a fixed period, the patient-period—not each visit—is the trial.

Encoding the Event as a Binary Response

Let \(A_{ij}\) denote the success event for eligible trial \(i\) in cluster \(j\). The binary response is its indicator:

$$ Y_{ij}=\mathbb{1}(A_{ij})= \begin{cases} 1, & \text{if } A_{ij} \text{ occurs},\\ 0, & \text{if } A_{ij} \text{ does not occur}. \end{cases} $$

Here, \(\mathbb{1}(A_{ij})\) equals 1 when the statement \(A_{ij}\) is true and 0 otherwise. For an eligible trial with a known outcome, \(Y_{ij}\) has Bernoulli support \(\{0,1\}\). In a GLMM, a common conditional response specification is

$$ Y_{ij}\mid b_j,\mathbf{x}_{ij}\sim\operatorname{Bernoulli}(p_{ij}), \qquad P(Y_{ij}=1\mid b_j,\mathbf{x}_{ij})=p_{ij}. $$

The vector \(\mathbf{x}_{ij}\) denotes covariates and \(b_j\) denotes cluster-level random effects. This response specification presumes that the trial definition and event rule are meaningful and applied consistently. The usual GLMM formulation also assumes conditional independence of trial outcomes given the modeled covariates and random effects; this does not assert marginal independence of records from the same cluster. Defining a binary response does not by itself establish that the conditional-independence assumption is plausible.

For each candidate record, use the event rule to decide whether the outcome is a success, a non-success, or not classifiable as either. The last possibility is important: a trial that was not eligible is not a \(Y_{ij}=0\), and a missing or unobserved outcome is not automatically a non-success. Such records require an eligibility or missing-data decision, not a forced binary code.

Worked Example: Defining a Patient-Level Follow-Up Outcome

Hypothetical setting. A study asks whether adults starting a treatment experience a specified adverse event within 30 days after their first dose. An adult is eligible if the first dose was administered and the required baseline information was recorded. The observational unit and trial are the patient and that patient’s 30-day follow-up period. The success event is at least one occurrence of the specified adverse event in that period.

The response rule is \(Y_i=1\) if at least one qualifying event is documented by day 30, and \(Y_i=0\) if follow-up through day 30 is complete and no qualifying event is documented. Suppose five eligible patients have complete follow-up, with observed event indicators \(1,0,1,0,0\). The number coded as successes is \(1+0+1+0+0=2\); the other three have no event during the specified period.

For illustration, if the fitted model assigns a conditional event probability \(p_i=0.70\) to the first patient, that patient’s observed Bernoulli contribution is \(p_i^{Y_i}(1-p_i)^{1-Y_i}=0.70^1(1-0.70)^0=0.70\). If it assigns \(p_i=0.30\) to the second patient, whose response is 0, the contribution is \(0.30^0(1-0.30)^1=0.70\). These calculations use the event indicator, not a judgment that one patient’s outcome is more important. The eligibility, event window, and endpoint are the same for all five records, so the codes represent the stated patient-level question.

A patient without 30-day follow-up cannot be assigned 0 on the basis of no recorded event: the absence of a record does not establish that the event did not occur. The example’s zero codes are justified because complete follow-up is specified.

Make Eligibility and the Event Operational

A usable trial definition should let another analyst decide, from the recorded information, whether a record qualifies and how its outcome is coded. State the relevant population, assessment occasion or period, and any conditions required for outcome ascertainment. Then define success in terms of observable criteria, including the event type and time window when those apply.

Eligibility should be determined independently of whether the event occurred. If the rule says a record is eligible only when the success event is observed, then eligible trials are selected using the outcome itself. That changes the population being described and can distort the intended comparison. A rule such as “include all participants meeting the baseline criteria, then assess their outcomes through day 30” keeps eligibility separate from outcome status.

Worked Example: Repeated Eligible Assessments Within Clinics

Hypothetical setting. A researcher studies whether a scheduled blood-pressure screening visit is completed. Each clinic is a cluster. A trial is one patient’s scheduled screening visit, and eligibility requires that the patient was enrolled and that the visit was due during the study period. Success means the patient attended that scheduled visit.

Suppose clinic A has four eligible scheduled visits. The attendance records are attended, not attended, attended, attended, giving \(Y_{iA}=1,0,1,1\). The codes follow the rule directly: attendance is the event, and a due but missed visit is an observed non-success. The non-success is not missing merely because the patient did not attend; the schedule and attendance record establish that the eligible visit occurred as an opportunity.

If the model gives each of these records a conditional attendance probability of \(0.60\), the recorded outcomes have probabilities \(0.60, 0.40, 0.60, 0.60\), respectively. For example, the second record has probability \(0.60^0(1-0.60)^1=0.40\). The records share a clinic, so a GLMM may represent their dependence through clinic-level random effects; it should not silently treat them as four unrelated patients merely because there are four rows.

The coding would not be justified if the dataset contained only attended visits. In that case, there is no record of eligible missed visits, so the list cannot distinguish a genuinely 100% attendance rate from incomplete capture of non-attendance. The assumed completeness of the visit register is essential to interpreting zeroes.

This example illustrates why the observational unit must be stated rather than inferred from a spreadsheet’s rows. A row may represent a patient, a scheduled visit, or a patient-period. Each choice defines a different outcome and potentially a different dependence structure. If one patient contributes several visits, the GLMM’s cluster indexing should reflect that repeated membership.

Check Whether the Coding Preserves the Question

A binary response is appropriate when the scientific question is about the occurrence or non-occurrence of one clearly specified event in one eligible trial. If the question instead concerns which of several distinct outcomes occurred, forcing all but one category into zero can hide scientifically meaningful distinctions. If the recorded variable is a number of occurrences rather than whether an event occurred, it is not automatically a binary response. The outcome definition should follow the question, not a convenient model format.

Changing the event definition can change the estimand—the quantity the analysis is intended to describe. “Any adverse event by day 30,” “a severe adverse event by day 30,” and “an adverse event requiring hospitalization by day 30” are separate endpoints. They can yield different response values for the same patient. A coding is faithful to the scientific question only when its event and time window match the endpoint that was intended.

Worked Example: Separating Event Criteria From Missing Information

Hypothetical setting. A laboratory study asks whether a specimen exceeds a prespecified concentration threshold of 10 units. Each eligible specimen is one trial, and eligibility requires that the specimen passed a quality-control check. Success is a measured concentration strictly greater than 10 units. The rule is \(Y=1\) if \(C>10\) and \(Y=0\) if \(C\leq10\), where \(C\) is the measured concentration.

For eligible specimens with concentrations \(12.4,\ 10.0,\ 8.7\), the coded outcomes are \(1,0,0\): \(12.4>10\), \(10.0\not>10\), and \(8.7\not>10\). In particular, equality belongs to the non-success category under the stated strict inequality. This explicit boundary rule prevents two analysts from coding the same value differently.

Now suppose a fourth specimen fails quality control, and a fifth eligible specimen has no recorded concentration because the assay result is unavailable. The fourth does not meet the eligibility rule, so it is not a trial in this analysis. The fifth is eligible but its binary outcome is unknown; without a concentration it cannot be classified as above or at/below 10. Coding either one as 0 would assert a known non-success, which the available information does not establish.

The event criterion, boundary, and eligibility condition are consistent with the stated threshold question. The example also shows why a data-processing rule must preserve the difference between “not eligible,” “eligible with no success,” and “eligible but outcome unknown.”

Derivation and Practical Checks

The indicator construction is simple, but it makes the logic of the response explicit. For a known eligible trial, exactly one of the event \(A_{ij}\) or its complement \(A_{ij}^{c}\) occurs. Therefore the indicator takes one of two values, with probabilities

$$ P(Y_{ij}=1\mid b_j,\mathbf{x}_{ij})=P(A_{ij}\mid b_j,\mathbf{x}_{ij})=p_{ij}, \qquad P(Y_{ij}=0\mid b_j,\mathbf{x}_{ij})=1-p_{ij}. $$

Since these probabilities are nonnegative and sum to 1, the response has the Bernoulli distribution with parameter \(p_{ij}\). This justification depends on having a single event rule and a known outcome for an eligible trial. If the recorded status could be “success,” “failure,” or “unknown,” the unknown status is not a third Bernoulli value; it is an unobserved outcome that requires separate handling.

Before fitting a binary GLMM, inspect a sample of records against the written rule. Confirm that the unit and time window are identifiable, that eligibility does not depend on the observed event, and that the event threshold or category is unambiguous. Check that every coded 0 represents an assessed non-event rather than an absent record, and that each coded 1 meets the full event definition. Finally, examine whether repeated observations or cluster membership have been represented as intended. These checks assess whether the response itself is coherent; they do not prove the model’s distributional or dependence assumptions.

1
Name the unit.
Say what one observational record represents, including whether the same entity can contribute multiple records.
2
Write eligibility before outcomes.
Specify which records qualify for assessment using criteria that do not require the success event to have occurred.
3
Define success observably.
State the event, assessment window, and any threshold or boundary rule needed to classify it.
4
Audit all three statuses.
Distinguish ineligible records, known eligible non-successes, and eligible records with an unknown outcome.

Common Mistakes and Limitations

  • Calling every unrecorded event a failure. A missing outcome does not establish that the event did not occur. Code 0 only when the eligible trial was assessed sufficiently to establish a non-event.
  • Defining the unit as “whatever is in one row.” Rows may be repeated visits or intervals from the same entity. State the scientific unit and represent shared cluster membership appropriately.
  • Using an event rule that changes across records. A different follow-up window, threshold, or eligibility rule can make 0s and 1s non-comparable. Apply a common prespecified definition or explicitly model and report justified differences.
  • Letting the event determine eligibility. Excluding eligible records because they did not experience the event removes non-successes by construction and changes the question.
  • Forcing a complex outcome into two labels without justification. When outcome categories carry distinct meaning, a binary collapse may discard information or answer a narrower question than intended.

The introductory material on Bernoulli likelihood establishes how individual binary records enter a likelihood. The present task is logically prior: a likelihood can be calculated exactly and still describe the wrong scientific endpoint if the unit, eligibility rule, or event was defined poorly. A well-defined binary response does not resolve confounding, missing-data bias, measurement error, or misspecified random-effects structure; those remain separate modeling concerns.

Check Your Understanding

Answer each question using an explicit unit, eligibility rule, or event definition where requested.

  1. A study records whether each eligible participant has a confirmed infection within 14 days. What must be specified before coding \(Y=0\)?
  2. Each patient can have three scheduled appointments. Is the patient necessarily the trial for an attendance outcome? Explain.
  3. A concentration of exactly 5.0 is coded as a success under the rule \(C\geq5.0\). What is the correct binary value?
  4. Why is an eligible record with no outcome measurement not automatically a zero?
  5. A researcher asks whether a patient experiences any event during a month but instead codes a separate response for each event occurrence. What part of the response definition has changed?

Solutions. (1) Specify the eligible population and confirm that the participant had adequate observation through the full 14-day window; otherwise absence of a recorded infection does not establish a non-event. (2) Not necessarily. If each scheduled appointment is assessed separately, the appointment is the trial and the patient contributes repeated records; if the question is whether the patient attends at least once across the three appointments, the patient-level period is the trial. (3) \(Y=1\), because \(5.0\geq5.0\). (4) The event status is unknown: no measurement is not evidence that the event did not occur. (5) The trial unit changed from a patient-month with an “any event” indicator to individual event occurrences; those records do not encode the stated patient-month binary question.

Clinical Biostats