A Grammar for Choosing a Model: Five Questions Before Any Command

Clinical Epidemiology ResearchMethodology and Research DesignUniqcret doctor knowledges
A Grammar for Choosing a Model: Five Questions Before Any Command
On this page

อ่านฉบับภาษาไทย (Thai version)

Abstract

Choosing an analysis is a grammar, not a list of model names to memorise: Outcome + Denominator/Time + Dependence + Estimand + Special structure = Analysis. Five questions fill the slots, and when one feature changes, one part of the model changes with it. The outcome sets the family: linear, logistic, Poisson or negative binomial, Cox, ordinal or multinomial. Unequal follow-up turns a count into a rate: two events in 10 days is 0.20 per day and two in 100 days is 0.02 per day, the same count at a ten-fold different rate, so a log person-time offset is added. Patients inside one hospital are not independent, so clustering is added through a cluster-robust variance, GEE or a mixed model. For a trial that randomises hospitals and counts infections over unequal patient-days, the parts assemble into a count model with a log person-time offset and hospital clustering. This article builds that analysis from the anatomy of the data, then changes the trial one feature at a time.


Visual summary. The analysis is assembled slot by slot from the features of the data.

Five candidate analyses for one infection trial

A trial randomises hospitals, not patients, to an infection-prevention bundle or to usual care. In every hospital the team counts each patient's hospital-acquired infections, and patients stay for different numbers of patient-days. At the planning meeting, five analyses are put on the table: logistic regression, Poisson regression, linear regression, a count model with a log patient-days offset and hospital clustering, and a Kaplan-Meier analysis.

The statistician does not pick one by its name. She reads the trial for its parts: what is counted, over how much time, in which groups of patients, and for which effect. The analysis is then assembled from those parts, and only one of the five keeps them all.

Learn a grammar, not a list of model names

Statistical analysis is easier to learn as the grammar of a model than as a list of model names to remember one at a time. A scenario can change by a single word, from a count to a yes or no, or from equal to unequal follow-up, and the right analysis changes with it. What matters is whether you can build the model from the components of the data.

Five questions before any model name

Do not start from “Poisson or logistic?”. Start from five questions.

  1. What is Y? Binary, continuous, a count or a time to an event.
  2. Does the denominator or the follow-up time differ between patients?
  3. Are the observations really independent?
  4. Which effect is wanted? An odds ratio (OR), a risk ratio (RR), an incidence rate ratio (IRR), a hazard ratio (HR) or a mean difference. This effect is the estimand, the quantity the study sets out to estimate. An IRR compares events per unit of follow-up time; an HR compares the instantaneous event rates of patients who are still event-free.
  5. Is there a special structure? Recurrent events (one patient has the event more than once), competing risks (another event, such as death, prevents the event of interest), overdispersion (counts that vary more than a Poisson model allows) or clustering.

These five questions are the real root of every choice that follows.

Layer 1: the outcome sets the model family

The kind of outcome decides the family of the model [1]. Risk, odds, incidence rate and hazard are different quantities, so the outcome and the research question have to agree on which one is measured, and recurrent events are a different outcome structure from a single event.

This layer gives the base verb of the sentence. The layers after it conjugate that verb to the features of the study.

The base model for each kind of outcome.
OutcomeExampleBase model
ContinuousBlood pressure, HbA1cLinear regression
BinaryDead or aliveLogistic regression
CountNumber of admissionsPoisson or negative binomial regression
RateEvents per patient-yearCount model + offset
Time to eventTime to deathCox or another survival model
OrdinalMild, moderate or severeOrdinal logistic regression
Nominal, more than two groupsDisease A, B or CMultinomial logistic regression

Layer 2: only a count, or a rate?

This is the layer where a count analysis most often goes wrong. A count says how many events happened; a rate says how many happened per unit of time observed.

Two patients, the same count

Suppose patient A has 2 events over 10 days of observation, and patient B has 2 events over 100 days.

  1. Count only

    \[ \text{A} = 2 \text{ events}, \quad \text{B} = 2 \text{ events} \]

    Counted alone, the two patients look the same.

  2. Rate for patient A

    \[ \frac{2 \text{ events}}{10 \text{ days}} = 0.20 \text{ per day} \]

    Two events over 10 days of observation.

  3. Rate for patient B

    \[ \frac{2 \text{ events}}{100 \text{ days}} = 0.02 \text{ per day} \]

    The same two events, spread over 100 days.

  4. Compare the rates

    \[ \frac{0.20}{0.02} = 10 \]

    Patient A's rate is ten times patient B's.

Result: Both patients have 2 events, yet patient A's rate, 0.20 per day, is ten times patient B's, 0.02 per day.

Switching on the offset

