Definition
Autocorrelation is correlation §15.44 between values of one series at different positions in time: knowing one value changes what is expected of the values near it. Events recorded during one boot of a device, one run of its software from a power-on or reset until the next, are usually correlated with each other because they share that boot’s conditions. Pseudoreplication §11.6 is the error of analyzing such events as independent repetitions, which overstates the evidence and understates the uncertainty. The cure is to count and resample the independent units: whole boots.
The idea
A test starts a device 5 times, and during each boot a logger records the duration of one operation 200 times, which gives rows. The 200 rows of one boot share that boot’s conditions: the state the software reached while starting, the temperature of the chip, the contents of the processor’s caches (small, fast memories that keep recently used data) and the background work running at the same time. If boot 3 happens to run slow, its 200 rows are slow together.
The usual question is how long the operation takes on a boot of this device. For that question the table holds 5 independent observations, each measured in great detail, not 1,000. A method that treats the rows as 1,000 independent draws behaves as if it had seen 1,000 boots. Its interval comes out far too narrow, and a difference between two conditions can look certain when it is only a difference between a few particular boots.
Weighing each of 5 apples 200 times is a fair picture. The readings fix the weights of those 5 apples precisely, but they say little more about apples in general than 5 careful readings would. The picture stops being accurate in one respect: repeated weighings of an apple differ only by the noise of the scale, while the events of one boot also vary for reasons of their own. The within-boot correlation measures the share of the variation that the events of one boot have in common: 0 means none of it, 1 means all of it.
How it works
Six steps decide the resampling unit and use it.
Name the claim. Say what the result should generalize to: further boots of this one device, or other devices of the same model.
Count the levels. Write down how the data nest, for example 3 devices, 12 boots and 4,800 events.
Choose the unit. The resampling unit is the unit that was sampled independently at the level the claim generalizes over. Experimental design calls it the experimental unit §11.3, the thing that receives a condition as a whole. For a claim about boots of one device, the unit is the boot. For a claim about devices, it is the device with all of its boots.
Check for dependence. If the events of a boot were independent, the means of boots of events would scatter by about the within-boot standard deviation §11.14 divided by ; much more scatter shows shared conditions. Within one series, the autocorrelation at lag is the correlation between each value and the value positions later.
Resample whole units. The bootstrap estimates uncertainty by building many artificial data sets, each drawn at random with replacement from the data, and recomputing the statistic on each; the spread of the results estimates the uncertainty. It is valid only if the drawing copies how the data were collected. The cluster bootstrap §11.21 therefore draws whole boots and keeps the events of each drawn boot together.
Report both counts, for example 12 boots and 4,800 events, never a bare .
When there is only one long series and no independent units, such as the events of one long boot, the block bootstrap applies. It cuts the series into consecutive blocks of events, draws blocks with replacement and joins them into an artificial series of the original length. Each block keeps the dependence between neighboring events, so must exceed the distance over which events stay noticeably correlated, a choice to justify from the measured autocorrelation. The result describes the variation within that one series, not the variation across boots.
When the data have several levels, resample the top-level units that the claim is about and keep everything inside each of them together. A unit drawn whole already carries the variation of the levels below it. With few such units no resampling works well: 2 boots allow only 3 distinct artificial data sets (boot 1 twice, boot 2 twice, or one of each).
Worked example
Take 2 boots with 2 events each, 4 rows in all. Each event has a variance of 1, where the variance is the average squared distance of a value from its mean. Events of the same boot have correlation 0.5, and events of different boots correlation 0. Their covariance, the correlation times the product of the two standard deviations (the square roots of the variances), is therefore within a boot and 0 across boots.
The variance of the sum of the 4 rows is the sum of their variances, , plus the covariance of every ordered pair of different rows. Each boot has one pair, counted in both orders, so the covariances add , and the sum has variance . The mean is the sum divided by 4, so its variance is . Treating the rows as independent drops the covariances and gives . The standard error §11.15, meaning the standard deviation of the mean, is therefore , not . The ratio is called the design effect, and is the effective sample size: the number of independent rows that would carry the same information about the mean.
At a larger size the error grows. Take 10 boots of 100 events each, 1,000 rows, with a within-boot correlation of 0.3. The design effect is , the effective sample size is , and the true standard error is about times the one a row-level analysis reports. A bootstrap that draws single rows makes the same mistake. Each artificial data set it builds holds rows of all 10 boots in nearly the original proportions, so the row bootstrap captures too little of the variation due to sampling boots.
Stated precisely
Let a data set consist of boots with events each, events in all. Assume that every event has the same variance , that any two events of the same boot have the same correlation , and that events of different boots are uncorrelated. Then the mean of all events has variance The factor is the design effect, and is the effective sample size. With the number of boots fixed and , the variance approaches , not 0, as grows: more events per boot cannot push the uncertainty below the level set by the number of boots.
Call one long series stationary if its mean, its variance and its correlation at each lag stay the same along the series. Let be the autocorrelation at lag . For a stationary series of values with variance , If each value is correlated with the previous one by , with , and the correlation fades geometrically with distance, , the bracket approaches for large . With that is : the series carries as much information about its mean as a third as many independent values.
A bootstrap estimate of uncertainty is justified when the resampled units are independent draws from one common distribution, are the units the claim generalizes over, and are numerous enough for their spread to be estimated. Resampling dependent units, such as the events of one boot, leaves their covariances out of the variance.
Limits and common mistakes
The formulas assume the same correlation for every pair of events in a boot, equal boot sizes and uncorrelated boots. Real boots differ in length, early events can behave differently from later ones during a warm-up §11.27 period, and correlation can fade with the distance between events.
Boots are not automatically independent. Boots of one device share that device, so for a claim about devices they are pseudoreplication. Boots run one after another can share a slowly changing condition, such as a room that warms up during a long test session.
Resampling cannot create units that were never collected. With few boots every interval, whether it comes from a bootstrap or from a formula, is wide or unreliable. The remedy is more boots.
A sample autocorrelation near 0 does not prove independence. The estimate is itself noisy, and correlation detects only straight-line association.
More events per boot describe each boot more precisely and show the variation inside a boot. They do not replace boots when the question is about the variation between boots.
Questions answered
What is the right resampling unit?
The right resampling unit is the unit that was sampled independently at the level the claim is about, drawn whole with everything recorded inside it. Resampling here means the bootstrap: estimating uncertainty by recomputing a statistic on many artificial data sets, each drawn at random with replacement from the data. For a claim about boots of a device, with the boots run independently, draw whole boots and keep the events of each drawn boot together. For a claim about devices, draw devices with all of their boots. For one long series without independent units, draw blocks of consecutive events (the block bootstrap), with a block length justified by how far the correlation between events reaches.
Drawing single events is wrong when the events of one boot share conditions and are therefore correlated: each artificial data set then mixes all boots in nearly the original proportions, the bootstrap understates how much the mix of boots would vary in a new experiment, and the interval comes out too narrow. With 10 boots of 100 events and a within-boot correlation of 0.3, the true standard error is about 5.5 times what row-level resampling reports. Report both counts, such as 10 boots and 1,000 events.
Related entries: Pseudoreplication (§11.6), Standard error (§11.15), Cluster bootstrap (§11.21), Correlation and covariance (§15.44), Bootstrap (§11.19), Experimental unit (§11.3).