AI Glossary / Mathematics and optimization / Beginner
Longitudinal data
Definition
Longitudinal data contain repeated observations of the same entities over time. The entities might be people, machines, stores, or accounts. By linking observations across occasions, the data can reveal change within an entity as well as differences between entities. Entity identifiers and measurement times are therefore central to their interpretation.
What it means
A longitudinal dataset is more than a file with dates. Its defining feature is that observations can be connected to the same units across time. Repeated surveys of entirely different people provide repeated cross-sections, while following the same people provides a longitudinal structure.
Measurements need not occur at equally spaced intervals, and every entity need not have the same number of observations. A balanced panel is one special arrangement with observations across a common set of occasions; real datasets often have gaps, new entrants, or departures.
The structure changes what can be learned. A rise in an overall average might reflect improvement within existing entities, the arrival of different entities, or both. Keeping those possibilities separate is essential when describing trends.
How it works
Specify the entity, time scale, and measurement definition. Store a reliable identifier and timestamp with each observation. A long-format table commonly uses one row per entity and occasion; a wide-format table may place different occasions in separate columns.
Analyze both within-entity changes and between-entity differences as appropriate. Repeated observations from one entity are often related, so treating every row as an independent unit can misrepresent uncertainty or evaluation performance. The suitable model depends on the question and the pattern of dependence.
Check missing observations, changing measurement procedures, and whether follow-up depends on the outcome being studied. For prediction, ensure each input is available at the prediction time. Evaluation may require separation by entity, time, or both, according to whether the intended task concerns new entities or future observations of known ones.
Three practical examples
- A retailer can follow the same stores over several months to distinguish store-level changes from differences between locations.
- A maintenance dataset can track repeated measurements from each machine to study its trajectory.
- A product team can examine repeated account activity while keeping account identity and the timing of events clear.
Think of it this way
Think of a photo album that follows the same subjects over time, rather than a series of unrelated group photos. The analogy captures continuity of identity, but longitudinal analysis also needs consistent measurements and attention to who is missing from later pictures. Repeated observation alone does not explain what caused a change.
Worked example
Consider an original two-month dataset of store activity scores. In month 1, store A has score 10 and store B has score 30. Their average is (10+30)/2=20. In month 2, A has score 12 and B has score 32, while a newly included store C has score 100. The month-2 average is (12+32+100)/3=48.
Comparing the two overall averages suggests an increase of 28 points. However, the two stores observed in both months each increased by only 2 points: A changed from 10 to 12, and B from 30 to 32. Their matched month-2 average is 22, so their average within-store change is 22−20=2.
Neither calculation is arithmetically wrong. They answer different questions. The 28-point difference compares the composition of all observed stores at each month. The 2-point result describes change in the two matched stores. C has no month-1 observation, so its within-store change cannot be calculated from these data.
The table has five rows but only three distinct stores and only two complete month pairs. Reporting five independent store trajectories would therefore be incorrect. If A's month-2 score were recorded twice by mistake, the duplicated row would not provide an additional independent observation. The example shows why row counts, entity counts, and matched follow-up counts should be reported separately.
Illustrative case study
In a fictional customer-support study, a team follows account activity across quarterly reviews. Accounts with little activity are less likely to return a follow-up questionnaire. The team notices that the remaining respondents appear more active than the original group.
It investigates the missing-response pattern before describing the difference as improvement for all accounts. It also distinguishes a descriptive trajectory from an explanation of why activity changed. This hypothetical case illustrates attrition and interpretation, without claiming that a specific statistical adjustment solves every missing-data problem.
Common misconceptions and mistakes
Do not equate a timestamped dataset with a longitudinal design if the same entities cannot be followed. Do not confuse changes in group composition with changes within individuals. Repeated measurements increase information, but not necessarily as much as the same number of independent entities would.
Avoid filling missing follow-up values with zero unless zero is actually observed and meaningful. Do not use future measurements as inputs to a prediction supposedly made earlier. Also, temporal ordering alone does not establish causation: other changes can occur during the same period and influence the observed outcome.
Business use
Longitudinal data can support retention analysis, equipment monitoring, and repeated operational measurement. Begin by specifying whose change matters and over what time scale. Keep identifiers stable, document measurement revisions, and distinguish new entrants from continuing entities.
When evaluating an AI model, align the split with deployment. Predicting future behavior of existing accounts differs from predicting behavior for entirely new accounts. Randomly mixing related rows between training and evaluation can make results look stronger than performance under the intended conditions. The appropriate design should follow the question rather than a default row-shuffling procedure.
People also ask
Must observations be equally spaced?
No. Longitudinal records can have irregular intervals, which should be represented and considered in analysis.
Is longitudinal data the same as a time series?
The concepts overlap. Longitudinal data emphasize repeated observations of entities; a time series often emphasizes one ordered process, and datasets can combine both structures.
Does following entities prove what caused their change?
No. Longitudinal observation helps establish timing and trajectories but does not by itself remove confounding or other alternative explanations.
Check your understanding
Ten machines each have six monthly readings. How many rows and entities are present in a complete long-format table?
Answer: 60 rows and 10 machines. The 60 readings should not automatically be treated as 60 independent machines.
Related terms
- Time series
- Cross-sectional data
- Missing data
- Panel data
- repeated measures
- within-entity change
- attrition
- temporal validation
- grouped evaluation
Learn next
Next, calculate both an overall period average and a matched-entity change from a small table. Then design an evaluation split for a concrete prediction task, stating whether it must generalize to new entities, future times, or both.
More in Mathematics and optimization
- Absolute error loss - Absolute error loss measures a numerical prediction's error as the absolute difference between its predicted and reference values: L(y,y-hat)=|y-y-hat|.
- Active-set method - An active-set method is an optimization approach that works with a changing subset of constraints believed to be tight at the solution.
- Adjoint state method - The adjoint state method computes how a chosen objective changes when the parameters of a mathematical model change.
- Σ-algebra
- Algebraic connectivity - Algebraic connectivity is the second-smallest eigenvalue of a graph's Laplacian matrix.
- Algorithm IMED - Algorithm IMED, short for Indexed Minimum Empirical Divergence, is a method for choosing actions in a stochastic multi-armed bandit problem.
Sources
Primary terminology reference: Alexander Jung and contributors, The Aalto Dictionary of Machine Learning, longitudinal data entry: https://aaltodictionaryofml.github.io/ADictML_Main.pdf . The store-composition calculation and follow-up examples are original illustrations of the data structure.
Previous: Long tail Next: Longitudinal modified treatment policy