So when a study description says any of these, the time slot is switched on:

Person-time is the time each patient was observed and at risk, added over patients; patient-days and person-years are person-time in different units. The module to switch on is the offset:

offset = log(exposure time)

An offset is a term whose coefficient is fixed at 1, so the model describes events per unit of time rather than raw counts [2]:

$$\log \mathrm{E}(\text{events}) = \log(\text{person-time}) + \beta_0 + \beta_1 x$$

Moving the offset to the left side gives the log of the rate, $\log\{\mathrm{E}(\text{events})/\text{person-time}\}$, so the model compares rates. The count family can be Poisson regression or negative binomial regression, a count model that lets the variance exceed the mean. A separate article covers Poisson regression for rates.

Layer 3: independent, or correlated?

This module matters a great deal.

Independent: each patient is unrelated to every other patient, and ordinary regression works.

Clustered: the observations come in groups, such as

Members of one cluster may resemble each other: patients in one hospital share its staff and routines, and two eyes share one patient.

Assembling the grammar for the infection trial

Each phrase of the trial description fills one slot.

  1. “Patient event counts”

    The outcome is a count, so the family is Poisson or negative binomial.

  2. “Unequal patient-days”

    The count becomes a rate: add a log(patient-days) offset.

  3. “Hospitals are randomised”

    Patients in one hospital should not be treated as independent: account for hospital clustering.

  4. Put the parts together

    \[ \text{Count} + \text{unequal person-time} + \text{hospital clustering} \]

    Each feature of the data has its own part in the model.

Result: Count model + log(person-time) offset + hospital clustering, the one candidate on the table that keeps every feature.

This is conjugation: the base verb, a count model, takes the endings that the features of the trial demand.

Six versions of the same trial

How the trial can change matters more than remembering its one analysis. Each version below changes one feature, and one part of the model changes with it.

Version 1, the original. Event counts, unequal patient-days, hospitals randomised. Needed: Count + offset + cluster.

Version 2. Event counts, but every patient is followed for the same 1 year; hospitals randomised. The denominator is now equal, so no offset is needed to correct for unequal exposure. What remains is Count + cluster, for example a clustered Poisson or negative binomial analysis.

Version 3. The outcome is developed an infection: yes or no; hospitals randomised. The outcome has changed from a count to binary, so the family changes at once: Binary + cluster, for example logistic GEE or mixed-effects logistic regression, not the count model of Version 1.

Version 4. The outcome is time until the first infection; hospitals randomised. This is no longer a count but a time to a first event: Survival model + cluster, for example a Cox model that accounts for hospital clustering.

Version 5. Patients can have several infections during follow-up. Another module opens, recurrent events: Recurrent-event model + dependence, for example the Andersen-Gill model, a Cox-type model in which each patient contributes every infection, with a robust variance, if the estimand is the overall rate of recurrent events [4].

Version 6. Event counts, unequal person-time, hospitals randomised, and the variance of the counts is much larger than their mean. The new clue is overdispersion: the Poisson assumption that the variance equals the mean may not hold, so the negative binomial module opens, giving Negative binomial + log(person-time) offset + hospital clustering.

GEE or mixed model: one more slot

Suppose the outcome is binary and clustered, as in Version 3. GEE and a mixed-effects model can both be used, but they answer from different perspectives [5].

GEE targets the population-average, or marginal, effect. Its question is roughly: on average across the population, what does the treatment do?

A mixed-effects model, for example with a random intercept for hospital, targets the cluster-specific, or conditional, effect. Its question is roughly: once the differences between hospitals are taken into account, what is the association?

Why a marginal and a conditional odds ratio from the same patients can differ is the subject of part 5.

Repeated measures: one patient, several values

Suppose blood pressure is measured in the same patients at baseline, month 1, month 3 and month 6. With 100 patients there are not 400 independent observations, because the 4 values from one patient are correlated.

So the grammar reads Continuous + repeated, and the analysis can be a linear mixed model, a linear regression with a random effect for each patient, or GEE [3]. It is not ordinary linear regression that pretends the 400 rows are independent.

Clustered and repeated: one family, two sources

Clustered and repeated data belong to one family, correlated observations. They differ in the source of the correlation.

The two can also nest:

$$\text{measurement} \subset \text{patient} \subset \text{hospital}$$

Blood pressure measured 5 times per patient, patients inside hospitals, and hospitals as the randomised clusters make multilevel longitudinal data. A harder analysis may have to capture both layers of correlation.

Survival analysis conjugates too

