Data Structure and Planning Analysis
Data Structure and Planning Analysis
What "data structure" means
Before any statistic is computed, a study has a structure: what was measured, on what, how those things were selected, and how any treatments were handed out. Almost every serious analysis failure in biology is a structure failure rather than an arithmetic failure, so this concept is about reading and designing that structure.
The standard rectangular layout is one row per observation (the thing being described) and one column per variable (a property recorded for every observation). A greenhouse study of a carbon-dioxide enrichment treatment might look like this:
plant_id | bench | co2_treatment | height_cm | leaf_count |
|---|---|---|---|---|
P001 | B1 | ambient | 14.2 | 7 |
P002 | B1 | ambient | 15.8 | 8 |
P011 | B2 | enriched | 17.3 | 9 |
P012 | B2 | enriched | 16.1 | 8 |
Six benches were used, ten seedlings grew on each bench, and the carbon-dioxide treatment was applied to a whole bench at a time. Three benches received ambient treatment and three received enrichment.
The table above is a four-row excerpt from the 60-row, five-column data set; its displayed rows are examples from that allocation. As the next section shows, the data set does not contain 60 independent pieces of evidence about carbon dioxide.
Variable types drive what you are allowed to do
- Categorical (nominal): unordered labels, such as co2_treatment or blood type. Summarize with counts and proportions.
- Categorical (ordinal): ordered labels with unequal or unknown spacing, such as a lesion grade of mild / moderate / severe. Order is meaningful; differences are not.
- Quantitative (discrete): counts such as leaf_count. Whole numbers, with a meaningful zero.
- Quantitative (continuous): measured amounts such as height_cm. Values can vary throughout their feasible range (for example, height is nonnegative); instrument precision limits the resolution of recorded measurements.
Storing a category as a number does not make it quantitative.
If you code ambient as 0 and enriched as 1, the mean of that column is just the proportion enriched; if you code three blood types as 1, 2 and 3, the mean is meaningless. Ask what the number represents, never what type the spreadsheet assigned.
The unit of analysis, and why it is often not the row
The experimental unit is the smallest thing that was independently assigned to a treatment. The observational unit is the thing you measured. When one treatment is applied to a whole group, these differ.
In the greenhouse study, carbon dioxide was set per bench, so the experimental unit is the bench: three benches received ambient treatment and three received enrichment, giving 3 independent replicates per group.
The ten seedlings on a bench share a watering line, a light gradient and a microclimate, so their heights may be correlated.
Analyzing all 60 seedlings as independent observations - pseudoreplication - counts seedlings within each bench as separate treatment replicates even though treatment was assigned to benches.
Under the usual equal-cluster model with ten seedlings per bench, the design effect is 1 + 9ρ; it equals 1 at zero within-bench correlation and exceeds 1 when that correlation is positive.
Thus treating seedlings as independent can understate uncertainty when within-bench correlation is positive; the six benches remain the independently assigned treatment units, three per treatment, and a bench-level fluke can look like a carbon-dioxide effect.
The honest structural fix is to summarize to the experimental unit (one bench mean per bench, so 6 numbers) or to use a model that carries the bench as a grouping factor.
Either way, the number of independent units is set by how the treatment was assigned, not by how many measurements you were able to take.
True replication means independently assigned units receiving the same treatment. Technical replication (three qPCR wells from the same extract, two height readings on the same plant) measures instrument and handling noise. Technical replicates are useful for quality control.
For a simple unit-level analysis, they are commonly averaged; alternatively, they may be retained in a model that represents their nesting. Either way, they must not be counted as independent biological or experimental units.
Selection: how observations get into the study
- Population - everything you want to describe. Sampling frame - the list you can actually draw from. A gap creates undercoverage, so generalization to people missing from the frame is not automatic; suitable external population information and assumptions can sometimes support weighting or modeling adjustments.
- Simple random sample: for a fixed sample size, every possible sample of that size has equal probability of selection. Equal inclusion probabilities for individual members follow from this design.
- Stratified sample: split the frame into strata (for example, sex or site), then sample within each. Guarantees representation of small strata and usually gives more precise estimates when strata differ.
- Cluster sample: sample whole groups (clinics, ponds, litters) and measure within them. Analysis must account for how groups were selected and for within-cluster correlation; the information lost relative to independent sampling depends on that correlation and the design.
- Convenience sample: whoever is available. Cheap and common, and the source of most non-generalizable results.
Assignment: randomization, controls and confounding
A confounder here is a pre-treatment factor related to treatment selection and outcome risk that can distort the treatment comparison.
If enriched benches sit nearer a window and light affects plant growth, light may confound the comparison because it is related both to which benches receive enrichment and to the outcome.
When treatment and light are completely confounded, their contributions cannot be separated from these data alone. If light is measured adequately and treatment groups have overlapping light exposure, adjustment may estimate their separate associations, subject to the model assumptions.
Random assignment addresses measured and unmeasured baseline confounding in expectation by balancing prior characteristics across arms on average.
It is not magic on a single small study - one randomization can still land unbalanced - which is why blocking or stratified randomization is used when a strong prognostic factor is known in advance.
Other causal designs, such as a valid instrumental-variable design or regression discontinuity, can also address unmeasured confounding under their specific identifying assumptions.
Random selection and random assignment answer different questions. Random selection from a frame supports generalizing to the population it was drawn from (external validity). Random assignment within whatever sample you have supports a causal claim about the treatment (internal validity). A study can have either, both or neither.
Controls give the comparison meaning: a negative control (vehicle, sham procedure) shows the response without the active factor; a positive control shows the assay can detect a response at all. Blinding of participants, handlers and outcome assessors protects against expectation effects, and matters most when the outcome involves any human judgement.
From structure to an analysis plan
The plan should fall out of the structure, and it should be written before the data arrive. Read the structure in this order: what is the outcome variable and its type; what is the grouping or predictor structure; what is the independent unit; are the groups independent or paired within a unit.
Structure | Plan family |
|---|---|
Continuous outcome, two independently assigned groups | Compare two group means with an interval or test for independent groups |
Continuous outcome, same unit measured before and after | Compare the within-unit differences as a single paired sample |
Binary outcome, two groups | Compare two proportions, or a risk or odds ratio |
Continuous outcome, three or more assigned groups | An overall grouped comparison is one option; prespecified pairwise contrasts need suitable multiplicity control, and contrasts selected after seeing results require particular caution |
Treatment assigned to clusters, measurement within clusters | Summarize to the cluster, or keep the cluster as a grouping factor in the model |
The details of each named procedure and its assumptions belong to the sibling concepts; what belongs here is recognizing which family the structure calls for, and refusing to pick the procedure after seeing which one gives the answer you wanted.
An aquaculture trial compares two feed formulations. Four tanks are available. Two tanks are randomly assigned to diet A and two to diet B, and the whole tank receives its assigned feed. Each tank holds 25 fish, and at the end of the trial every fish is weighed individually, giving 100 weights.
For comparing the two diets, how many independent experimental units does this design provide?
A university draws a simple random sample of 800 enrolled students from the registrar's complete enrolment list and sends each a survey; 512 respond. Among respondents, students who report using the drop-in tutoring centre have a mean grade point average 0.32 points higher than those who report never using it. A campus newsletter reports that the tutoring centre raises grade point average.
Which assessment of the newsletter's claim is most accurate?