This sheet follows the twelve units of the course in order. Each unit starts with the big idea in a few sentences, then gives the definitions, formulas, rules and procedures you will look up most often, with the conditions they need. When you want the full explanation, a derivation or more examples, follow the lesson links under each topic.
Population quantities, called parameters, are the population mean , the population proportion and the population standard deviation . The matching sample statistics are the sample mean , the sample proportion and the sample standard deviation , which divides by . A capital letter such as names a random variable and a lowercase letter an observed value, so is the sample mean before the data are collected and is its observed value. Probabilities are written and , and a random variable has expected value , variance and standard deviation . The standard error of a statistic is the standard deviation of its sampling distribution, and is an estimate of it computed from the data.
A normal distribution is written with its variance, stands for a standard normal variable and for its CDF. Quantiles are lower-tail quantiles. The quantile of is , so , and , and are the quantiles of the , and distributions, whose subscripts , and are degrees of freedom. A two-sided 95 percent procedure therefore uses . Hypotheses are and , and is the significance level unless a topic gives it another meaning. Logarithms are natural logarithms, and marks a rounded or approximate value.
Statistical Thinking and Data
Statistics starts with a question about a group and a clear idea of what each recorded value means. A number computed from data describes the units that were observed, and a statement about any other units needs an argument about how the data were produced.
Populations, samples, parameters and statistics
A statistical question asks about a defined collection of units and expects the answers to vary from unit to unit. The observational unit is the person, thing or event that one row of data describes. The population is the complete set of units the question is about, of size , and a sample is the part of it on which data are collected, of size . A census collects data on every unit.
| Quantity | Population parameter | Sample statistic |
|---|---|---|
| Mean | ||
| Proportion with a property | when of the units have it | |
| Standard deviation |
For a fixed population a parameter is one number, usually unknown. A statistic is known once the data are in, but its value changes from sample to sample, which is sampling variability, and for one sample the difference is its sampling error. Descriptive statistics summarizes the data at hand. Inferential statistics draws conclusions about a larger population, a process or a cause, with a statement of uncertainty, and that step needs random sampling, random assignment or a model for how the data arose.
For example, six waits of 2, 3, 4, 5, 7 and 9 minutes have minutes, and two of the six exceed 6 minutes, so . Six other visits from the same population would usually give other values.
Lessons Introduction to Statistics
Variables and levels of measurement
A variable is a characteristic recorded for each unit. A categorical variable places a unit in one of several categories, and a numerical variable records an amount in stated units, so that differences and averages of its values are amounts of the same thing. Identifiers and numeric codes for categories stay categorical. A numerical variable is discrete when its possible values form a finite or countable list, such as counts, and continuous when, in the model used, it can take any value in an interval.
| Level | Values | Comparisons that make sense | Example |
|---|---|---|---|
| Nominal | categories without an order | same or different, counts, proportions, mode | blood type |
| Ordinal | ordered categories | also order and ranks, but not the sizes of the steps | rating from poor to excellent |
| Interval | numbers in equal units with an arbitrary zero | also differences and means | temperature in degrees Celsius |
| Ratio | an interval scale whose zero means none of the quantity | also ratios | waiting time in minutes |
An operational definition says exactly how a value is obtained, including the instrument, the units, the recording resolution and how a missing value is marked. Accuracy is closeness to the true value, and precision is agreement among repeated measurements. A binary indicator is for a unit that meets a condition and otherwise, and the mean of the indicators is the proportion of units that meet it.
Ratios fail on an interval scale. The temperatures and degrees Celsius are and degrees Fahrenheit, and , not . Differences convert consistently, since a change of Celsius degrees is always a change of Fahrenheit degrees.
Lessons Types of Data and Measurement
Data tables and data quality
A data table gives each observational unit a row and each variable a column. The data dictionary records each variable’s meaning, units, allowed values and missing-value code, and the provenance records who produced the data, how the units were selected and how the file reached the analyst. The raw data stay unchanged, and every edit goes into a dated data cleaning log with its reason.
- Missing values. A missing value is not zero. Four observed values totaling 105 have mean , while recording a fifth, missing value as zero gives , an average that includes a value nobody measured.
- Duplicates. A duplicate record is the same unit on the same occasion entered more than once. Equal values alone do not show that two records are duplicates.
- Outliers. An outlier lies unusually far from the bulk of the data. It is a reason to check the value, not evidence of an error, since it can be a mistake, a unit from outside the population or a genuine extreme.
| Missingness mechanism | The chance that a value is missing | Mean of the complete cases |
|---|---|---|
| Missing completely at random | depends on none of the data | no systematic error, only less precision |
| Missing at random | depends only on recorded variables | can be biased, and methods that use those variables can correct it under this assumption |
| Missing not at random | depends on the missing value itself, even given the recorded variables | can be biased, and the data alone cannot show by how much |
A complete-case analysis drops every record with a missing value on the variables it needs, so its results describe the complete cases. They answer a question about all the intended units only under an assumption about the mechanism.
Lessons Data Tables, Missing Values and Data Quality
Describing and Exploring Data
Tables, graphs and a few numbers describe what a set of data shows. Center, spread, position and shape summarize one variable, while scatter plots, correlation and two-way tables describe how two variables vary together. Each summary answers a particular question, so the question and the shape of the data decide which one to use.
Frequency tables and categorical charts
The frequency of a category is its count. When the categories are mutually exclusive and exhaustive, the frequencies add to , and the relative frequency of a category with frequency is . A bar chart draws one bar per category, separated by gaps, with lengths measured from a baseline at zero. A contingency table cross-classifies two categorical variables, its row and column totals are the margins, and a conditional percentage uses one row or one column as its denominator.
For example, if 12 of 25 people use the bus and 8 of the 10 people in group A do, then 80 percent of group A use the bus, while group A makes up percent of bus users. The two percentages have different denominators and answer different questions.
Cumulative frequencies are meaningful only for ordered categories or numerical values. In a multiple-response question a respondent may choose several categories, so the percentages of respondents can add to more than 100 percent.
Lessons Frequency Tables and Categorical Charts
Dot plots, histograms and distribution shape
A dot plot shows one dot per observation. A histogram divides an interval containing the data into adjacent bins and draws touching bars. When the bins have different widths, the height of each bar must be its frequency density, so that areas show counts. A bin of width holding observations gets
and dividing by as well gives bars with total area . A bin from 0 to 2 and a bin from 2 to 8 that each hold 6 observations have heights and and equal areas.
Describe a distribution by its shape, center, spread and unusual values. It is skewed to the right when its right tail stretches much farther from the bulk than its left tail, and its modality is the number of clear peaks. The apparent shape can depend on the choice of bins, especially in a small sample.
Lessons Dot Plots, Histograms and Distribution Shape
Center
| Measure | Definition | Properties |
|---|---|---|
| Mean | balance point with , pulled toward extreme values | |
| Median | the middle ordered value, or the average of the two middle values when is even | resistant to a few extreme values |
| Mode | the most frequent value or category | can be several, and the only one of the three for nominal data |
| Weighted mean | with and | combines group means when the weights are the group sizes |
The values 2, 3, 4, 5 and 16 have mean 6 and median 4. Changing 16 to 26 moves the mean to 8 and leaves the median at 4. Combining groups of 2 and 8 people with means 10 and 20 gives the overall mean , not the unweighted average 15.
Lessons Mean, Median, Mode and Weighted Averages
Variance and standard deviation
For all values of a finite population with mean , and for a sample of values with mean ,
The standard deviations and are the nonnegative square roots, in the units of the data, while variances are in squared units. A standard deviation is exactly when all the values are equal. The sample variance divides by the degrees of freedom because the deviations from add to zero, and for independent observations from a population with variance this gives .
The values 2, 4, 6 and 8 have mean 5 and squared deviations adding to 20. As a whole population they have and , and as a sample and .
Lessons Variance and Standard Deviation
Percentiles, quartiles and box plots
A th percentile has about percent of the data below it. Sample percentiles need a stated rule, and the common rules can disagree in small samples. Under the median-of-halves rule, and are the medians of the lower and upper halves of the ordered data, with the middle value left out of both halves when is odd. Then
The five-number summary lists the minimum, , the median, and the maximum. A box plot draws a box from to with a line at the median. In the modified box plot the whiskers stop at the most extreme values that are not beyond the fences and , and values below or above are drawn as points and flagged as potential outliers.
Two more resistant summaries are the median absolute deviation, for the median , and the trimmed mean, which drops the smallest and the largest values, with , and averages the rest. Some software multiplies the MAD by about , so a report says which version it gives.
For delays of 1, 2, 3, 4, 5, 6, 7 and 20 minutes, , the median is and , so the IQR is 4 and the fences are and . Only the delay of 20 minutes is flagged. The mean is 6, while the MAD is 2 and the mean trimmed by one value at each end is .
Lessons Percentiles, Quartiles and Box Plots
Z-scores and changes of scale
The z-score of a value relative to a distribution with mean and standard deviation is
and for a sample and take the places of and . It counts standard deviations above or below the mean, and standardized data have mean and standard deviation . For a linear transformation of every value,
| Summary | Effect |
|---|---|
| Mean and median | , and the median changes the same way |
| Standard deviation and IQR | multiplied by |
| Variance | multiplied by |
| z-scores | unchanged when , sign reversed when |
A shift alone changes no measure of spread. Temperatures with mean 20 and SD 5 degrees Celsius have mean and SD in degrees Fahrenheit, and 30 degrees Celsius, which is 86 degrees Fahrenheit, has on both scales.
Lessons Z-Scores and Changes of Scale
Comparing distributions and reading graphs
Compare groups on a common scale, looking at center, spread, shape, unusual values and the number of observations behind each group. The length of a bar must start from a meaningful baseline, normally zero. For a change from to , with for the relative change,
A change between two percentages is measured in percentage points, so a rise from 10 percent to 15 percent is 5 percentage points and a relative increase of 50 percent. Counts compare groups only when the denominators match, and 20 events among 1000 people and 80 among 2000 are rates of 2 and 4 percent. Graphs mislead through truncated baselines, side-by-side panels on different scales, unequal histogram bins drawn with frequency heights, uneven time axes and icons enlarged in both directions.
Lessons Comparing Distributions and Reading Graphs
Scatter plots, covariance and correlation
For pairs measured on the same individuals, the sample covariance and the Pearson correlation are
The covariance is in the product of the two units. The correlation needs and , has no units and satisfies , with exactly when all the points lie on one straight line, rising for and falling for . It does not change when either variable is shifted or multiplied by a positive constant, and it changes sign when one variable is multiplied by a negative constant.
Correlation measures only linear association. The points , and lie exactly on the curve and have . A single influential point, or data that cover only part of the range of a variable, can change a lot. The Spearman rank correlation is the Pearson correlation of the ranks, with tied values given the average of their ranks, and it measures monotonic association. Neither coefficient shows that one variable causes the other.
Lessons Scatter Plots, Covariance and Correlation
Two-way tables and Simpson’s paradox
The aggregated proportion of a group is a weighted average of its subgroup proportions, each weighted by that subgroup’s share of the group’s cases,
Simpson’s paradox occurs when an association has the same direction in every subgroup but reverses or disappears once the subgroups are combined. It can happen only when the groups being compared are spread differently over the subgroups.
| Easy cases | Hard cases | All cases | |
|---|---|---|---|
| Service A | |||
| Service B |
Service A has the higher success rate for both kinds of case and the lower rate overall, because most of its cases are hard. A standardized rate applies one fixed mixture of subgroups to every group. With half easy and half hard cases, A scores and B scores . Which comparison answers the question, and whether the subgroup variable is a confounder, depends on the causal setting, not on the arithmetic.
Lessons Two-Way Tables and Simpson’s Paradox
Collecting Trustworthy Data
How data are collected decides which conclusions they can support. A biased selection stays biased however large the sample, random sampling supports generalizing to the population that was sampled, and random assignment supports conclusions about cause and effect.
Sampling bias and representativeness
The target population is the set of units a study wants to describe, and the sampling frame is the list or procedure from which units are actually selected. Selection bias is a systematic difference between the analyzed units and the target population, and a larger sample from the same process does not remove it.
| Source | What goes wrong |
|---|---|
| Undercoverage | part of the target population is missing from the frame or cannot be reached |
| Nonresponse | selected units do not respond, and responders differ from nonresponders |
| Voluntary response | people select themselves, often those with strong views |
| Measurement bias | question wording, the interviewer, the wish to give an acceptable answer or a faulty instrument shifts the recorded values |
If a share of the target population is covered, with , proportion among the covered units and among the others, then
The error is the uncovered share times the gap, whatever the sample size. With , and , the target proportion is and the covered units overstate it by . The same calculation applies to nonresponse, with respondents in place of covered units. A sample is representative for a question when its selection and measurement give no systematic tendency to misstate the answer, which is a property of the process, not of how one sample looks.
Lessons Sampling Bias and Representativeness
Random sampling methods
A probability sample gives every unit of the frame a known, positive inclusion probability , and the design weight of a sampled unit is .
| Design | How units are selected | Inclusion probability |
|---|---|---|
| Simple random sample | every set of of the units is equally likely | |
| Stratified | a separate simple random sample of units from each stratum of units | in stratum |
| Cluster | a probability sample of whole groups, observing all units in each | the probability that the unit’s cluster is chosen |
| Systematic | a start chosen with equal probabilities from to , then every th unit of the list |
With unequal inclusion probabilities, estimate a proportion by the weighted proportion , where both sums run over the sample and is a 0/1 indicator. Sampling 10 of 20 units in one stratum and 10 of 80 in another gives weights 2 and 8. If 8 and 2 of the sampled units have the property, the weighted proportion is , while the unweighted overrepresents the small stratum.
The design effect of an estimator compares its variance under the design with its variance under simple random sampling of the same size from the same frame,
and is the effective sample size. Stratifying on a variable related to the response often brings it below 1, and sampling clusters of similar units often pushes it above 1, but the value depends on the population, the estimator and the variable measured.
Lessons Random Sampling Methods
Observational studies, confounding and causation
In an observational study the researcher records the explanatory variable and the response but does not assign the explanatory variable. For a unit with potential outcomes under treatment and under control, the causal effect is , and at most one of the two outcomes is ever observed, so is never observed directly. An association between the explanatory variable and the response can come from
- a causal effect of the explanatory variable,
- confounding, a factor associated with the explanatory variable that also affects the response,
- reverse causation, where the response or an early stage of it affects the explanatory variable,
- selection, when entry into the analysis depends on both variables,
- chance variation.
Adjusting for a measured confounder, for example by comparing units with similar values of it, removes confounding by that variable only as far as the compared units really are similar, and unmeasured confounders remain.
Lessons Observational Studies, Confounding and Causation
Randomized experiments
In an experiment the investigator assigns treatments to experimental units, the entities that can receive different treatments. Random assignment by a chance mechanism balances measured and unmeasured characteristics on average over the possible assignments, which supports a causal comparison of the treatments for the units studied.
- Control and placebo. A control group receives a comparison condition, and a placebo imitates the treatment without its active component.
- Blinding. Some or all of the participants, the staff delivering treatments and the people assessing outcomes are kept from knowing the assignments, and a report says exactly who was blinded.
- Replication. Each treatment goes to several experimental units. Repeated measurements of one unit are not replicates.
- Blocking. Treatments are randomized separately within blocks of similar units and compared within blocks, which keeps block differences out of the comparison. A matched pairs design uses blocks of two and analyzes the within-pair differences.
| Random assignment | No random assignment | |
|---|---|---|
| Random sample | causal conclusion that extends to the sampled population | association that extends to the sampled population |
| No random sample | causal conclusion for the units studied | association among the units studied |
Lessons Randomized Experiments, Blocking and Matched Pairs
Probability Models for Statistics
Probability describes chance through a model, and statistical inference rests on such models. The rules for events lead to conditional probability and Bayes’ theorem, random variables turn outcomes into numbers, and a few standard distributions model counts, waiting times and measurements.
Probability rules, conditioning and independence
A sample space contains all possible outcomes, an event is a set of outcomes, and a probability model gives each event a number with , and the probabilities of disjoint events adding. When a finite sample space has equally likely outcomes, is the number of outcomes in divided by the number in .
| Rule | Formula | Condition |
|---|---|---|
| Complement | any event | |
| Addition | any two events | |
| Disjoint events | ||
| Conditional probability | ||
| Multiplication | ||
| Independence | the definition | |
| Total probability | disjoint and exhaustive, each |
When , independence means . Disjoint events with positive probabilities are never independent, since one rules out the other. For a fair die, the events and give , and since differs from , they are not independent. In repeated independent trials the relative frequency of an event tends to its probability, which is the long-run reading of probability.
Lessons Probability Rules and Events, Conditional Probability and Independence
Bayes’ theorem and base rates
For a condition with and a positive test result, written , with ,
| Term | Probability |
|---|---|
| Base rate or prevalence, the prior | |
| Sensitivity | |
| Specificity | |
| False-positive rate | |
| Positive predictive value | |
| Negative predictive value |
The predictive values depend on the base rate as well as on the test. With base rate , sensitivity and specificity , natural frequencies for 1000 people give 90 true positives and 45 false positives, so . With a base rate of the same test gives . Reading the sensitivity as if it were ignores the base rate.
Lessons Bayes’ Theorem and Base Rates
Counting and sampling without replacement
If a procedure has stages with possible results at the successive stages, whatever happened before, it has possible results in all. For whole numbers , with ,
| Selections of from distinct objects | Number |
|---|---|
| Ordered, with replacement | |
| Ordered, without replacement | |
| Unordered, without replacement |
Draws without replacement are dependent. From 8 items of which 3 are marked, a sample of 3 drawn without replacement, with every set of 3 equally likely, contains exactly 2 marked items with probability , and no marked item with probability , not the that independent draws with replacement would give.
Lessons Counting and Sampling Without Replacement
Random variables, expected value and variance
A random variable assigns a number to each outcome. A discrete random variable has a probability mass function whose values are nonnegative and add to 1 over its support, the set of values with positive probability. Every random variable has a cumulative distribution function , which never decreases and runs from 0 to 1, and for .
For a discrete with mean ,
provided is finite for the mean and is finite for the variance, and .
| Rule | Condition |
|---|---|
| finite means, independence not needed | |
| finite variance | |
| finite variances | |
| finite variances | |
| finite variances, and uncorrelated, for example independent | |
| and independent with finite means |
For uncorrelated variables the variances add for differences too, while standard deviations do not add. If is or with probabilities and , then , and . For an independent copy of , , while .
Lessons Discrete Random Variables and Probability Distributions, Expected Value, Variance and Sums of Random Variables
Models for counts
| Model | Mean | Variance | |
|---|---|---|---|
| for , for | |||
| for | |||
| Hypergeometric | |||
| for |
Each model needs its setting.
- Binomial. The number of successes in independent trials, with fixed in advance and the same success probability in every trial.
- Hypergeometric. The number of marked items in a uniformly random sample of drawn without replacement from items, of them marked. Its possible values are the whole numbers from to , and the variance formula needs . When is a small fraction of it is close to .
- Poisson. The number of events that occur one at a time, independently in nonoverlapping intervals, at a constant rate , counted over an exposure , so that is an expected count, not a rate. Counts whose variance clearly exceeds their mean are overdispersed relative to this model.
For , . With events per minute over 10 minutes, , and .
Lessons Bernoulli, Binomial and Hypergeometric Models, Poisson Models for Event Counts
Continuous distributions
A continuous random variable has a density with and total area under its graph, and probabilities are areas, so for
Each single value has probability , so and give the same probabilities. A density value is not a probability and can exceed , and its units are the reciprocal of the units of .
| Model | Density | Mean | Variance |
|---|---|---|---|
| Uniform on with | for | ||
| Exponential with rate | for |
An exponential waiting time has survival probability for . It is the wait for the first event of a Poisson process with rate , and it is memoryless, for all . With per minute, and .
Lessons Continuous Distributions, Density and Cumulative Probability
Normal distributions and quantiles
The normal distribution with has the density
which is symmetric about with inflection points at . If , then , so
If is normal and , then is normal, and a sum of independent normal variables is normal.
For every normal distribution the probabilities within 1, 2 and 3 standard deviations of the mean are about , and . This empirical rule describes the normal model, and for other shapes it can be far off. For , and the quantile is .
Lessons Normal Distributions and Quantiles
Normal approximations and their limits
For with , the normal approximation replaces by , and the continuity correction treats each whole number as the interval from to .
| Exact probability | Approximation |
|---|---|
The success-failure condition asks for and , and some texts use 5 or 15 instead. It is a rule of thumb, not a bound on the error. For and the approximation gives , which matches the exact value to four decimals. For and it gives , while the exact value is . Near or , and far in the tails, use the exact binomial probability.
Lessons Normal Approximations and Their Limits
Simulation and Monte Carlo error
A simulation generates outcomes from a fully specified probability model. To estimate a probability from independent replications, record the indicator of the event in replication . The estimate and its Monte Carlo standard error are
with in place of to estimate the MCSE. It shrinks like , so four times as many replications halve it. When no replication shows the event, or every one does, the estimated MCSE is , which does not mean the estimate is exact. A run that finds the event for in 420 of 10000 replications gives with an estimated MCSE of about , and the exact value is about . Record the model, the generator, the seed and so that the run can be repeated exactly. More replications reduce Monte Carlo error but leave model error, the mismatch between the model and the real process, unchanged.
Lessons Simulation and Monte Carlo Error
Sampling Distributions and Estimation
A statistic varies from sample to sample, and its sampling distribution describes how. The standard error measures that variation, the law of large numbers and the central limit theorem describe sample means in large samples, and together these ideas lead to estimators, confidence intervals and sample-size plans.
Sampling distributions and standard errors
The sampling distribution of a statistic is its distribution over repeated samples of the same size, drawn by the same design from the same population. It is a different object from the population distribution and from the distribution of the values in one sample. Its standard deviation is the standard error, which describes how much the statistic varies, while the SD of the data describes how much individual values vary.
| Statistic | Mean | Standard error | Conditions |
|---|---|---|---|
| independent observations with mean and SD | |||
| from a simple random sample | without replacement from units, with divisor | ||
| independent trials with success probability | |||
| independent samples | |||
| independent samples |
The parameters in these formulas are usually unknown, and the estimated standard errors use and in their place, as in . The factor is the finite population correction for the variance, close to when the sample is a small fraction of the population, and it multiplies the variance of in the same way. Quadrupling halves a standard error, so with the SE of the mean is for and for .
Dependence changes the standard error. For independent clusters of observations, each with variance and with correlation between observations in the same cluster, with , the design effect and the effective sample size . With 100 readings in clusters of 10, and , the design effect is , the SE is about instead of , and the effective sample size is about .
Lessons Sampling Distributions of Means and Proportions, Standard Deviation and Standard Error
The law of large numbers and the central limit theorem
Let be independent and identically distributed with mean and variance , and let be the mean of the first of them.
Law of large numbers. When is finite, for every the probability tends to as , and Chebyshev’s inequality bounds it by . For independent and identically distributed observations a finite mean is already enough. Averages settle by dilution, not by compensation, so a run of one outcome does not make the other outcome more likely on the next trial, and expecting it to is the gambler’s fallacy.
Central limit theorem. When , for every real number
as , so for large the sample mean is approximately . For a normal population this holds exactly for every . No single sample size, such as 30, is enough for every population, because skewness and heavy tails slow the approach, especially for tail probabilities. Without a finite variance the theorem can fail, and the mean of independent standard Cauchy variables has the same standard Cauchy distribution for every .
The law of large numbers says where the mean settles, and the central limit theorem describes the shape and size of its fluctuations. Neither one describes the shape of the data in a single sample. Independent exponential waits with mean 2 minutes have SD 2 minutes, so the mean of 100 waits has , and , while the exact value is about .
Lessons The Law of Large Numbers, The Central Limit Theorem
Student’s t, chi-square and F distributions
| Distribution | Construction | Properties |
|---|---|---|
| for independent standard normal | nonnegative, mean , variance , right-skewed | |
| with independent and | symmetric about , heavier tails than , close to for large | |
| with independent and | nonnegative, right-skewed, |
If , then . For independent observations from , the sample mean and the sample variance are independent, and
Degrees of freedom belong to the construction, so they are not always . A critical value is a quantile used as a cutoff, such as , and . The t critical values for two-sided 95 percent procedures are
Lessons Student’s t, Chi-Square and F Distributions
Estimators, bias and mean squared error
An estimator is a rule that computes a value for a parameter from the data, and an estimate is the value it gives for the data actually observed. Its properties describe its behavior over repeated samples,
An estimator is unbiased when its bias is 0 for every allowed , and consistent when it converges in probability to as grows. For independent observations from one population with finite variance, is unbiased for and is unbiased for , while , so tends to underestimate . A small bias can be worth a large drop in variance. An unbiased estimator with variance 4 has MSE 4, while one with bias 1 and variance 1 has MSE 2.
Lessons Estimation, Bias, Precision and Mean Squared Error
Likelihood and maximum likelihood
For a model with parameter and fixed observed data, the likelihood is the probability of the data under , or their density for continuous data, read as a function of . It is not a probability distribution for . The ratio compares how well two values account for the data. The maximum likelihood estimate maximizes , or equivalently the log-likelihood , and for independent observations the likelihood is a product and the log-likelihood a sum.
Six successes in eight independent Bernoulli trials give , which is largest at , and . With no successes the maximum is at the boundary value , although small positive values of remain compatible with the data.
Lessons Likelihood and Maximum Likelihood Estimation
Confidence intervals
An interval procedure has confidence level when for every allowed value of , with the probability taken over repeated samples while stays fixed. Some procedures reach this only approximately, and some guarantee at least . Once the data are in, a computed interval either contains or does not, so a 95 percent confidence level describes how often the procedure captures , not the probability that this particular interval does. Many intervals have the form estimate critical value standard error. The margin of error, the half-width, reflects only random sampling error, not bias from selection, nonresponse or measurement.
| Target | Interval | Conditions |
|---|---|---|
| Mean, known | independent normal observations, approximate for large otherwise | |
| Mean | independent observations, exact for a normal population and approximate otherwise | |
| Proportion, Wald | binomial model, poor coverage for small or near or | |
| Proportion, Wilson | as below | binomial model, endpoints always inside |
| Proportion, Clopper-Pearson | the values of rejected by neither exact one-sided binomial test at level | binomial model, coverage at least for every |
The Wilson interval is the set of with , where . Solving gives the center and half-width ,
For , and minutes, the 95 percent t interval is minutes. For 12 successes in 20 trials the 95 percent intervals are about by Wald, by Wilson and by Clopper-Pearson. For no successes in 10 trials the Wald interval is the single point , while the Wilson and Clopper-Pearson upper limits are about and .
Lessons Confidence Intervals and Coverage, Confidence Intervals for a Mean, Confidence Intervals for a Proportion
Bootstrap standard errors and intervals
The nonparametric bootstrap uses the sample as a stand-in for the population. Draw resamples of size with replacement from the observed units, compute the statistic on each, and use
- the standard deviation of , with divisor , as the bootstrap standard error,
- the mean minus the observed statistic as the bootstrap estimate of bias,
- the and quantiles of the as the endpoints of the percentile interval.
Resample the units that were sampled independently, keeping pairs or clusters whole, and use blocks of consecutive values for a time series. The bootstrap cannot correct a biased sample, and it works poorly for very small samples and for statistics such as the sample maximum. For waits of 2, 3, 4, 5, 7 and 9 minutes, all resamples give a bootstrap distribution of the median with standard deviation about minutes and, taking each quantile as the smallest value whose cumulative probability reaches the level, a 95 percent percentile interval of minutes.
Lessons Bootstrap Standard Errors and Intervals
Sample size and margin of error
For a margin of error of at most with critical value , a proportion and a mean estimated from independent observations need
rounded up, with a planning value for or from a pilot study or earlier work. Since , the conservative choice works whatever the true is, and a planning SD that is too small gives a margin larger than intended. Halving roughly quadruples . Multiply by the design effect, round up at the end, and divide by the expected response rate to find how many units to invite. For at 95 percent with , , so 385 responses are needed, a design effect of raises this to 577, and an 80 percent response rate means inviting people.
Lessons Sample Size and Margin of Error
Hypothesis Tests and Two-Group Comparisons
A hypothesis test asks whether the data are compatible with a stated null model. The p-value measures how surprising the data would be if that model were true, and it is read together with an estimate of the effect and its interval.
Hypothesis tests and p-values
- State and about a parameter, and fix the test statistic, the direction that counts as extreme, the significance level and the sample size before looking at the outcome data.
- Find the null distribution, the distribution of the test statistic when and the model assumptions hold.
- Compute the p-value, the probability under the null model of a test statistic at least as extreme as the observed one.
- Reject when the p-value is at most , and otherwise fail to reject it. Report the estimate and an interval along with the p-value.
A p-value is not the probability that is true, and one minus the p-value is not the probability that is true. A one-sided test counts departures in one stated direction and a two-sided test counts both. For a symmetric null distribution the two-sided p-value is twice the smaller one-sided p-value, capped at 1, and for an asymmetric null distribution the rule for the two-sided p-value must be stated. Sixteen successes in 20 trials under give the one-sided p-value and the two-sided p-value .
Lessons Hypothesis Tests and P-Values
Type I and type II errors and power
| true | false | |
|---|---|---|
| Reject | type I error, probability at most | correct, with probability equal to the power |
| Fail to reject | correct | type II error, probability |
The power is computed at a specific alternative value. For a given test it usually grows with the true effect, the sample size and , and falls as the SD of the data grows. For the one-sided z test of against with known , the power at and the sample size for power are
With , , and power , , so 155 observations. The minimum detectable effect is the smallest effect at which a fixed design reaches the target power. Testing again and again as data arrive and stopping at the first significant result, which is optional stopping, raises the type I error rate above .
Lessons Type I Error, Type II Error and Power
Statistical significance and practical importance
Statistical significance says only that the data are hard to reconcile with . The effect size, the magnitude of the effect in its units, and its interval show whether the effect matters, judged against the smallest effect that would matter in practice, fixed in advance. A very large study can make a negligible effect significant, and a small study can leave an important effect nonsignificant. Failing to reject is absence of evidence, not evidence that the effect is zero.
| Study | Estimate | SE | 95 percent interval | Two-sided p-value |
|---|---|---|---|---|
| A | ||||
| B |
If effects below 1 unit do not matter, study A gives clear evidence of an effect that is too small to matter, and study B is inconclusive, compatible with no effect and with a large one. To show that an effect is negligible, choose an equivalence margin in advance and check whether the percent interval lies within , which is the two one-sided tests procedure.
Lessons Statistical Significance and Practical Importance
Randomization and permutation tests
Under a sharp null hypothesis, such as no treatment effect on any unit, every unit’s response would be the same under every assignment the design could have produced. A randomization test recomputes the statistic for every assignment the design allows, and when these are equally likely its p-value is the proportion of them, the observed one included, whose statistic is at least as extreme as the observed one. A permutation test applies the same idea to rearrangements of the data that leave the null distribution unchanged, such as relabeling two independent samples from one distribution. The allowed rearrangements must match the design, for example swaps only within pairs or blocks. When there are too many to list, draw of them at random, count the number at least as extreme as the observed statistic, and report
which keeps the type I error rate at most for every . With treated responses 4, 5 and 6 and control responses 1, 2 and 3, the difference in means is 3. Only the observed assignment and its mirror image, out of , reach an absolute difference of 3, so the two-sided p-value is .
Lessons Randomization and Permutation Tests
Tests for means and proportions
| Situation | Test statistic | Reference |
|---|---|---|
| One mean | ||
| Paired data with differences | for pairs | |
| Two independent means, Welch | with the Welch-Satterthwaite | |
| One proportion | ||
| Two proportions | with pooled |
Means. The t tests need independent observations, or independent pairs, and a sample mean that is close to normal, which holds exactly for a normal population and approximately for larger samples without strong skewness or outliers. Paired data are analyzed through the within-pair differences, never as two independent samples. Welch’s test does not assume equal variances, and its degrees of freedom are
The pooled two-sample t test assumes equal population variances and uses with degrees of freedom.
Proportions. The z tests need independent trials with a common success probability in each group, and expected counts of successes and failures under , such as and , of at least about 5 to 10. Otherwise use the exact binomial test for one proportion or Fisher’s exact test for two.
Tests and intervals. Each t test has a matching interval, estimate , and the two-sided test at level rejects exactly when the null value is not strictly inside that interval. The interval for uses the unpooled standard error , and the one-proportion test puts in its standard error, so for proportions the match between test and interval is only approximate. The standardized mean difference gives the effect in SD units, and .
Group A with , mean 18 and SD 4 and group B with , mean 22 and SD 6 give , and , a two-sided p-value of about and the 95 percent interval of about for . With 60 of 100 successes against 45 of 100, the pooled proportion is , , the two-sided p-value is about , and the 95 percent interval for is about .
Lessons One-Sample t-Tests, One-Proportion Tests, Comparing Two Independent Means, Paired t-Tests and Before-After Data, Comparing Two Proportions
Rank-based tests
| Test | Data | Null hypothesis | Statistic |
|---|---|---|---|
| Sign test | paired differences , or for one sample | the number of positive values among the nonzero ones, under given | |
| Wilcoxon signed-rank | paired differences | the distribution of is symmetric about | , the sum of the ranks of the over the positive |
| Wilcoxon rank-sum or Mann-Whitney | two independent samples | the rank sum of sample A in the pooled ranking, or |
Without ties, with nonzero differences and , the null means and variances are
In the usual versions zero differences are dropped, and tied values get the average of their ranks, which changes the exact null distribution and lowers the variance. The ratio estimates the probability of superiority for independent draws from A and from B. For continuous differences the sign test is a test that the median of is 0. The signed-rank test is a test about the median only under the added assumption of symmetry, and the rank-sum test compares medians only under a location-shift model .
For and , , and . Of the 20 equally likely ways to choose which three values carry the label A, 14 give , so the exact two-sided p-value is .
Lessons Sign Tests and Wilcoxon Signed-Rank Tests, Mann-Whitney Tests and Rank-Based Comparisons
Categorical Data Inference
Categorical outcomes are summarized by counts, proportions, risks and odds. Chi-square tests compare observed counts with the counts a model expects, exact tests handle small counts, and paired yes or no data need a test of their own.
Risk, odds and relative effects
Take a 2 by 2 table with outcomes and non-outcomes among the members of group A, and outcomes and non-outcomes among the members of the reference group B, with risks and .
| Measure | Definition | Estimate | No difference |
|---|---|---|---|
| Risk difference | |||
| Risk ratio | |||
| Odds ratio |
The odds of an outcome with probability are , and . For risks strictly between 0 and 1 with , the odds ratio exceeds the risk ratio, which exceeds 1. The gap between them is small when both risks are small and can be large for a common outcome. A relative effect needs its baseline risk, since doubling a risk of adds 1 percentage point while doubling a risk of adds 20. A case-control study fixes the numbers of cases and controls, so it estimates the odds ratio but not risks, risk differences or risk ratios.
Intervals for ratios are built on the log scale. With all four counts positive,
and the interval for the risk ratio is , with the same form for the odds ratio. With 20 of 100 people in group A and 10 of 100 in group B having the outcome, the risk difference is , the risk ratio is 2 and the odds ratio is , and the 95 percent interval for the risk ratio is about .
Lessons Risk, Odds and Relative Effects
Chi-square tests
Every chi-square test compares observed counts with the counts expected under ,
and the approximate p-value is the upper tail .
| Test | Data | Expected count | Degrees of freedom | |
|---|---|---|---|---|
| Goodness of fit | one sample in categories | the category probabilities are , fixed in advance | , minus one for each parameter estimated from the counts by maximum likelihood | |
| Independence | one sample classified by two variables | the two variables are independent | for rows and columns | |
| Homogeneity | independent samples from several groups | every group has the same distribution over the categories | as for independence |
The approximation needs independent observations, raw counts rather than percentages, and large expected counts, commonly all at least 5. A Pearson residual shows which cells drive a large , and Cramér’s V,
measures the strength of association on a scale from 0 to 1. Counts of 28, 22, 18 and 12 tested against four equal probabilities have every , on 3 degrees of freedom and . A 2 by 2 table with counts 30, 20, 20 and 30 has every , on 1 degree of freedom, and .
Lessons Chi-Square Goodness-of-Fit Tests, Chi-Square Independence and Homogeneity
Fisher’s exact test and McNemar’s test
For a 2 by 2 table of independent units, Fisher’s exact test conditions on both margins. With first row total , first column total and grand total , the count in the top left cell has, under , the hypergeometric distribution
The common two-sided p-value adds the probabilities of all tables with these margins that are no more probable than the observed table. Because the distribution is discrete, the type I error rate of the test is at most and often below it. The table with rows and has two-sided p-value .
For paired binary data from independent pairs, such as different people each answering the same yes or no question twice, only the discordant pairs carry information about a change. With pairs that answer yes and then no, and pairs that answer no and then yes, McNemar’s test of equal yes proportions at the two times uses the fact that, given discordant pairs, the count of the first kind is under . Its exact two-sided p-value is , and with many discordant pairs is compared with . The second yes proportion minus the first is . With and the exact p-value is .
Lessons Sparse Tables, Fisher’s Exact Test and Paired Binary Data
Several Groups and Variability
With several groups, one overall test asks whether any differences exist, follow-up comparisons say which, and multiplicity control keeps the error rate of the whole family of comparisons in check. Factorial designs study several factors at once, and the spread of a variable can itself be the target of inference.
One-way ANOVA
For groups with observations in group , group means , grand mean and observations in all,
| Source | Sum of squares | Degrees of freedom | Mean square |
|---|---|---|---|
| Between groups | |||
| Within groups | |||
| Total |
The test of uses , which has the distribution under when the observations are independent and each group is normal with the same variance. The F test tolerates moderate nonnormality, especially with similar group sizes that are not very small. Unequal variances matter most when the group sizes differ, and Welch’s ANOVA drops the equal-variance assumption. A rejection says that the means are not all equal, not which ones differ. The groups , and have , on 2 and 6 degrees of freedom and .
Lessons One-Way ANOVA and Welch ANOVA
Factorial designs, blocking and interactions
A factorial design runs every combination of the levels of its factors, and a cell mean is the mean response at one combination. For two factors A and B at two levels each, with these cell means,
| Simple effect of B | |||
|---|---|---|---|
the interaction is the difference of the simple effects, , and it is zero exactly when the effect of B is the same at both levels of A. A main effect averages simple effects over the other factor, so the main effect of B is and that of A is . When the interaction is large, report the simple effects, because a main effect averages effects that differ. Replication, more than one experimental unit per cell, is needed to separate the effects from random error. In a randomized block design the treatments are randomized separately within blocks of similar units, and the analysis keeps the blocks.
Lessons Factorial Designs, Blocking and Interactions
Contrasts and multiple testing
A contrast is with . In one-way ANOVA it is estimated by with standard error and tested against . Running tests of true null hypotheses, each at level , raises the chance of at least one false rejection, to for independent tests, which is about for and . The family-wise error rate is the probability of at least one false rejection, and the false discovery rate is the expected share of false rejections among all rejections, counted as 0 when nothing is rejected.
| Method | Rule for ordered p-values | Controls |
|---|---|---|
| Bonferroni | reject when | the family-wise error rate, under any dependence |
| Holm | reject in order while , and stop at the first failure | the family-wise error rate, under any dependence, rejecting everything Bonferroni rejects |
| Tukey | intervals , with the quantile of the studentized range for means and degrees of freedom | the family-wise error rate for all pairwise comparisons of means, for normal groups with equal variances |
| Benjamini-Hochberg | find the largest with and reject | the false discovery rate at level , for independent or positively dependent tests |
Comparisons planned before seeing the data form a smaller family than every comparison that might be chosen after looking, and post-hoc comparisons must be adjusted for every comparison that could have been made. For p-values , and at , Bonferroni and Holm reject only the first, since exceeds both and , while Benjamini-Hochberg rejects the first two, since .
Lessons Planned Contrasts, Post-Hoc Comparisons and Multiple Testing
Kruskal-Wallis test
Rank all observations of independent groups together, with midranks for ties, and let be the rank sum of group , which has observations. The Kruskal-Wallis statistic is
and it tests , that all groups come from one distribution, with large values of as evidence against it. For large groups is approximately under , small groups use the exact permutation distribution, and with ties is divided by , where each is the size of a set of tied values. A rejection says that the distributions are not all identical. Reading it as a difference in medians needs further assumptions, such as distributions of the same shape. For the groups , and , , the chi-square approximation gives , and the exact p-value is .
Lessons Kruskal-Wallis Tests and Comparing Several Distributions
Inference for variance and comparing spread
For independent observations from a normal population, , and the confidence interval for is with
Square roots of the endpoints give an interval for . Five observations with give about for and for . For two independent normal samples, is compared with to test . Both procedures are very sensitive to nonnormality, even in large samples. Levene’s test, a one-way ANOVA on the absolute deviations from the group means, and the Brown-Forsythe version, which uses deviations from the group medians, are much less sensitive.
Lessons Inference for Variance and Comparing Spread
Regression and Prediction
Regression describes how the mean of a response changes with one or more predictors. Least squares fits the model, residual plots check it, and intervals and tests describe its uncertainty. A coefficient describes an association adjusted for the other predictors in the model, and it is a causal effect only when the design supports that. Predictions are judged on data not used to fit them.
Least squares and R-squared
For pairs with at least two distinct values, the least-squares line minimizes and has
where and , and the form with needs . The line passes through , and the residuals add to 0. The slope is the change in the fitted value per unit of , in response units per predictor unit, and it compares individuals with different values rather than describing what happens when one individual’s changes. Regressing on gives a different line unless .
With ,
is the share of the variation of around its mean that the line accounts for. In simple regression with an intercept, and . A high does not show that a line is the right form, that the relationship is causal, or that predictions outside the data will be good. The points , and give , , , and .
Lessons Least Squares and R-Squared
Regression assumptions, residuals and influence
Classical inference for a line uses the model with these assumptions.
| Assumption | Statement | Check |
|---|---|---|
| Linear mean | , so | no curve in the plot of residuals against or |
| Constant variance | for every | no fan shape in the residual plot |
| Independent errors | the errors of different observations are unrelated | the design, and residuals plotted in time or group order |
| Normal errors | , needed for exact small-sample t and F inference | a normal Q-Q plot of the residuals |
Normality concerns the errors around the line, not the distribution of or of all the values together. For a line, the hat value
also called the leverage of an observation, depends only on the predictor values, with and . Cook’s distance measures how much all the fitted values move when observation is left out, and it combines the residual with the hat value,
for an observation with in a fit with coefficients, for a line, and . Values near or above 1, or far above the rest, deserve a closer look. A high-leverage point with a large residual can move the line a lot, and an influential point is a reason to check the data and the model, not to delete the point automatically.
Lessons Regression Assumptions, Residuals and Influence
Inference for the slope and intervals for predictions
Under the model with independent normal errors of constant variance, and at least two distinct values,
and . The confidence interval for the slope is , and is tested with . The slope is estimated more precisely when the residual SD is small, is large and the values are spread out. At a predictor value , with and
the intervals are
| Target | interval |
|---|---|
| Mean response | |
| One new observation at |
The prediction interval is wider because a new observation has its own error, and unlike the confidence interval it does not shrink toward zero width as grows. Both widen as moves away from . Extrapolation beyond the range of the data assumes that the model still holds there, which the data cannot check. For the six points with , fitted line , and , the slope has and 95 percent interval about . At the interval for the mean response is about , while the prediction interval is about .
Lessons Inference for a Regression Slope, Confidence and Prediction Intervals
Multiple regression, categorical predictors and interactions
The multiple regression model is fitted by least squares. The coefficient is the difference in mean response for a one-unit difference in with the other predictors held fixed, an adjusted association. It can differ in size and even in sign from the slope in a simple regression, and it is a causal effect only when the design supports that. Leaving out a variable that is related both to a predictor and to the response, an omitted variable, can distort the coefficients of the predictors that remain.
A categorical predictor with levels enters through indicator variables, and each of their coefficients compares one level with the reference level. Including indicators for all levels together with an intercept makes the coefficients not identifiable. An interaction term lets the effect of one predictor depend on another. In with an indicator , the reference group has and the other group has , so the group difference is 3 at , zero at and negative beyond. The coefficient of is the group difference at only. A model with an interaction usually keeps the terms it is built from, which is the hierarchy principle.
Lessons Multiple Regression and Adjusted Associations, Categorical Predictors and Interactions
Curved relationships and comparing models
A model is linear in the coefficients when its mean is a weighted sum of known functions of the predictors, such as , or for , so least squares and the usual inference apply to it. In a polynomial the effect of a one-unit step depends on where the step starts.
For a positive response in fixed units, the model with independent errors describes multiplicative effects. Each unit of multiplies the conditional median of by , the back-transformation of the mean of is the conditional median of , and the conditional mean is larger by the factor ,
Nested models are compared with the partial F test. If a reduced model with coefficients is a special case of a full model with coefficients, both fitted to the same observations, then
is compared with under the normal error model. Adding predictors to a least-squares fit on the same data never increases SSE and never lowers , while the adjusted value
can fall. With and , models with 2 and 3 coefficients and SSE 40 and 30 have and , adjusted values and about , and partial on 1 and 9 degrees of freedom with .
The variance inflation factor , where comes from regressing on the other predictors, is the factor by which the correlation of with the other predictors multiplies the variance of . Multicollinearity makes individual coefficients unstable without necessarily harming predictions, and an exact linear relation among the predictors leaves the coefficients not identifiable. Choosing a model with the same data that are then used to test it makes the reported p-values and intervals too optimistic.
Lessons Transformations and Curved Relationships, Comparing Regression Models and Multicollinearity
Logistic regression
For a binary response with , logistic regression models the log odds as a linear function,
The coefficient is the change in log odds for a one-unit increase in , so is the odds ratio for that increase. The change in probability per unit of is not constant, and it is largest where is near . The coefficients are estimated by maximum likelihood, and when a predictor separates the outcomes 0 and 1 completely, no finite maximum likelihood estimate exists. A model is well calibrated when, among cases with predicted probability near some value, the observed share of ones is near that value. With and , and , the odds ratio per unit is , and the probability rises by about from to but by about from to .
Lessons Logistic Regression
Validation, overfitting and honest prediction
For evaluated predictions with errors ,
and for a binary outcome with predicted probabilities the Brier score is the mean of . Error on the training data is too optimistic, because the model was fitted to those cases, and a flexible model can fit them perfectly while predicting new cases badly, which is overfitting. Estimate prediction error on test data set aside before any modeling decision, or with -fold cross-validation, which repeats the whole procedure, preprocessing and variable selection included, on folds and scores the held-out fold. Data leakage, such as predictors recorded after the outcome, linked records on both sides of a split, or scaling with statistics of all the data, makes a score look better than real use would be. A test score describes data like the test data, and distribution shift in later use can make performance worse.
Lessons Validation, Overfitting and Honest Prediction
Bayesian Statistics
Bayesian statistics describes uncertainty about unknown quantities with probability distributions. The prior states what is assumed before the data, the likelihood links the parameter to the data, and the posterior combines the two. Every posterior statement is conditional on the model and the prior as well as on the data.
Prior, likelihood and posterior
For hypotheses with prior probabilities that add to 1, and data with ,
so the posterior is proportional to the likelihood times the prior. For two hypotheses and , with and ,
so the posterior odds equal the prior odds times the Bayes factor . When the observations are conditionally independent given each hypothesis, updating with one observation at a time gives the same posterior as updating with all of them at once. With prior probabilities for each of two hypotheses that give a success the probabilities and , one success raises the probability of the second hypothesis to , a Bayes factor of 3 in its favor.
Lessons Prior, Likelihood and Posterior
Bayesian estimation and credible intervals
The distribution, with , has density proportional to on and mean . With a prior for a success probability and successes in independent trials with that probability, the posterior is
and the posterior mean
is a weighted average of the prior mean and the sample proportion , with weights proportional to and . A 95 percent credible interval contains with posterior probability given the prior, the model and the data, and the equal-tailed version runs from the to the posterior quantile. A 95 percent confidence interval instead makes a statement about the procedure over repeated samples, and the two intervals can differ in value as well as in meaning.
A prior and 7 successes in 10 trials give the posterior , with mean , median about , 95 percent equal-tailed credible interval about and posterior probability .
Lessons Bayesian Estimation and Credible Intervals
Posterior prediction and prior sensitivity
The posterior predictive distribution of new data averages the model over the posterior, so it includes the uncertainty about the parameter as well as the randomness of the new observations. With the posterior , the next trial succeeds with probability , and the number of successes in new trials that are independent given has
for , where is the beta function. Plugging a single estimate of into the binomial formula ignores the uncertainty about and gives a predictive distribution that is too narrow. With the posterior and , the probabilities of 0, 1 and 2 successes are , and , while plugging in gives for one success instead of .
Refitting with other reasonable priors shows how much a conclusion depends on the prior. With the same 7 successes in 10 trials, a prior gives posterior mean and a prior gives . A prior predictive check simulates data from the prior and the model before the data are used, and a posterior predictive check compares the observed data with data replicated from the posterior, looking for features the model fails to reproduce.
Lessons Posterior Prediction and Prior Sensitivity
Dependent Data and Time Series
Many standard formulas assume independent observations. Readings from the same person or cluster and values recorded over time are often positively correlated, and then the usual standard errors are too small and random splits for validation are too optimistic.
Repeated measures, clusters and independence
Pseudoreplication treats repeated measurements of one unit, or units inside one assigned cluster, as independent replicates. In the random-intercept model , with independent cluster effects of variance and independent errors of variance , two observations in the same cluster have the intraclass correlation
and with clusters of observations the variance of the overall mean is times its value under independence. Analyze at the level of the units that were sampled or assigned independently, for example with one summary per cluster, a cluster bootstrap that resamples whole clusters, or a mixed model with a random intercept for each cluster. With clusters of unequal size, the mean of the cluster means and the mean of all the observations estimate different quantities.
Four devices measured three times each, with readings , , and , have device means 8, 10, 12 and 14. The standard error of the overall mean computed from the four device means is , while treating the 12 readings as independent gives about .
Lessons Repeated Measures, Clusters and Independence
Time series, trend, seasonality and autocorrelation
A time series records one variable at successive times, and its order carries information. A trend is a long-run change in level, seasonality is a pattern that repeats with a fixed period, and the autocorrelation at lag is the correlation between values steps apart. With deviations , the sample autocorrelation is
The values 1, 2, 3, 4 and 5 in that order have , and the same values in the order 1, 5, 2, 4, 3 have . A series is stationary in the weak sense when its mean and variance stay constant and the covariance between two values depends only on the lag between them. Trend and seasonality break stationarity, and differencing, , or seasonal differencing, for period , often removes them.
Positive autocorrelation makes the variance of a mean larger than . For 10 values from a stationary series with variance 4 and autocorrelations , the SE of the mean is about , against for independent values. A change seen in a time plot does not by itself identify its cause.
Lessons Time Series, Trend, Seasonality and Autocorrelation
Smoothing, forecasting and time-aware validation
A forecast is made at origin for horizon and uses only the values up to time .
| Method | Forecast from origin |
|---|---|
| Naive | for every horizon |
| Seasonal naive with period | the last observed value from the same season |
| Trailing moving average of values | |
| Simple exponential smoothing | the level , with smoothing constant |
A centered moving average uses later values, so it can describe the past but cannot forecast. Simple exponential smoothing with and , applied to 10, 12, 11, 13, 12, 14, 13 and 15, gives the levels 10, 11, 11, 12, 12, 13, 13 and 14, so every forecast from time 8 is 14.
Rolling-origin evaluation fits the method at each origin using only the data available then, forecasts ahead, and scores the error when the value arrives. Random splits, and preprocessing or tuning that uses later data, let information from the future leak into the evaluation, which is temporal leakage. A useful method should beat the naive and seasonal naive baselines on such an evaluation. A forecast interval needs a probability model for the future errors, and it usually widens as the horizon grows.
Lessons Smoothing, Forecasting and Time-Aware Validation
Complete Statistical Investigations
A statistical result means little without its question, design and limits. A complete investigation runs from a precise question and its estimand through design, measurement, exploration and a method suited to the design, to model checks and a conclusion that says no more than the evidence supports.
Choosing a method
Choose the method from the question, the type of outcome and the design, before seeing the results, and check its conditions on the data.
| Question and data | Usual methods |
|---|---|
| One mean | one-sample t interval and test, or the sign test for a median |
| One proportion | Wilson or Clopper-Pearson interval, exact binomial test |
| Paired measurements | paired t on the differences, or a sign or signed-rank test |
| Two independent means | Welch t interval and test, or the rank-sum test to compare distributions |
| Two independent proportions | unpooled interval for the difference, two-proportion z test, Fisher’s exact test for small counts |
| Paired yes or no outcomes | McNemar test |
| Several means | one-way or Welch ANOVA, then planned contrasts or Tukey comparisons |
| Several distributions | Kruskal-Wallis test |
| Counts in categories | chi-square goodness-of-fit, independence or homogeneity test |
| Numerical response and predictors | linear regression with residual checks |
| Binary response and predictors | logistic regression |
| Clustered or repeated measurements | analysis at the cluster level, cluster bootstrap or mixed model |
| Values over time | time-aware methods and rolling-origin evaluation |
Lessons Selecting Methods and Reporting Statistical Results
Planning and reporting
- Estimand. State the quantity the study aims to learn, with its population, variable, comparison and summary, such as in minutes.
- Analysis plan. Fix the primary outcome, the method, the handling of missing data and the comparisons before the outcome data are seen, and preregister the plan when possible. Label analyses chosen after looking at the data as exploratory.
- Selective reporting. Report every comparison that was made, not only the significant ones, since selection inflates false positives.
- Effects and uncertainty. Give the estimate in its units with a confidence interval, then the p-value with the test named, and compare the interval with the smallest effect that would matter.
- Scope. Generalize to a population only as far as the sampling supports, and claim causation only as far as the assignment supports.
- Sensitivity analysis. Repeat the analysis under other reasonable assumptions, such as other values for missing data or without influential points, and report how much the conclusion moves.
- Reproducibility. Keep the raw data, the code, the software versions, the seeds and the cleaning log, so that every number can be recomputed.
For example, two independent groups of 12 with mean completion times of about minutes for A and minutes for B give the Welch estimate minutes, with 95 percent interval about minutes and two-sided p-value about . A report states the difference and its interval in minutes first, says that the p-value is computed assuming no true difference and the conditions of the Welch test, and compares the whole interval with the smallest difference that would matter.
Lessons Selecting Methods and Reporting Statistical Results, A Complete Statistical Investigation