Survival models follow the same grammar, one module at a time.

  1. Time to the first event: a Cox model, the usual regression for a time to an event, which estimates a hazard ratio.
  2. + clustering by hospital: a Cox model with a clustered, or robust, variance.
  3. + recurrent events: the Andersen-Gill model [4]; the Prentice-Williams-Peterson (PWP) model [6], which handles the first, second and later events in separate strata; or a frailty model, which gives each patient or cluster a shared random effect. The choice depends on the scientific target.
  4. + death as a competing event: first decide what is being asked [7]. For an aetiological question about the hazard, use a cause-specific hazard model, which ends a patient's follow-up for the event of interest at death. For a question about the actual cumulative probability of the event, use the cumulative incidence, the probability of the event by a stated time while death can occur first, with a Fine-Gray type model [8] when covariates are needed.

So the word “survival” on its own does not choose a Cox model.

The Statistical Grammar table

Read each row as a base outcome, then the feature that modifies it, then what is added or changed. It is a framework to understand, not a table to memorise row by row.
Base outcomeModifierWhat to add or change
ContinuousNoneLinear regression
ContinuousRepeated or clusteredMixed model or GEE
BinaryNoneLogistic regression
BinaryClusteredLogistic GEE or GLMM (generalized linear mixed model)
CountNonePoisson or negative binomial
CountUnequal exposure+ log exposure offset
CountClustered+ GEE, a random effect or robust clustering
CountUnequal exposure + clusteroffset + clustering
CountOverdispersionNegative binomial often considered
Time to eventFirst eventCox or another survival model
Time to eventClustering+ robust variance or frailty
Time to eventRecurrentRecurrent-event model
Time to eventCompeting eventCause-specific hazard or Fine-Gray, depending on the estimand

The link function is the scale on which the covariates act on the mean of the outcome, and it decides which effect measure a model gives naturally [9].

How the link and the family set the effect measure and the standard error is worked through in part 2.

The root: six steps before choosing an analysis

Each time an analysis has to be chosen, run these steps in your head.

  1. STEP 1: What is Y? Continuous, binary, a count or a time?
  2. STEP 2: What is the denominator? Was everyone observed equally, or does person-time differ?
  3. STEP 3: Independent? The same patient? The same hospital? The same family?
  4. STEP 4: Special event structure? A first event, recurrent events or a competing event?
  5. STEP 5: What effect is wanted? OR, RR, IRR or HR; marginal or conditional?
  6. STEP 6: Does the proposed analysis respect ALL five?

Why four of the five candidates fail

  • “Logistic regression will do.”

    It is a regression, but the kind of Y is wrong: each patient has a count of infections, not a yes or no.

    Fix: Start from STEP 1: a count calls for the Poisson or negative binomial family.

  • “Poisson regression on the counts is enough.”

    Y is right, but the analysis forgets the time and the clusters: patients were observed for unequal patient-days, and patients in one hospital are not independent.

    Fix: Add a log(patient-days) offset and account for hospital clustering.

  • “Linear regression on the counts.”

    The family is wrong: a count of infections is not a continuous measurement.

    Fix: Use the count family that matches Y, then add the time and cluster parts.

  • “Follow-up time means Kaplan-Meier.”

    Seeing follow-up, it jumps to survival analysis, but neither the scientific target nor the data structure fits: the trial counts infections over unequal time in hospital clusters, not the time to one first event.

    Fix: Use survival methods when the outcome is a time to an event, as in Version 4; for counts over unequal time, keep the count model with its offset and clustering.

Glossary

person-time (person-time (ผลรวมเวลาที่อยู่ในความเสี่ยง))
The time each patient was observed and at risk, added over patients, such as patient-days or person-years.
offset
A term whose coefficient is fixed at 1; log person-time as the offset turns a count model into a rate model.
negative binomial regression (negative binomial regression)
A count model like Poisson regression that lets the variance exceed the mean.
overdispersion (การกระจายเกินกว่าที่แบบจำลองกำหนด (overdispersion))
Count variance larger than the mean, which a Poisson model assumes to be equal.
cluster-robust standard error (cluster-robust standard error)
A standard error computed from the variation between clusters, so observations within one cluster may be correlated.
generalized estimating equations (สมการประมาณค่าวางนัยทั่วไป (GEE))
An approach for correlated data that estimates the population-average, or marginal, effect.
mixed-effects model
A regression with random effects for clusters or patients, which estimates a cluster-specific, or conditional, effect.
estimand (ปริมาณเป้าหมายของการประมาณ (estimand))
The effect a study sets out to estimate, such as an odds ratio, a rate ratio or a hazard ratio, marginal or conditional.
link function (ฟังก์ชันเชื่อมโยง (link function))
The scale that links the mean of the outcome to the covariates; it sets the effect measure a model gives.
hazard ratio (อัตราส่วนฮาซาร์ด (hazard ratio, HR))
The ratio of instantaneous event rates among patients who are still event-free.
Andersen-Gill model (แบบจำลอง Andersen-Gill (AG))
A Cox-type model for recurrent events in which each patient contributes every event, used with a robust variance.
Prentice-Williams-Peterson model (แบบจำลอง Prentice-Williams-Peterson (PWP))
A Cox-type model for recurrent events that handles each event number in its own stratum.
frailty model (แบบจำลอง frailty)
A survival model with a random effect shared by the events of one patient or one cluster.
competing event (เหตุการณ์แข่งขัน (competing event))
An event, such as death, that prevents the event of interest.
cause-specific hazard ratio (อัตราส่วนฮาซาร์ดเฉพาะสาเหตุ (cause-specific hazard ratio))
The hazard ratio for one cause among patients still free of any event, suited to aetiological questions.
cumulative incidence function (อุบัติการณ์สะสม (cumulative incidence function, CIF))
The probability of the event of interest by a stated time when competing events can occur.
Fine-Gray model (แบบจำลอง Fine-Gray)
A regression model for the cumulative incidence of one cause when competing events can occur.

