Statistics questions, answered
45 short answers from 9 guides. Each set links to the full guide for the worked examples and the reasoning behind the answer.
Confidence Intervals and Sample Size, Worked Through
Why is the standard survey sample size 385?
The 385 comes from Cochran's formula, n₀ = z² p(1 - p) / E², at 95% confidence (z = 1.959964), a ±5% margin and p = 0.5. That gives 3.8415 x 0.25 / 0.0025 = 384.15, which rounds up to 385. Using p = 0.5 is deliberate, because p(1 - p) is largest at 50%, giving the biggest, safest sample.
What is the finite population correction for sample size?
The finite population correction reduces the required sample when the population is small: n = n₀ / (1 + (n₀ - 1) / N). At 95% confidence and ±5%, 385 becomes 218 for a population of 500, 278 for 1,000 and 80 for 100. For a city of a million it is 384, so once the population is far bigger than the sample, its size stops mattering.
How do I calculate sample size to estimate a mean?
To estimate a mean within ±E, use n = (zσ / E)², which needs a guess at the standard deviation σ. If a pilot study suggests σ = 15 and you want the mean within ±2 at 95% confidence, n = (1.96 x 15 / 2)² = 216.08, so you need 217. The answer is only as good as the σ guess, so round up generously.
How many survey invitations should I send?
Sample size formulas give completed responses, so divide by the expected response rate to get invitations. If you need 385 responses and expect 25% of invitations to come back, invite 1,540 people. Low response rates also raise the risk that responders differ from non-responders, which no sample size can fix.
How much more data do I need to halve the margin of error?
You need four times the data to halve the margin of error, because the width of a confidence interval shrinks with the square root of the sample size. At 95% confidence and p = 0.5, a ±5% margin needs 385 responses while ±3% needs 1,068 and ±1% needs 9,604, so precision gets expensive quickly.
How to Do a t-Test: One-Sample, Paired and Welch
What is the difference between a paired and an independent t-test?
A paired t-test compares two measurements on the same subjects and is a one-sample test on their differences, while an independent t-test compares separate groups. On Student's 1908 sleep data the paired test gives p = 0.0028, but treating the same columns as independent groups gives p = 0.079, because pairing removes person-to-person spread from the error term.
Who invented the t-test?
William Sealy Gosset, a chemist at the Guinness brewery in Dublin, published the t-test in Biometrika in 1908 as "The probable error of a mean". He used the pen name "Student" because Guinness preferred staff not to publish under their own names. R. A. Fisher later reshaped the result into the t distribution with n - 1 degrees of freedom.
Should I use a one-tailed or two-tailed t-test?
Use a two-tailed t-test unless the direction of the effect was fixed before collecting the data and an effect in the other direction would be treated the same as no effect. A one-sided test halves the p-value when the effect is in the predicted direction, and choosing the tail after looking at the data doubles the real false-positive rate.
How do you calculate degrees of freedom for a t-test?
One-sample and paired t-tests have n - 1 degrees of freedom, and Student's pooled two-sample test has n₁ + n₂ - 2. Welch's test uses the Welch-Satterthwaite approximation, which usually gives a fractional answer between the smaller group's n - 1 and n₁ + n₂ - 2. Two classes of 18 and 20 pupils, for example, gave 35.74 degrees of freedom.
When should I not use a t-test?
A t-test is the wrong tool for more than two groups, where running every pairwise test inflates false positives and a one-way ANOVA fits instead. Small, skewed samples suit the Wilcoxon signed-rank or Mann-Whitney U test, clustered data need a multilevel model, and yes/no outcomes such as conversion rates suit a test on counts like chi-square.
Linear Regression Explained: Slope, R² and Residuals
What is Anscombe's quartet?
Anscombe's quartet is four small data sets published by Francis Anscombe in 1973 with nearly identical regression summaries: slope 0.500, intercept 3.00, r about 0.816 and R² 0.667. Plotted, they look nothing alike: one linear scatter, one smooth curve, one perfect line with an outlier, and one vertical stack with a single point creating the slope. It shows why you must plot data.
How do I interpret a residual plot in linear regression?
A residual plot puts fitted values on the horizontal axis and residuals on the vertical axis, and a good straight-line fit shows a shapeless band around zero. A curve means the relationship is not linear, a funnel means the error variance is not constant so p-values are unreliable, and isolated points far from zero are possible outliers.
What is the standard error of the slope in linear regression?
The standard error of the slope is SE(b) = s / √Sxx, where s is the residual standard error and Sxx the sum of squared x deviations. It shrinks with less scatter, more data and a wider spread of x values. Dividing the slope by it gives the t statistic, with n − 2 degrees of freedom, for testing whether the true slope is zero.
Who invented least squares regression?
Adrien-Marie Legendre published the least squares method in 1805 to fit comet orbits. Carl Friedrich Gauss published it in 1809, said he had used it since 1795, and showed it is the best choice when errors are normally distributed. Least squares picks the line that makes the sum of squared residuals as small as possible.
What are the assumptions of linear regression?
The standard errors, p-values and intervals of linear regression rely on four assumptions, remembered as LINE. Linear: the mean of y changes linearly with x. Independent: errors are independent of each other. Normal: errors are roughly normal. Equal variance: the scatter around the line is the same at every x. The least squares line itself can be computed for any data.
Mean, Median, Standard Deviation and Z-Scores Explained
When should I use the median instead of the mean?
Use the median when data are skewed or contain extreme values, because a few outliers drag the mean but not the median. That is why house prices, household incomes and web page load times are usually reported as medians. If the mean and median are close, the data are roughly symmetric and either works, and the mean is the right choice when totals matter.
What is the difference between Excel QUARTILE.INC and QUARTILE.EXC?
Excel's QUARTILE.INC interpolates at position (n - 1)p + 1, the same rule as Google Sheets, R's default type 7 and NumPy's default. QUARTILE.EXC uses position (n + 1)p, like R type 6, Minitab and SPSS. For the 11 values 12, 15, 15, 15, 18, 21, 22, 25, 27, 30, 64, QUARTILE.INC gives Q3 = 26 and QUARTILE.EXC gives Q3 = 27.
What is the 1.5 IQR rule for outliers?
John Tukey's 1.5 IQR rule flags a value as an outlier when it lies below Q1 - 1.5 x IQR or above Q3 + 1.5 x IQR, where the interquartile range IQR is Q3 - Q1. With Q1 = 15 and Q3 = 27, the fences are -3 and 45, so a value of 64 is flagged. An outlier flag is a reason to look at a value, not to delete it.
How do I convert a z-score to a percentile?
If the data are roughly normal, convert a z-score to a percentile with the standard normal cumulative distribution Φ(z). For z = 1.5, Φ = 0.9332, so the value beats about 93% of the group. The conversion assumes a bell-shaped distribution, so for strongly skewed data such as incomes or reaction times, rank the values directly instead.
What is the 68-95-99.7 empirical rule?
The empirical rule says that in a normal distribution 68.27% of values lie within one standard deviation of the mean, 95.45% within two and 99.73% within three. It comes from the same standard normal curve used to turn z-scores into percentiles, so it holds only for roughly bell-shaped data, not for strongly skewed data such as incomes or file sizes.
Normal Distribution Probabilities and the Inverse Normal
How do I standardise a normal variable?
Standardise a normal variable by measuring its distance from the mean in standard deviations: z = (x - μ) / σ. The probability below x is then Φ(z), the area to the left of z under the standard normal curve with mean 0 and standard deviation 1. On the IQ scale with mean 100 and SD 15, a score of 85 gives z = -1.
What percentage of people have an IQ above 130?
About 2.28% of people score above 130 on the IQ scale, which is designed to have mean 100 and standard deviation 15. A score of 130 is z = 2, and the right tail beyond it is 1 - Φ(2) = 0.02275, roughly 1 person in 44. About 15.9% score below 85.
Where does 1.96 come from in a 95% confidence interval?
The 1.96 multiplier comes from the standard normal distribution: the range μ ± 1.96σ contains 95.00% of the area, leaving 5% in the two tails. In the same way, μ ± 2.576σ contains 99.00%, which is the multiplier for a 99% confidence interval. Many lab reference ranges use mean ± 1.96 SD for the same reason.
What is the continuity correction in the normal approximation?
The continuity correction adjusts a whole-number count by half a unit when approximating a binomial with the normal curve, so P(X ≤ 45) becomes P(X < 45.5). For 100 tosses of a fair coin, the corrected approximation Φ(-0.9) gives 0.184 for at most 45 heads, matching the exact binomial value. The approximation works well when np and n(1 - p) are at least about 10.
What does the central limit theorem say?
The central limit theorem, due to Laplace, says that the sum or average of many small, independent effects tends towards a normal distribution, whatever the shape of the individual effects. That is why the bell curve turns up so often, and why sample means are often close to normal even when the individual values are not.
One-Way ANOVA Explained: F, Effect Sizes and Post Hoc Tests
What are the assumptions of a one-way ANOVA?
A one-way ANOVA assumes independent observations, approximately normal residuals within groups and equal variances. It is fairly tolerant of mild non-normality, especially with balanced groups of 15 or more. A ratio of largest to smallest standard deviation above about 2 is a warning sign for unequal variances, and Levene's test or Welch's ANOVA can address it.
What is Levene's test?
Levene's test checks the equal-variance assumption of ANOVA by running an ANOVA on the absolute deviations of each value from its group centre. The median-centred version, due to Brown and Forsythe (1974), is less sensitive to non-normal data and is the default in R's car::leveneTest and SciPy's levene.
What is the difference between Holm and Bonferroni corrections?
Bonferroni multiplies each p-value by the number of comparisons, capped at 1, which is simple and conservative. Holm (1979) sorts the p-values and multiplies the smallest by m, the next by m - 1 and so on, keeping the sequence non-decreasing. Holm controls the same overall error rate and is never less powerful than Bonferroni.
Is ANOVA the same as a t-test with two groups?
Yes, with exactly two groups a one-way ANOVA and the pooled two-sample t-test are the same test: F equals t squared and the p-values match. One-way ANOVA is also a special case of linear regression with the group coded as indicator variables, which is why regression output shows the same ANOVA table.
What is the non-parametric alternative to one-way ANOVA?
The Kruskal-Wallis test is the rank-based alternative to one-way ANOVA for small, skewed groups where the normality assumption is doubtful. When observations are not independent, for example the same subjects measured under several conditions, a repeated-measures ANOVA or a mixed model is needed instead.
Probability Rules, Permutations and Combinations
How do I tell if order matters in a counting problem?
Swap two of the chosen items and see whether the outcome changes. If swapping first and second place gives a different result, order matters and you count permutations. If swapping two people on a committee leaves the same group, order does not matter and you count combinations.
What are the odds of winning the Powerball jackpot?
The Powerball jackpot odds are 1 in 292,201,338. A ticket must match 5 white balls from 69, which is 69C5 = 11,238,513 combinations, and 1 red ball from 26. Multiplying 11,238,513 by 26 gives the total number of equally likely outcomes, and only one of them wins the jackpot.
What is the prosecutor's fallacy?
The prosecutor's fallacy is confusing P(A | B) with P(B | A), the single most common probability error. In medicine the same mistake appears as treating a test's sensitivity as the chance that a positive result is correct. Bayes' theorem, P(A | B) = P(B | A) P(A) / P(B), converts one conditional probability into the other.
What was the Chevalier de Méré's dice problem?
Antoine Gombaud, the Chevalier de Méré, bet in 17th-century Paris on getting at least one six in four rolls, which wins 51.77% of the time. His second bet, at least one double six in 24 rolls of two dice, wins only 49.14%. His question to Blaise Pascal started the correspondence between Pascal and Pierre de Fermat that founded probability theory.
When should I not use the binomial distribution?
The binomial distribution needs a fixed number of trials, two outcomes per trial, the same success probability each time, and independence. Drawing cards without replacement breaks the last two, so the hypergeometric distribution fits instead, though the binomial is a fine approximation for a few draws from a large population. Counting events over time, such as calls per hour, calls for the Poisson distribution.
The Chi-Square Test: Independence and Goodness of Fit
What is the chi-square formula?
The chi-square statistic, introduced by Karl Pearson in 1900, is χ² = Σ (O - E)² / E. For every category or cell, subtract the expected count E from the observed count O, square the gap and divide by E, then add up the results. Large values mean the counts sit far from what was expected, so the p-value is always the right-tail area.
What if a chi-square expected count is less than 5?
Under Cochran's 1954 rule, no expected count should be below 1 and no more than 20% of cells should have expected counts below 5. The rule is about expected counts, not observed ones. When it fails, merge sparse categories if that makes sense, collect more data, or use Fisher's exact test for a 2 x 2 table.
How do estimated parameters change chi-square degrees of freedom?
In a goodness-of-fit test, each parameter estimated from the same data removes one more degree of freedom, so df = k - 1 - (number of estimated parameters). Testing whether daily defect counts follow a Poisson distribution, for example, means estimating the Poisson mean first and subtracting one more df. Forgetting this makes the chi-square test too lenient.
Can I use percentages in a chi-square test?
No, a chi-square test needs raw counts, not percentages, because χ² depends on sample size. A split of 60% versus 40% in a sample of 20 is weak evidence, while the same split in a sample of 2,000 is overwhelming. Each observation must also fall in exactly one cell and come from an independent subject.
How do I report chi-square test results?
Report the chi-square statistic with its degrees of freedom, the sample size, the p-value and an effect size such as Cramér's V, for example "χ²(2, N = 2,757) = 30.07, p < 0.001, V = 0.10". Reporting only the p-value hides how strong the association is, since large samples produce tiny p-values even for weak associations.
What Is a P-Value? Meaning, Calculation and Misuses
Why is 0.05 used as the significance level?
The 0.05 convention traces back to Ronald Fisher's Statistical Methods for Research Workers (1925), where he wrote that it was convenient to take 1 in 20, a deviation of about two standard deviations, as a line for judging whether a result deserved a closer look. It is a convention rather than a law, and p = 0.049 and p = 0.051 are practically the same evidence.
What did the ASA statement on p-values say?
In 2016 the American Statistical Association took an official position on a specific matter of statistical practice for the first time, prompted by widespread misuse of p-values. Its six principles, published by Wasserstein and Lazar, say a p-value is not the probability the null hypothesis is true, does not measure effect size, and should not be the sole basis of a conclusion.
Does a large p-value mean there is no effect?
No. A large p-value usually means the study could not tell whether there is an effect, not that there is none. With twelve patients, a large and useful benefit can give p = 0.2. Report the effect size and its confidence interval: an interval running from a small harm to a large benefit shows that the data are simply inconclusive.
What is the multiple testing problem?
Each test at α = 0.05 has a 5% false-positive rate when the null hypothesis is true, so running many tests makes a spurious "significant" result likely. With twenty independent tests on pure noise, the chance of at least one is 1 − 0.95²⁰ = 64%. Corrections such as Bonferroni or Holm control the overall error rate.
Why is 1.96 used for 95% confidence?
1.96 is the point on the standard normal distribution that leaves 2.5% in each tail. The area above z = 1.96 is 0.0249979, and the same area lies below -1.96, so the two-tailed p-value is 0.04999579. A z statistic beyond ±1.96 is therefore significant at the 5% level, and 1.96 is the multiplier for a 95% interval.