References

  1. Vittinghoff E, Glidden DV, Shiboski SC, McCulloch CE. Regression methods in biostatistics: linear, logistic, survival, and repeated measures models. 2nd ed. New York: Springer; 2012. doi:10.1007/978-1-4614-1353-0 https://doi.org/10.1007/978-1-4614-1353-0
  2. Gardner W, Mulvey EP, Shaw EC. Regression analyses of counts and rates: Poisson, overdispersed Poisson, and negative binomial models. Psychol Bull. 1995;118(3):392-404. doi:10.1037/0033-2909.118.3.392 https://doi.org/10.1037/0033-2909.118.3.392
  3. Fitzmaurice GM, Laird NM, Ware JH. Applied longitudinal analysis. 2nd ed. Wiley; 2011. doi:10.1002/9781119513469 https://doi.org/10.1002/9781119513469
  4. Andersen PK, Gill RD. Cox's regression model for counting processes: a large sample study. Ann Stat. 1982;10(4):1100-1120. doi:10.1214/aos/1176345976 https://doi.org/10.1214/aos/1176345976
  5. Hubbard AE, Ahern J, Fleischer NL, Van der Laan M, Lippman SA, Jewell N, Bruckner T, Satariano WA. To GEE or not to GEE: comparing population average and mixed models for estimating the associations between neighborhood risk factors and health. Epidemiology. 2010;21(4):467-474. doi:10.1097/EDE.0b013e3181caeb90 https://doi.org/10.1097/EDE.0b013e3181caeb90
  6. Prentice RL, Williams BJ, Peterson AV. On the regression analysis of multivariate failure time data. Biometrika. 1981;68(2):373-379. doi:10.1093/biomet/68.2.373 https://doi.org/10.1093/biomet/68.2.373
  7. Wolbers M, Koller MT, Stel VS, Schaer B, Jager KJ, Leffondré K, Heinze G. Competing risks analyses: objectives and approaches. Eur Heart J. 2014;35(42):2936-2941. doi:10.1093/eurheartj/ehu131 https://doi.org/10.1093/eurheartj/ehu131
  8. Fine JP, Gray RJ. A proportional hazards model for the subdistribution of a competing risk. J Am Stat Assoc. 1999;94(446):496-509. doi:10.1080/01621459.1999.10474144 https://doi.org/10.1080/01621459.1999.10474144
  9. McCullagh P, Nelder JA. Generalized linear models. 2nd ed. London: Chapman and Hall; 1989. doi:10.1007/978-1-4899-3242-6 https://doi.org/10.1007/978-1-4899-3242-6

Key takeaways

  • Model = Outcome family + Time/exposure + Correlation + Estimand + Special event structure: build the analysis from the features of the data, not from a remembered model name.
  • Unequal follow-up turns a count into a rate: two events in 10 days (0.20 per day) and two in 100 days (0.02 per day) differ ten-fold, so add a log person-time offset.
  • Patients in one hospital, or repeated values from one patient, are correlated observations; allow for them with a cluster-robust variance, GEE or a mixed model, where GEE gives a marginal effect and a mixed model a conditional one.
  • When one feature changes, such as equal follow-up, a yes-or-no outcome, time to the first infection, recurrent infections or overdispersion, change only that part of the model.
  • Check every candidate analysis against all five questions: the right one keeps every feature.

Related in the wiki: [[glm-link-family-guide]] [[poisson-regression-rates-lambda]]

0
Message for International and Thai ReadersUnderstanding My Medical Context in ThailandRead more →Message for International and Thai ReadersUnderstanding My Broader Content Beyond MedicineRead more →

Comments

No comments yet. Be the first to share your thoughts.

Sign in to comment