Statistics tutorial · Chapter 04
Describing and exploring
This chapter covers the analyses of the Analysis › Describe and Explore family that describe a sample or a curve: descriptive statistics (Descriptive Statistics), normality and lognormality tests (Normality Tests), frequency distributions (Frequency Distribution), row statistics (Per-Row Summary), the area under a curve (Area Under Curve), the comparison of an observed distribution with an expected one (Observed vs. Expected Frequencies), the analysis of a stack of P values (Multiple P Values (FDR)), and the smoothing, differentiation and integration of a curve (Curve Smoothing, Derivative and Integral). The two other analyses of the family are covered elsewhere: correlation in chapter 16, principal component analysis in chapter 20. General notions (SD and SEM, confidence intervals, P value, multiple comparisons, P value styles) are explained in chapter 10, to which this chapter refers.
Describe before you test. This is the step that is skipped most often, and the one that prevents the most errors. The number of values, the minimum and the maximum reveal a data-entry or unit error; comparing the mean with the median, the skewness, the histogram and the QQ plot show the shape of the distribution; the standard deviations of several groups tell you whether equal variances are plausible. A test chosen after this look is applied to data you understand; a test run blindly can answer a badly posed question with great precision.
The examples use the sample data of the welcome window ("an example"): the One factor table "Two groups (t test)", the Two factors table "Two-way ANOVA (3 rows × 2 data sets, triplicates)", the Multivariable table "Clinical study (continuous, categorical and outcome variables)", the XY tables "Exponential decay (time course)" and "Dose-response (log dose, replicates)", and the Proportions table "Distribution of categories".
Common principles#
- The data are never modified. Each analysis creates a results sheet. Four analyses also produce an output table (a tab preceded by ⊞) and plot it immediately: Frequency Distribution (bar histogram), Normality Tests (QQ plot, as points), Curve Smoothing, Derivative and Integral (curve, as lines) and Multiple P Values (FDR) (ranked P values, as points). Per-Row Summary (option "Statistics of the entire row (all data sets)") produces an output table without a graph: the Plot These Results button of its tab plots it, and Analyze These Results analyzes it.
- Results follow the data. Correcting a value recalculates the analysis (unless the "Lock the results (no recalculation)" box is checked), and Format › Analysis Settings… (Ctrl+Shift+A) reopens its options.
- Only the numeric values present count. Empty cells, text and excluded values (Edit › Exclude or Include Values, Ctrl+Shift+D) are ignored. Always check the line that gives the number of values.
- Individual values or summaries. Descriptive Statistics, Normality Tests and Frequency Distribution require individual values: a data set entered as mean, SD (or SEM) and N is ignored. Area Under Curve and Curve Smoothing, Derivative and Integral use the mean of each row (the mean of the replicates, or the mean as entered).
- Common tabs. The "Data sets" tab chooses the data sets analyzed; the "Options" tab contains the options specific to the analysis, then "Significant digits" (4 by default) and "P value format" (chapter 10).
Descriptive Statistics#
The Descriptive Statistics analysis summarizes each data set with about thirty quantities: sample size, location, dispersion, precision (SEM, confidence intervals), shape, and the geometric, harmonic and quadratic means. It performs no test. The definitions and a hand-calculated example (the "Wild type" column) are in chapter 10, section "Descriptive statistics"; this section describes the analysis and gives an example on a Multivariable table.
When to use it#
- Always, first, on every data set that will be analyzed: "Number of values" confirms that all the values were read, the minimum and maximum flag a data-entry or unit error, and the mean compared with the median, together with the skewness, tells you whether the data are roughly symmetric.
- To choose the summary to report: mean and SD (symmetric data), median and quartiles (skewed or bounded data), geometric mean and its factor (lognormal data: concentrations, titers, durations).
- To prepare a test (n and SD of each group, shape) and to report the precision of an estimate (CI of the mean, of the median or of the geometric mean).
Assumptions and checks#
The summaries themselves assume nothing. The confidence intervals assume independent values drawn from a single population: technical replicates, several measurements on the same animal or the cells of one dish are not independent, so describe one value per experimental unit (for example the mean of the replicates, with Per-Row Summary). The CI of the mean further assumes a normal distribution or a large enough n (a few dozen values if the skewness is moderate); that of the geometric mean assumes a lognormal distribution; that of the median assumes only a continuous distribution (it is nonparametric). To check the shape, look at the individual values, a histogram (Frequency Distribution) or a QQ plot (Normality Tests).
Step by step in Variance#
- Display a One factor, XY, Two factors, Nested or Multivariable table and choose Analysis › Describe and Explore › Descriptive Statistics (or the ribbon's Analyze button, then "Descriptive Statistics" in the "Choose an Analysis" window).
- Options tab:
- "Basic statistics (min, max, quartiles, mean, SD, SEM)" (checked), with the range as well;
- "Confidence intervals" (checked): CI of the mean and of the median;
- "Advanced (CV, skewness, kurtosis, geometric, harmonic and quadratic means)" (checked), with the CIs of these means and the MAD;
- "10th and 90th percentiles" (unchecked), displayed only if "Basic statistics" is checked;
- "Confidence level (%)": level of all the intervals (95 by default, from 50 to 99.99).
- Data sets tab: check the data sets to describe, then OK.
What Variance calls a data set depends on the table type:
| Table | One results column for | Values pooled |
|---|---|---|
| One factor | each column | all rows |
| XY | each Y data set | all rows and all replicates; X is ignored |
| Two factors | each data set (column group) | all rows and all replicates |
| Nested | each data set (treatment) | all subcolumns and all rows |
| Multivariable | each numeric variable | all rows; categorical variables are ignored |
If no data set contains individual values (all entered as mean/SD/N, for example), the analysis stops with the message "no values to describe".
Calculations#
The formulas are those of chapter 10. In brief, with x₍₁₎ ≤ … ≤ x₍ₙ₎ the n sorted values, m the mean, s the standard deviation and t the 1 − α/2 quantile of Student's distribution with n − 1 degrees of freedom:
Percentile p h = (n + 1)·p; x₍₁₎ if h ≤ 1; x₍ₙ₎ if h ≥ n;
otherwise x₍k₎ + (h − k)·(x₍k+1₎ − x₍k₎), k = integer part of h
(Hyndman and Fan type 6); the median is the central value
or the mean of the two central values
SD, SEM s = √( Σ(xᵢ − m)² / (n − 1) ) SEM = s / √n
CI of the mean m ± t·SEM
CI of the median [x₍l₎, x₍n−l+1₎], l = largest rank such that P(B ≤ l − 1) ≤ α/2,
B ~ Binomial(n, 1/2); actual level = 1 − 2·P(B ≤ l − 1)
CV (%) 100 · s / m
Skewness G1 n / ((n − 1)(n − 2)) · Σ zᵢ³ zᵢ = (xᵢ − m) / s
Kurtosis G2 n(n + 1) / ((n − 1)(n − 2)(n − 3)) · Σ zᵢ⁴ − 3(n − 1)² / ((n − 2)(n − 3))
Geometric mean GM = exp(mean of ln xᵢ) factor GSD = exp(SD of ln xᵢ)
CI = exp(limits of the t CI of the mean of ln xᵢ)
Harmonic mean H = 1 / (mean of 1/xᵢ); CI = reciprocals of the limits of the t CI of the
mean of 1/xᵢ (empty cell if its lower limit is ≤ 0)
Quadratic mean Q = √(mean of xᵢ²); CI = square roots of the limits of the t CI of the
mean of xᵢ² (lower limit set to 0 if it is negative)
MAD median of |xᵢ − median| (not multiplied by 1.4826)
Variance specifics:
- Percentiles. The 10th percentile is the minimum and the 90th is the maximum as long as n ≤ 9; the quartiles are as well for n ≤ 3. A spreadsheet (type 7) gives other values on small samples.
- Minimum number of values. SD, SEM and CI require 2 values, skewness 3, kurtosis 4; the geometric and harmonic means require all values to be strictly positive. A quantity that cannot be computed leaves its cell empty (for n = 1, the actual level of the median CI displays 0).
- CI of the median. At 95%, no rank is suitable for n ≤ 5: the interval is the range and its actual level, 1 − 2 × 0.5ⁿ, is lower than the requested level (93.75% for n = 5). Always read "Actual confidence level of median CI (%)".
- CV. It is negative if the mean is (there is no absolute value).
Reading the results#
The "Descriptive statistics" tab has one column per data set and the following rows, in this order (each group of rows depends on the corresponding box):
| Row | Content |
|---|---|
| "Number of values" | n |
| "Minimum", "10% Percentile", "25% Percentile", "Median", "75% Percentile", "90% Percentile", "Maximum", "Range" | location; "Range" = maximum − minimum |
| "Mean", "Std. Deviation", "Standard error of the mean" | mean, SD, SEM |
| "Lower 95% CI of mean", "Upper 95% CI of mean" | CI of the mean (the label follows the chosen level) |
| "Lower CI of median", "Upper CI of median", "Actual confidence level of median CI (%)" | CI of the median and its actual level |
| "Coefficient of variation (%)", "Skewness", "Kurtosis" | CV, G1, G2 (0 for a normal distribution) |
| "Geometric mean", "Geometric SD factor", "95% CI of geometric mean" | GM, GSD, CI of GM |
| "Harmonic mean", "95% CI of harmonic mean" | H and its CI |
| "Quadratic mean", "95% CI of quadratic mean" | Q and its CI |
| "Median absolute deviation" | unscaled MAD |
| "Sum" | sum of the values (always displayed) |
The CIs of the three special means are displayed in the form "lower limit to upper limit". The analysis creates neither an output table nor a graph. A mean clearly above the median, with a positive skewness, signals a right tail. The geometric SD factor is multiplied and divided: for a lognormal distribution, about 68% of the values lie between GM/GSD and GM × GSD, and the CI of GM, symmetric on the logarithmic scale, is not symmetric around GM.
Worked example#
Data: the Multivariable sample "Clinical study (continuous, categorical and outcome variables)", 40 patients and 7 variables. Run Descriptive Statistics with the default options. The results have six columns, Age, Weight, Height, Response, Time and Event: the variable Sex (M/F) is categorical and is not described.
Sorted values of the variable Time (a follow-up duration, assumed here to be in days):
38 38 39 39 39 39 43 43 44 44 44 45 47 48 49 49 49 50 51 52
52 53 53 55 56 57 58 59 60 61 61 62 63 65 66 67 69 71 72 85
Hand calculation:
n = 40 Σx = 2135 m = 53.375 s = 11.0725 SEM = 11.0725 / √40 = 1.7507
Q1: h = 41 × 0.25 = 10.25 → x₍₁₀₎ + 0.25 × (x₍₁₁₎ − x₍₁₀₎) = 44 + 0.25 × 0 = 44
Median = (x₍₂₀₎ + x₍₂₁₎) / 2 = (52 + 52) / 2 = 52
Q3: h = 41 × 0.75 = 30.75 → x₍₃₀₎ + 0.75 × (x₍₃₁₎ − x₍₃₀₎) = 61
95% CI of the mean: t(0.975, 39) = 2.0227
53.375 ± 2.0227 × 1.7507 = 49.83 to 56.92
CI of the median: P(B ≤ 13) = 0.0192 ≤ 0.025 but P(B ≤ 14) = 0.0403 → l = 14
[x₍₁₄₎, x₍₂₇₎] = [48, 58], actual level 1 − 2 × 0.0192 = 96.15%
Logarithms: mean 3.95699, SD 0.203344
GM = e^3.95699 = 52.30 GSD = e^0.203344 = 1.2255
CI of GM = exp(3.95699 ± 2.0227 × 0.203344 / √40) = 49.01 to 55.81
MAD = median of |x − 52| = 8
Variance displays the same values: "Mean" 53.38, "Std. Deviation" 11.07, "25% Percentile" 44, "Median" 52, "75% Percentile" 61, "Lower 95% CI of mean" 49.83, "Upper 95% CI of mean" 56.92, "Lower CI of median" 48, "Upper CI of median" 58, "Actual confidence level of median CI (%)" 96.15, "Skewness" 0.624, "Kurtosis" 0.171, "Geometric mean" 52.3, "Geometric SD factor" 1.225, "95% CI of geometric mean" 49.01 to 55.81, "Median absolute deviation" 8.
The mean is slightly above the median and the skewness is positive, because of one delay of 85 days; the difference remains moderate and both summaries are defensible. If the delays followed a lognormal distribution, about 68% of them would lie between 52.30/1.2255 = 42.7 and 52.30 × 1.2255 = 64.1 days.
The variable Response is coded 0/1: its "Mean" (0.3) is the proportion of responders ("Sum" = 12 out of 40) and its "Std. Deviation" (0.4641 = √(0.3 × 0.7 × 40/39)) adds nothing; quartiles, skewness and geometric mean are meaningless for a binary variable. Summarize it with the count and the percentage, with the CI of a proportion (chapter 10).
Reporting the results#
"The median delay was 52 days (interquartile range 44 to 61; range 38 to 85; n = 40)." For symmetric data: "mean 53.4 days (SD 11.1; n = 40); 95% CI of the mean 49.8 to 56.9 days". Always state n, and whether the number after ± is an SD or a SEM.
Common pitfalls#
- Presenting the SEM as a measure of dispersion (chapter 10), or counting technical replicates as subjects: the SEM and CIs become falsely narrow.
- Describing a Two factors table column by column: the values of all rows are pooled (in the Two factors sample, "Male" mixes placebo, low dose and high dose). To describe each cell, use Per-Row Summary with "Statistics of each data set (replicates)".
- Comparing quartiles from one program to another without checking the convention (type 6 here, type 7 in most spreadsheets).
- Interpreting a CV on a scale with no natural zero (temperature in °C, centered score).
- Over-interpreting the skewness and kurtosis of small samples: with 12 values, a single low value is enough to give a skewness of −1.1 ("Wild type" column, chapter 10).
Normality Tests#
For each column of a One factor table, this analysis tests the hypothesis that the values come from a normal distribution and, if requested, from a lognormal distribution, with four tests to choose from; it also compares the likelihood of the two models and produces a QQ plot. The role of normality in parametric tests is explained in chapter 10 (section "Normality").
When to use it#
- To examine the shape of a sample before choosing a summary or a transformation: the QQ plot is the most informative result.
- To choose between a normal and a lognormal distribution (concentrations, titers, durations).
- To check the normality assumption of a parametric test: it is the residuals that must be normal, and the group comparisons (chapter 14) and nonlinear regression (chapter 17) test their own directly; here, test each group separately.
A normality test cannot prove normality. With fewer than 15 to 20 values it has almost no power: a "Yes" says almost nothing. With hundreds of values it rejects minimal departures that have no consequence for a t test or an ANOVA. What you know about the variable (a concentration is positive and often right-skewed) often matters more than the P value of a small sample.
Assumptions and checks#
H0 is "the values are a sample from a normal distribution", with any mean and standard deviation, estimated from the data. The tests assume independent individual values from a single population (a column that pools two groups with different means can look non-normal although each group is normal), and a continuous variable: heavily rounded values or counts of small numbers lead to rejection of normality for a reason unrelated to the planned analysis.
Step by step in Variance#
- Enter one column per group in a One factor table (the only type accepted) and choose Analysis › Describe and Explore › Normality Tests.
- Options tab:
- "Test for normal (Gaussian) distribution" (checked): tests on the values themselves;
- "Lognormal distribution" (unchecked): the same tests on the natural logarithms;
- "Compute the relative likelihood of normal vs lognormal" (unchecked);
- "D'Agostino-Pearson test", "Anderson-Darling test", "Shapiro-Wilk test" and "Kolmogorov-Smirnov test (Lilliefors P value)" (all checked): tests performed;
- "Significance level (alpha)": threshold of the "Passed" row (0.05 by default).
- Data sets tab: check the columns, then OK. Variance displays the results and plots the QQ plot.
Calculations#
The values are sorted, x₍₁₎ ≤ … ≤ x₍ₙ₎; m is the mean, s the standard deviation (denominator n − 1), Φ the cumulative distribution function of the standard normal distribution. Minimum number of values: 3 for Shapiro-Wilk (5000 at most), 5 for Kolmogorov-Smirnov, 8 for D'Agostino-Pearson and Anderson-Darling. Below these, the statistic row displays "Too few values"; if all the values are equal, "All values identical"; beyond 5000 values for Shapiro-Wilk, "More than 5000 values".
Shapiro-Wilk (Shapiro and Wilk, 1965; coefficients and P by Royston's algorithm AS R94, 1995). W compares a linear combination of the sorted values, close to the slope of the QQ plot, with the sum of squared deviations:
W = ( Σ aᵢ · (x₍ₙ₊₁₋ᵢ₎ − x₍ᵢ₎) )² / Σ (xⱼ − m)² i = 1 … integer part of n/2
mᵢ = Φ⁻¹( (i − 0.375) / (n + 0.25) ) u = 1/√n M = 2 · Σ mᵢ² (same i)
a₁ = −m₁/√M + 0.221157u − 0.147981u² − 2.071190u³ + 4.434685u⁴ − 2.706056u⁵
a₂ = −m₂/√M + 0.042981u − 0.293762u² − 1.752461u³ + 5.682633u⁴ − 3.582633u⁵ (n > 5)
other ranks: aᵢ = −mᵢ / √ε, ε = (M − 2m₁² − 2m₂²) / (1 − 2a₁² − 2a₂²)
(n = 4 or 5: only a₁ is corrected and ε = (M − 2m₁²) / (1 − 2a₁²))
n = 3: a₁ = 1/√2
P:
n = 3 P = (6/π) · ( arcsin √W − arcsin √(3/4) ) (exact)
4 ≤ n ≤ 11 γ = −2.273 + 0.459n w = −ln( γ − ln(1 − W) )
μ = 0.5440 − 0.39978n + 0.025054n² − 0.0006714n³
σ = exp( 1.3822 − 0.77857n + 0.062767n² − 0.0020322n³ )
n ≥ 12 w = ln(1 − W) L = ln n
μ = −1.5861 − 0.31082L − 0.083751L² + 0.0038915L³
σ = exp( −0.4803 − 0.082676L + 0.0030302L² )
P = 1 − Φ( (w − μ) / σ ) (for n ≤ 11, if ln(1 − W) ≥ γ, P is practically zero)
D'Agostino-Pearson (K² omnibus test of D'Agostino and Pearson, 1973; skewness transformation of D'Agostino, 1970, and kurtosis transformation of Anscombe and Glynn, 1983). With the central moments mₖ = Σ(xᵢ − m)ᵏ / n:
√b₁ = m₃ / m₂^(3/2) b₂ = m₄ / m₂²
Skewness:
Y = √b₁ · √( (n + 1)(n + 3) / (6(n − 2)) )
β₂ = 3(n² + 27n − 70)(n + 1)(n + 3) / ( (n − 2)(n + 5)(n + 7)(n + 9) )
ω² = −1 + √( 2(β₂ − 1) ) δ = 1 / √(ln ω) c = √( 2 / (ω² − 1) )
Z₁ = δ · ln( Y/c + √( (Y/c)² + 1 ) )
Kurtosis:
E = 3(n − 1) / (n + 1) V = 24n(n − 2)(n − 3) / ( (n + 1)²(n + 3)(n + 5) )
x = (b₂ − E) / √V
√β₁ = 6(n² − 5n + 2) / ((n + 7)(n + 9)) · √( 6(n + 3)(n + 5) / (n(n − 2)(n − 3)) )
A = 6 + (8/√β₁) · ( 2/√β₁ + √(1 + 4/β₁) )
Z₂ = [ 1 − 2/(9A) − ∛( (1 − 2/A) / (1 + x · √(2/(A − 4))) ) ] / √( 2/(9A) )
(real cube root, negative if its argument is)
K² = Z₁² + Z₂² P = P(χ² with 2 df > K²) = exp(−K²/2)
Z₁ is positive for a right tail, Z₂ for heavy tails; only K² is displayed. D'Agostino, Belanger and D'Agostino (1990) recommend at least 20 values for the kurtosis component: between 8 and 20 values, the P value of K² is approximate.
Anderson-Darling (mean and SD estimated; formulas of D'Agostino and Stephens, 1986). This test gives more weight to the tails of the distribution than Kolmogorov-Smirnov does:
zᵢ = (x₍ᵢ₎ − m) / s
A² = −n − (1/n) · Σ (2i − 1) · [ ln Φ(zᵢ) + ln(1 − Φ(z₍ₙ₊₁₋ᵢ₎)) ]
A²* = A² · (1 + 0.75/n + 2.25/n²) (displayed statistic)
A²* ≥ 0.6 P = exp(1.2937 − 5.709·A²* + 0.0186·A²*²)
0.34 ≤ A²* < 0.6 P = exp(0.9177 − 4.279·A²* − 1.38·A²*²)
0.2 ≤ A²* < 0.34 P = 1 − exp(−8.318 + 42.796·A²* − 59.938·A²*²)
A²* < 0.2 P = 1 − exp(−13.436 + 101.14·A²* − 223.73·A²*²)
Variance displays the corrected statistic A²*; some programs display the uncorrected A², with the same P.
Kolmogorov-Smirnov in Lilliefors's version (1967), in which the mean and SD are estimated from the data, which rules out the classic Kolmogorov table:
D = max over i of max( i/n − Φ(zᵢ), Φ(zᵢ) − (i − 1)/n )
if n > 100: D is replaced by D · (n/100)^0.49 and n by 100 in the following formula
P = exp( −7.01256 · D² · (n + 2.78019) + 2.99587 · D · √(n + 2.78019)
− 0.122119 + 0.974598/√n + 1.67997/n ) (Dallal and Wilkinson, 1986)
if P > 0.10: displayed as ">0.1000"
The Dallal and Wilkinson approximation is accurate only for small P values: beyond 0.10, Variance gives only a bound. A decision remains possible as long as α ≤ 0.10 (P > 0.10 ≥ α: "Yes"); with a larger α, "Passed normality test" displays "Undetermined (P > 0.10)".
Lognormality. The same tests are applied to the ln xᵢ. A lognormal distribution takes only positive values: if a data set contains a zero or negative value, its lognormality tests are not computed, the statistic row displays "Values <= 0" and "Passed normality test" is "No".
Likelihood comparison. Each model has two parameters estimated by maximum likelihood; each probability is e^ℓ of the model divided by the sum of the two (formulas in chapter 10). They are computed only if n ≥ 3 and all values are strictly positive.
QQ plot. For the value of rank i, theoretical quantile zᵢ = Φ⁻¹((i − 0.375)/(n + 0.25)) (Blom positions); predicted value = m + s · zᵢ.
Reading the results#
The "Normality tests" tab has one column per data set. Under the heading "Normal distribution", each checked test gives three rows:
- its statistic: "D'Agostino-Pearson test: statistic" (K²), "Anderson-Darling test: statistic" (
A²*), "Shapiro-Wilk test: statistic" (W) or "Kolmogorov-Smirnov test: statistic" (D); "Too few values" if the test cannot be computed; - "P value";
- "Consistent with normality at α = 0.05": "Yes" if P > α, "No" otherwise ("Undetermined (P > 0.10)" when the Kolmogorov-Smirnov P value is known only to be greater than 0.10 and α exceeds 0.10).
The heading "Lognormal distribution" repeats these rows for the logarithms; "Likelihood comparison" gives "Probability of normal" and "Probability of lognormal"; "Number of values" ends the tab.
The output table "QQ plot" has as X column "Actual" (the sorted observed values) and one "name (predicted)" column per data set; the point graph is created automatically. The points of a normal sample line up around the line Y = X; a regular curvature signals skewness (for a right tail, the upper points fall below the line), an S shape tails that are too heavy or too light, and an isolated point an extreme value.
A low P value ("No") indicates a probably real departure, whose nature the QQ plot, skewness and kurtosis tell you; "Yes" only means that the departure is not detected with this number of values. "Probability of normal" = 0.8 gives the normal model a relative weight of 80% against the lognormal model alone: it is not the probability that the data are normal.
Worked example#
Data: the One factor sample "Two groups (t test)", columns "Wild type" (12 values) and "Knock-out" (10 values), with all options checked. Results of the normality test:
| Row | Wild type | Knock-out |
|---|---|---|
| D'Agostino-Pearson test: statistic | 5.097 | 1.665 |
| P value | 0.0782 | 0.4349 |
| Anderson-Darling test: statistic | 0.5034 | 0.4534 |
| P value | 0.2048 | 0.2709 |
| Shapiro-Wilk test: statistic | 0.9115 | 0.9193 |
| P value | 0.2229 | 0.3511 |
| Kolmogorov-Smirnov test: statistic | 0.1989 | 0.2065 |
| P value | >0.1000 | >0.1000 |
The "Consistent with normality at α = 0.05" rows are "Yes" everywhere. Hand calculation for "Wild type" (sorted values in chapter 10):
m = 5.250917 moments (denominator n): m₂ = 0.111925 m₃ = −0.036351 m₄ = 0.046299
√b₁ = −0.036351 / 0.111925^1.5 = −0.97079 b₂ = 0.046299 / 0.111925² = 3.69588
D'Agostino-Pearson
skewness: Y = −1.75012 β₂ = 3.43255 ω² = 1.20570 δ = 3.26984 c = 3.11817
Z₁ = −1.75043
kurtosis: E = 2.53846 V = 0.601462 x = 1.49240 √β₁ = 1.53926 A = 21.2745
Z₂ = 1.42575
K² = 1.75043² + 1.42575² = 5.0968 P = exp(−5.0968 / 2) = 0.0782
Kolmogorov-Smirnov (s = 0.349428): the maximum gap is at the 4th rank
z₍₄₎ = (5.206 − 5.250917) / 0.349428 = −0.1285 Φ(−0.1285) = 0.4489
D = 0.4489 − 3/12 = 0.1989; Dallal and Wilkinson formula: P = 0.221 > 0.10
Anderson-Darling
A² = 0.46690 A²* = 0.46690 × (1 + 0.75/12 + 2.25/144) = 0.50338
0.34 ≤ A²* < 0.6: P = exp(0.9177 − 4.279 × 0.50338 − 1.38 × 0.50338²) = 0.2048
Shapiro-Wilk
a₁ … a₆ = 0.5474 0.3326 0.2345 0.1589 0.0924 0.0304
Σ aᵢ (x₍₁₃₋ᵢ₎ − x₍ᵢ₎) = 1.10644 Σ(x − m)² = 1.34310 W = 1.10644² / 1.34310 = 0.91149
L = ln 12 = 2.48491 μ = −2.81589 σ = 0.51323
z = (ln(1 − 0.91149) − μ) / σ = (−2.42459 + 2.81589) / 0.51323 = 0.7624
P = 1 − Φ(0.7624) = 0.2229
All four tests "pass", although "Wild type" is clearly skewed (G1 = −1.12, because of the value 4.432): with 12 values, they lack power. The one closest to rejection is D'Agostino-Pearson, in which the skewness component (Z₁ = −1.75) dominates. Logarithms make a left skew worse: on the ln values, D'Agostino-Pearson rejects ("P value" 0.0313, "No") and the likelihood comparison does not settle the question ("Probability of normal" 0.6024). Nothing justifies a logarithmic transformation here; the value 4.432, however, deserves a check (chapter 12, Outlier Detection).
The tests do not all see the same departures. Copy the variable Age of the Multivariable sample "Clinical study" (40 ages spread almost uniformly from 31 to 67 years, kurtosis −1.14) into a One factor table: D'Agostino-Pearson (P = 0.0251) and Shapiro-Wilk (P = 0.0469) reject normality, Anderson-Darling (P = 0.0844) and Kolmogorov-Smirnov (P = 0.0967) do not. The variable Time passes all four tests (Shapiro-Wilk: P = 0.1112), but "Probability of lognormal" is 0.8338: the data lean toward the lognormal model without imposing it.
Reporting the results#
"The distribution of each group was examined with a QQ plot and with the Shapiro-Wilk test, chosen a priori (Wild type: W = 0.912, P = 0.22, n = 12; Knock-out: W = 0.919, P = 0.35, n = 10). With such sample sizes, this test has low power; it shows no departure from normality." State the test, the statistic, P and n, but never write "the data are normal".
Common pitfalls#
- Concluding normality from a "Yes" obtained with 10 values, or giving up a parametric test because of a "No" on 500 barely skewed values.
- Using the test as an automatic switch between the t test and the Mann-Whitney test: this two-step procedure alters the error rates of the final test (Rochon et al., 2012). Decide on the basis of the nature of the variable and earlier data.
- Forgetting zeros in a lognormality test: a variable that contains zeros (or negative values) is not lognormal; Variance indicates this with "Values <= 0".
- Reading ">0.1000" as a value. The Kolmogorov-Smirnov P value is not computed beyond 0.10; with an α of 0.10 or more, the "Passed" row of this test displays "No" although P exceeds 0.10: read the "P value" row.
Frequency Distribution#
The Frequency Distribution analysis counts the values of each data set in bins of equal width, or by distinct value, and produces the corresponding histogram, or the cumulative distribution. It is the basic tool for seeing the shape of a distribution: symmetry, number of modes, isolated values, floor or ceiling effects, impossible values.
When to use it#
- To see the shape of a sample of a few dozen values or more. With fewer than 20 to 30 values, a graph of the individual points (scatter plot by column) shows the data better: a histogram of 10 values mostly reflects the chance of sampling.
- To compare the shape of several groups: Variance uses the same bins for all the data sets analyzed together.
- To tabulate a discrete variable (score, number of events per subject) with "No bins: each distinct value".
- To obtain the cumulative distribution: proportion of values below a threshold, approximate reading of a percentile, comparison of two entire distributions.
Assumptions and checks#
The analysis performs no test, but two choices change the picture: the width of the bins and their position. Too wide, they hide the structure (two modes merge); too narrow, they mostly show noise. Two classic rules guide the choice:
- Sturges' rule (1926): about log₂ n + 1 bins, suited to roughly normal data and small n, too few bins for large samples;
- Freedman and Diaconis' rule (1981): width 2 × IQR / ∛n, robust to extreme values because it is based on the interquartile range.
Check that your conclusions hold up with another width (half or double) and with a shift of the limits by half a bin. Set the limits according to the resolution of the measurement and the question asked, never to obtain a shape that "looks normal".
Step by step in Variance#
- Display a One factor, XY or Two factors table and choose Analysis › Describe and Explore › Frequency Distribution. Each data set gives a column: each column of a One factor table; all the Y values of one data set of an XY table (X is ignored); all the rows and all the replicates of one data set of a Two factors table.
- Options tab:
- "Tabulate": "Data points" (counts, by default), "Relative frequencies (fractions)" or "Relative frequencies (percentages)";
- "Create cumulative distribution" (unchecked): cumulative counts or frequencies;
- "Bins": "Automatic bin width" (default), "Bin width below" or "No bins: each distinct value";
- "Bin width": width of the bins (1 by default), used only with "Bin width below";
- "Center of first bin (empty = automatic)": center of the first bin (empty by default; a decimal comma is accepted).
- Data sets tab: check the data sets, then OK. Variance creates the output table and its histogram.
Calculations#
Automatic width, computed on the values of all the checked data sets pooled (n ≥ 2):
w₀ = 2 · IQR / ∛n (Freedman and Diaconis; IQR = Q3 − Q1, "type 6" quartiles)
if IQR = 0: w₀ = range / (log₂ n + 1) (Sturges)
w = w₀ rounded to a "round" value: write w₀ = f × 10ᵏ (1 ≤ f < 10) and
f < 1.5 → 1; f < 2.25 → 2; f < 3.5 → 2.5; f < 7.5 → 5; otherwise 10
Center of the first bin: c₁ = value entered, otherwise round(minimum / w) × w
Bin j (j = 0, 1, 2…): [c₁ − w/2 + j·w, c₁ + w/2 + j·w)
lower limit included, upper limit excluded; the last bin contains the maximum
Relative frequency = count / number of values counted in the data set (× 100 for %)
Cumulative distribution = sum of the counts of the bins up to the current bin
Details:
- Same bins for all data sets: the width and the center of the first bin are computed on the pooled values, and empty bins are kept (count 0).
- "No bins: each distinct value": one row per distinct value found across all the data sets.
- Values not counted. A value below the lower limit of the first bin is counted in no bin; a warning at the top of the results gives their number. This happens only if you enter a center of the first bin greater than the minimum + w/2; the relative frequencies are then computed on the counted values only.
- Values on a limit. A value equal to a limit goes into the bin of which it is the lower limit, even when the binary floating point calculation would place it just below (0.3 with limits every 0.1: 0.3/0.1 is 2.9999… in binary): Variance brings back onto the limit any position that differs from it only by a rounding error (10⁻⁹ in bin widths).
Reading the results#
The "Frequency distribution" tab has one row per bin, identified by its center (six significant digits), and one column per data set: counts, fractions or percentages, cumulative or not depending on the options. The limits of a bin are center ± w/2. The output table "Histogram" is an XY table (X column "Bin center", one data set per column); Variance plots a bar histogram from it. The fractions of a cumulative distribution end at 1, the percentages at 100.
Worked example#
Data: the One factor sample "Two groups (t test)", default options. The 22 pooled values give the automatic width:
Q1 (h = 23 × 0.25 = 5.75) = 5.23725 Q3 (h = 17.25) = 6.3895 IQR = 1.15225
w₀ = 2 × 1.15225 / ∛22 = 2.3045 / 2.80204 = 0.8224 → f = 8.224 ≥ 7.5 → w = 1
c₁ = round(4.432 / 1) × 1 = 4 → bins [3.5, 4.5), [4.5, 5.5), [5.5, 6.5), [6.5, 7.5)
| Bin center | Wild type | Knock-out |
|---|---|---|
| 4 | 1 | 0 |
| 5 | 8 | 0 |
| 6 | 3 | 5 |
| 7 | 0 | 5 |
Four bins for 22 values is few (Sturges' rule would give log₂ 22 + 1 = 5.5). With "Bins" = "Bin width below", "Bin width" = 0.5 and "Center of first bin (empty = automatic)" = 4.5:
| Bin center | Wild type | Knock-out |
|---|---|---|
| 4.5 | 1 | 0 |
| 5 | 5 | 0 |
| 5.5 | 6 | 1 |
| 6 | 0 | 3 |
| 6.5 | 0 | 1 |
| 7 | 0 | 4 |
| 7.5 | 0 | 1 |
The value 4.432 is alone in its bin, and the "Knock-out" distribution looks irregular: with 10 values, these irregularities mean nothing. With the automatic bins and "Create cumulative distribution" in percentages, "Wild type" gives 8.333, 75, 100 and 100, "Knock-out" 0, 0, 50 and 100: all the "Wild type" values and half of the "Knock-out" values are below 6.5.
Finally, enter 5.5 as the center of the first bin (width 0.5): the first limit becomes 5.25, and the six "Wild type" values below 5.25 disappear from the table, which now counts only 6 values out of 12 in this column; a warning reports the values not counted.
Reporting the results#
"Histogram of the values of each group (bins of width 0.5 centered from 4.5 to 7.5; n = 12 and 10)." Give the width and the limits (or centers) of the bins, say whether they are counts or percentages, and recall n.
Common pitfalls#
- Drawing a histogram of too few values and attributing a shape to it.
- Choosing the width until the hoped-for shape appears, or not saying which width was used.
- Entering a center of the first bin that is too large: the lower values are not counted (the warning gives their number); compare the total of the counts with the number of values.
- Comparing groups of different sizes in raw counts: percentages compare shapes, counts compare numbers. Say which one you are showing.
- Pooling groups with different means in a single histogram: the bimodality obtained is an artifact of the mixture.
- Confusing a histogram with a bar chart: the bars of a histogram represent contiguous intervals of a continuous variable.
Per-Row Summary#
The Per-Row Summary analysis computes statistics row by row: either on all the values of the row, data sets and replicates pooled, or for each data set separately. It is used mostly to summarize repeated experiments with a mean and an error at each row, for example to plot a mean curve with its error bars.
When to use it#
- The data sets of an XY table are repeats of the same experiment (one curve per independent experiment): "Statistics of the entire row (all data sets)" gives, for each X, the mean, SD, SEM, N and CI, and an output table to plot.
- In a Two factors table, to describe each cell (row × data set): "Statistics of each data set (replicates)".
- In a One factor table where each row is a subject and each column a repeated measurement: mean per subject.
Assumptions and checks#
Pooling the values of a row makes sense only if they measure the same quantity under the same condition. If the data sets are different conditions (two sexes, two treatments), the SD of the row mixes the difference between conditions with the variability within each. SD, SEM and CI assume independent values: technical replicates of the same sample measure the precision of the measurement, not biological variability. The t CI assumes a normal distribution; with N = 2 or 3 it is very wide (t(0.975, 2) = 4.30), which is information, not a defect.
Step by step in Variance#
- Display an XY, Two factors or One factor table and choose Analysis › Describe and Explore › Per-Row Summary.
- Options tab: "Calculate" is "Statistics of the entire row (all data sets)" (default) or "Statistics of each data set (replicates)"; "Confidence level (%)" (95 by default) applies only to the first choice.
- Data sets tab: check the data sets to include (only the checked data sets are pooled), then OK.
Calculations#
Entire row: for row r, all the values (all replicates) of the checked data sets
N = number of values m = mean s = SD (denominator N − 1)
SEM = s / √N Sum = Σ values
CI = m ± t(1 − α/2, N − 1) · SEM
Each data set: mean, SD and n of the replicates of the data set on the row
(mean, SD and N as entered, for a table of means and errors)
Rows without values are omitted; with N = 1, SD, SEM and CI stay empty.
Reading the results#
With "Statistics of the entire row", the "Row statistics" tab has one row per row of the table (identified by its title, its X value or "Row n") and the columns "Mean", "SD", "SEM", "N", "Sum" and "95% CI" ("lower limit to upper limit"). The output table "Row means" (an XY table if the original table has X values, Two factors otherwise) contains a "Row mean" data set in mean, SD and N format: Plot These Results plots the mean curve or bars with their error bars.
With "Statistics of each data set", the tab has one column per data set; each cell is a text "mean ± SD (n=N)", with the number of significant digits chosen ("Significant digits"). There is no output table.
Worked example#
Data: the Two factors sample "Two-way ANOVA (3 rows × 2 data sets, triplicates)" (rows Placebo, Low dose and High dose; data sets Male and Female; three replicates). With the default options, the Placebo row pools 20.96, 20.26, 19.82 (Male) and 22.09, 24.29, 24.01 (Female):
N = 6 Σ = 131.43 m = 21.905 s = 1.9026 SEM = 1.9026 / √6 = 0.77674
t(0.975, 5) = 2.5706 → 95% CI = 21.905 ± 2.5706 × 0.77674 = 19.91 to 23.90
Variance displays "Mean" 21.9, "SD" 1.903, "SEM" 0.7767, "N" 6, "Sum" 131.4 and "95% CI" 19.91 to 23.9; the Low dose and High dose rows give means of 31.35 and 41.66, with SDs of 3.694 and 6.185.
With "Statistics of each data set (replicates)", the Placebo row gives "20.35 ± 0.575 (n=3)" for Male and "23.46 ± 1.2 (n=3)" for Female. The SD of the entire row (1.90) is clearly larger than those of each sex (0.575 and 1.2), because it contains the difference between the sexes (20.35 versus 23.46). Here the data sets are different groups: the right description is that of each data set, and their comparison belongs to the two-way ANOVA (chapter 14). The mean of the entire row would make sense only if Male and Female were two repeats of the same condition.
Reporting the results#
"Each point represents the mean ± SD of three independent experiments (n = 3 per concentration)." State what N represents (experiments, animals, wells) and what the error bar is.
Common pitfalls#
- Pooling different conditions in one row: the SD no longer means anything.
- Taking technical replicates for independent repeats: the SEM and CI become misleading.
- Ignoring a variable N: a missing value reduces N on some rows; look at the "N" column.
- Using the entire row on a table of means and errors (box above).
Area Under Curve#
The Area Under Curve analysis computes, for each data set of an XY table, the area between the curve (the points joined by segments) and a horizontal baseline, by the trapezoidal method. It separates the area above the baseline from the area below it, and identifies the peaks, portions of the curve lying on the same side of the baseline.
When to use it#
- To summarize a curve with one number: drug exposure (area under the concentration curve), response of a glucose tolerance test, cumulative response during an experiment. This is the summary measures method (Matthews et al., 1990): one area per subject, then a comparison of these areas between groups by a t test or an ANOVA (chapter 14), rather than a test at each time.
- To measure the area of peaks above a background level (chromatogram, sensor signal).
Assumptions and checks#
- Linear interpolation. The trapezoidal method joins the points with segments. It is close to the true area if the points are dense relative to the curvature; for a convex curve such as an exponential decay, each segment lies above the curve and the area is overestimated, all the more so as the points are widely spaced.
- Observed range only. The area goes from the first to the last X; nothing is extrapolated. In pharmacokinetics, the area from 0 to infinity adds to the observed area the term C_last/kₑ, which Variance does not compute.
- Baseline fixed in advance. It changes the result as much as the data do: choose it according to the question (total response or response above the basal level) before seeing the results.
- No standard error. The replicates of a row are replaced by their mean; the analysis gives neither an SE nor a CI of the area. To compare groups, enter one data set per subject (or per independent experiment) and analyze the areas obtained.
Step by step in Variance#
- Enter the data in an XY table, one curve per data set, and choose Analysis › Describe and Explore › Area Under Curve.
- Options tab:
- "Baseline": "Y = value below" (default), "Mean of the first N points" or "Mean of the last N points";
- "Baseline Y": the baseline for "Y = value below" (0 by default);
- "N points": number of points for the two other choices (3 by default);
- "Ignore peaks smaller than (% of the largest peak)" (10 by default);
- "Ignore peaks defined by fewer than N points" (1 by default);
- "Include peaks below the baseline" (unchecked).
- Data sets tab: check the curves, then OK.
Calculations#
Preparation: mean of the replicates of each row; rows without X or without Y ignored;
points sorted by increasing X
Baseline b: value entered, or mean of the first (last) N Y values after sorting
Segment [xᵢ, xᵢ₊₁], with dᵢ = yᵢ − b and Δx = xᵢ₊₁ − xᵢ:
dᵢ and dᵢ₊₁ of the same sign (or zero): area = (dᵢ + dᵢ₊₁) / 2 · Δx
opposite signs: the curve crosses b at xᵢ + t·Δx, t = dᵢ / (dᵢ − dᵢ₊₁),
and the segment gives two triangles: dᵢ·t·Δx/2 and dᵢ₊₁·(1 − t)·Δx/2
Positive area = sum of the areas above b
Negative area = sum of the absolute values of the areas below b
Total Area = Positive area − Negative area (net area: trapezoids of y − b)
A peak is a run of segments on one side of the baseline. "Start X" and "End X" are the first and last observed points of the peak (its area extends to the crossings with the baseline); "Peak X" is the point farthest from the baseline, "Peak height" this distance |y − b|, "Area" the area of the peak. A peak is listed if its height is not zero, if it has at least the requested number of points, if its height reaches the requested percentage of the largest height of the peaks that can be listed (those with enough points; those below the baseline only if "Include peaks below the baseline" is checked) and, if it lies below the baseline, if "Include peaks below the baseline" is checked. These filters affect only the list of peaks: the three total areas always cover the entire curve.
Reading the results#
The "Area under curve" tab has one column per data set and the rows "Baseline" (value used), "Total Area", "Positive area", "Negative area" and "Number of peaks" (peaks listed). The "Peaks" tab gives, under the name of each data set, one row "Peak" or "Peak (below baseline)" per peak, with the columns "Start X", "End X", "Peak X", "Peak height" and "Area". An area is expressed in the unit of Y multiplied by that of X (for example mg/L × h). The analysis creates neither an output table nor a graph.
Worked example#
Data: the XY sample "Exponential decay (time course)" (concentration measured in duplicate, from 0 to 11 h). Variance uses the mean of the duplicates: 100.75, 72.74, 56.135, 41.56, 31.045, 26.15, 21.65, 17.175, 16.035, 15.295, 12.46, 13.32.
Baseline Y = 0 (default options), step of 1 h:
first trapezoid = (100.75 + 72.74) / 2 × 1 = 86.745
area = (100.75 + 13.32) / 2 + (72.74 + 56.135 + … + 12.46) = 57.035 + 310.245 = 367.28
"Total Area" and "Positive area" are 367.3; the "Peaks" tab shows a single peak, from X = 0 to 11, with "Peak X" 0 and "Peak height" 100.8.
Baseline "Mean of the last N points", N = 3:
b = (15.295 + 12.46 + 13.32) / 3 = 13.6917
net area = 367.28 − 13.6917 × 11 = 216.67
between 9 and 10 h, the curve crosses b: d = 1.6033 then −1.2317
t = 1.6033 / (1.6033 + 1.2317) = 0.5655 (X = 9.566)
negative area = 1.2317 × (1 − 0.5655) / 2 + (1.2317 + 0.3717) / 2 = 0.2676 + 0.8017 = 1.0692
positive area = 216.67 + 1.0692 = 217.74
Variance displays "Baseline" 13.69, "Total Area" 216.7, "Positive area" 217.7 and "Negative area" 1.069, with a single peak (from 0 to 9 h, area 217.7). The portion below the baseline (height 1.23) is not listed, even with "Include peaks below the baseline": it does not reach 10% of the height of the largest peak (87.06). If you also set "Ignore peaks smaller than (% of the largest peak)" to 0, it appears as a "Peak (below baseline)" from 10 to 11, with area 1.069.
The two areas answer two questions: 367 measures the total exposure between 0 and 11 h; 217 measures the excess above the final level, the difference (150.6 = 13.69 × 11) being the rectangle below the baseline. Neither is the area from 0 to infinity.
Reporting the results#
"The area under the concentration curve between 0 and 11 h, computed by the trapezoidal method above a baseline of zero, was 367 (concentration units × h)." For a comparison: "an AUC was computed for each animal, and the AUCs of the two groups were compared with Welch's t test". Specify the baseline, the time interval and the method.
Common pitfalls#
- Choosing the baseline after seeing the results.
- Reading "Total Area" as the sum of the listed peaks: it is the net area of the entire curve, with the area below the baseline subtracted, whether or not that area is listed.
- Comparing areas computed over different X intervals, or on curves sampled differently.
- Comparing the areas of the mean curves of two groups without an associated error: compute one area per subject.
- Overlooking a missing point: the method joins the points present, and a missing time is bridged by a single segment.
- Forgetting that the peak threshold is computed on the largest of the listed peaks: if the troughs below the baseline are not listed, they do not enter the calculation.
Observed vs. Expected Frequencies#
This analysis compares the counts observed in k categories with the counts expected under a hypothesis fixed in advance: chi-square goodness-of-fit test or, for two categories, exact binomial test.
When to use it#
- To test a genetic segregation ratio (3:1, 1:2:1, 9:3:3:1), an expected distribution of sexes or phenotypes, a uniform distribution (events per day of the week), or the conformity of a sample to a reference population.
- To cross two variables (treatment × outcome), use a contingency table (chapter 15).
Assumptions and checks#
- The values are counts of independent individuals, each classified in a single category: never measurements, percentages or means.
- The expected proportions are fixed before the experiment (theory, reference population). If they are estimated from the same data (an allele frequency to test Hardy-Weinberg equilibrium, for example), one degree of freedom must be removed per estimated parameter; Variance always uses k − 1.
- The chi-square is an approximation, valid if the expected counts are large enough: according to Cochran's rule (1954), none below 1 and at most 20% below 5. Otherwise, merge categories or, for two categories, use the exact binomial test.
Step by step in Variance#
- Enter the counts in a Proportions table (one row per category, the row label naming the category) or in the first column of a One factor table. Only the first data set checked is analyzed. An empty row between two categories is ignored.
- Choose Analysis › Describe and Explore › Observed vs. Expected Frequencies.
- Options tab:
- "Expected values": one expected value per category, in the order of the rows, separated by commas, semicolons or spaces (
9, 3, 3, 1); since the comma is a separator, write decimals with a point (56.25); - "Expected values are": "Percentages" (default) or "Actual numbers";
- "Test": "Binomial if two categories, chi-square otherwise" (default), "Chi-square goodness of fit" or "Binomial test (two categories)"; with more than two categories, it is always the chi-square.
- "Expected values": one expected value per category, in the order of the rows, separated by commas, semicolons or spaces (
- OK.
Calculations#
N = Σ Oᵢ (observed counts), k categories
"Percentages" Eᵢ = eᵢ / Σe × N (normalized values: 9, 3, 3, 1 is equivalent
to 56.25, 18.75, 18.75, 6.25)
"Actual numbers" Eᵢ = eᵢ as entered (their sum must equal N)
Pearson chi-square goodness of fit, without continuity correction:
χ² = Σ (Oᵢ − Eᵢ)² / Eᵢ df = k − 1 P = P(χ²(df) > χ²)
Exact binomial test (k = 2): X = O₁, n = N, p₀ = E₁ / N
two-sided P = sum of the binomial probabilities of all outcomes
at most as probable as the observed outcome
The expected values are always scaled to the observed total N: Eᵢ = N · eᵢ / Σ e, whether you entered percentages, proportions or counts ("Actual numbers"). If the counts entered do not sum to N, a "Note" row says so; the binomial test uses p₀ = E₁/N, hence the expected proportion of the first category.
Reading the results#
The "Observed vs expected" tab shows, under the heading "Chi-square goodness of fit", the rows "Chi-square", "df", "P value" and "Significance code"; or, under the heading "Binomial test", "P value (two-sided)" and "Significance code". The "Discrepancies" tab gives, for each category, "Observed", "Expected" and "Difference" (observed − expected); the contribution (O − E)²/E of each category to the chi-square shows where a discrepancy comes from. There is no output table or graph.
Worked example#
Data: the Proportions sample "Distribution of categories": 315, 108, 101 and 32 peas ("Round yellow", "Round green", "Wrinkled yellow", "Wrinkled green"), N = 556, the counts of Mendel's experiment. Hypothesis: 9:3:3:1 segregation. Enter 9, 3, 3, 1 in "Expected values", with "Percentages":
E = 556 × 9/16 = 312.75; 556 × 3/16 = 104.25; 104.25; 556 × 1/16 = 34.75
χ² = 2.25²/312.75 + 3.75²/104.25 + 3.25²/104.25 + 2.75²/34.75
= 0.0162 + 0.1349 + 0.1013 + 0.2176 = 0.4700 df = 3
P = P(χ²₃ > 0.4700) = 0.9254
Variance displays "Chi-square" 0.47, "df" 3, "P value" 0.9254 and "Significance code" ns; the "Discrepancies" tab gives the expected values 312.8, 104.2, 104.2 and 34.75 and the differences 2.25, 3.75, −3.25 and −2.75. The discrepancies are very small compared with what chance produces with 556 peas: the data are compatible with the 9:3:3:1 ratio, without proving it (a high P value does not prove H0, chapter 10).
With two categories, for example 71 offspring with the dominant phenotype and 29 with the recessive phenotype (One factor table, 71 and 29 in two rows, "Expected values" = 75, 25), the default choice gives the exact binomial test: "P value (two-sided)" 0.3564. The chi-square ("Chi-square goodness of fit") gives χ² = 0.8533, 1 df, P = 0.3556: with 100 individuals, the approximation is excellent.
Reporting the results#
"The observed counts (315, 108, 101 and 32; N = 556) do not differ significantly from the expected 9:3:3:1 proportions (chi-square goodness of fit: χ² = 0.47; 3 df; P = 0.93)."
Common pitfalls#
- Entering percentages or measurements as observed values: the test depends on N, and 50% of 10 is not 50% of 1000.
- Estimating the expected proportions from the data without reducing the degrees of freedom.
- Entering the expected values incorrectly: a number of values different from the number of categories, a decimal comma, an order different from that of the rows.
- Applying the chi-square to small expected counts.
- Concluding that a model is proven because P is large.
Multiple P Values (FDR)#
This analysis corrects for multiplicity a list of P values obtained elsewhere, entered one per row: control of the false discovery rate (FDR, q values) or of the risk of at least one false positive (FWER, adjusted P values). The notions and the formulas of each method are in chapter 10 (section "Multiple comparisons"), with an example of ten P values processed by all the methods; this section describes the analysis itself.
When to use it#
- Many tests were done separately (one per gene, protein, biomarker or secondary endpoint, possibly in other analyses or other programs) and their P values must be interpreted together.
- If the Variance analysis that produced the P values offers its own correction (multiple comparisons of an ANOVA, Row-by-Row t Tests), use that option instead.
Assumptions and checks#
- Each P value must be valid (assumptions of its test met); the P values of discrete tests (Fisher's exact test on small counts) make the corrections conservative.
- The family is defined before seeing the results and contains all the tests performed, not only those that seem interesting.
- Dependence: Bonferroni and Holm are valid whatever the dependence between the tests, as is Benjamini-Yekutieli for the FDR; Šídák, Holm-Šídák and Hochberg (the step-up version of Holm, at least as powerful) assume independent or positively dependent tests; Benjamini-Hochberg controls the FDR for independent or positively dependent tests, and the two-stage procedure (BKY) has been proven for independent tests.
Step by step in Variance#
- In a One factor table, enter the P values in the first column, one per row, as numbers between 0 and 1 (the title of each row can name the test). Only the first data set checked is analyzed; empty cells are ignored; a value outside [0, 1] stops the analysis with the message "P values must be between 0 and 1".
- Choose Analysis › Describe and Explore › Multiple P Values (FDR).
- Options tab:
- "Approach": "FDR, two-stage method of Benjamini, Krieger and Yekutieli" (default), "FDR: Benjamini and Hochberg", "FDR: Benjamini and Yekutieli", "Bonferroni", "Šídák", "Holm", "Holm-Šídák" or "Hochberg (step-up)";
- "Desired FDR Q or alpha (%)": Q for the FDR methods, α for the others, as a percentage (5 by default, from 0.001 to 50).
- OK.
Calculations#
With P₍₁₎ ≤ … ≤ P₍ₘ₎ the m sorted P values (detailed formulas in chapter 10):
FDR (q values)
Benjamini-Hochberg q₍ᵢ₎ = min over j ≥ i of min(1, m · P₍ⱼ₎ / j)
Benjamini-Yekutieli same formula multiplied by c(m) = 1 + 1/2 + … + 1/m
BKY (two-stage) Q' = Q / (1 + Q); stage 1: BH at level Q' → r₁ discoveries;
stage 2: BH at level Q' · m / (m − r₁) (if 0 < r₁ < m);
q = smallest Q that makes the hypothesis a discovery
(computed by bisection)
FWER (adjusted P values)
Bonferroni min(1, m · P)
Šídák 1 − (1 − P)^m
Holm max over j ≤ i of min(1, (m − j + 1) · P₍ⱼ₎)
Holm-Šídák max over j ≤ i of 1 − (1 − P₍ⱼ₎)^(m − j + 1)
Hochberg min over j ≥ i of min(1, (m − j + 1) · P₍ⱼ₎) (step-up)
Decision: "Yes" if q ≤ Q (FDR) or if adjusted P ≤ α (FWER)
For BKY, the discoveries are those of the procedure applied at the chosen Q; they coincide with q ≤ Q.
Reading the results#
The "Summary" tab gives "Count of P values" and "Discoveries" (FDR methods) or "Significant" (other methods). The "P value stack" tab begins with the name of the method ("Two-stage FDR of Benjamini, Krieger and Yekutieli", "Benjamini-Hochberg (FDR)", "Benjamini-Yekutieli (FDR)", "Bonferroni-Dunn", "Šídák-Bonferroni", "Holm" or "Holm-Šídák"), then gives one row per P value, from smallest to largest, identified by the title of its row: "Rank", "P value", "q value" or "Adjusted P", and "Discovery?" or "Significant?".
The output table "P values in order" (X = "Rank", Y = "P value") is plotted as points. If all the null hypotheses were true, the P values would follow a uniform distribution and the points would line up roughly along the line going from 0 at rank 0 to 1 at rank m; an excess of small P values on the left signals real effects.
A q value is a level of FDR: declaring as discoveries all the hypotheses with q ≤ 0.05 means accepting that, on average, at most 5% of these discoveries are false. It is not the probability that a particular hypothesis is false.
Worked example#
Twelve P values (twelve biomarkers) entered in one column: 0.0002, 0.0011, 0.0034, 0.0087, 0.0121, 0.0198, 0.0312, 0.0455, 0.134, 0.278, 0.512, 0.893. With "Desired FDR Q or alpha (%)" = 5, the number of positive results depends on the method:
| Method | "Discoveries" or "Significant" |
|---|---|
| FDR, two-stage method of Benjamini, Krieger and Yekutieli | 8 |
| FDR: Benjamini and Hochberg | 6 |
| FDR: Benjamini and Yekutieli | 3 |
| Bonferroni, Šídák, Holm, Holm-Šídák | 3 |
Hand calculation:
BH q₍₆₎ = min(12 × 0.0198/6, 12 × 0.0312/7, …) = 0.0396 ≤ 0.05
q₍₇₎ = min(12 × 0.0312/7, 12 × 0.0455/8, …) = 0.0535 > 0.05 → 6 discoveries
BKY Q' = 0.05 / 1.05 = 0.047619
stage 1: thresholds k × Q'/12 = k × 0.003968; P₍₆₎ = 0.0198 ≤ 0.02381,
P₍₇₎ = 0.0312 > 0.02778 and no later rank passes → r₁ = 6
stage 2: m − r₁ = 6; thresholds k × Q'/6 = k × 0.007937;
P₍₈₎ = 0.0455 ≤ 0.0635, P₍₉₎ = 0.134 > 0.0714 and later ones → 8 discoveries
Holm 12 × 0.0002 = 0.0024; 11 × 0.0011 = 0.0121; 10 × 0.0034 = 0.034;
9 × 0.0087 = 0.0783 > 0.05 → 3 significant
With the default method, the "q value" column gives 0.0322 at rank 7 and 0.0412 at rank 8, then 0.0732 at rank 9. At rank 8, q is lower than the P value (0.0455): the two-stage procedure estimates the number of true null hypotheses among the 12 at 6 and thereby gains power. Among the 8 discoveries, at most 0.05 × 8 = 0.4 false discovery is expected on average, without knowing which one.
Reporting the results#
"The P values of the 12 biomarkers were corrected with the two-stage procedure of Benjamini, Krieger and Yekutieli (FDR Q = 5%); 8 biomarkers are discoveries (q ≤ 0.041)." State the method, the size of the family and Q or α.
Common pitfalls#
- Choosing the method or Q after seeing the results.
- Entering only the "interesting" P values: the correction makes sense only on the complete family.
- Pooling different families (primary endpoint and exploratory analyses) in one stack.
- Entering "<0.001": it is text, and is ignored; enter the numeric value.
- Reading a q value as the P value of an isolated test.
Curve Smoothing, Derivative and Integral#
This analysis transforms each curve of an XY table into a new curve: smoothed with a Savitzky-Golay filter, differentiated (first or second derivative), or integrated. The result is an XY output table, plotted automatically as lines.
When to use it#
- Smoothing a noisy signal to display it or to follow its trend. Statistical analyses (regressions, tests) are done on the raw data: smoothing creates correlated values and an apparent precision that distort P values and CIs.
- Differentiating to obtain a rate (change in a concentration, growth) or to locate the point of maximum slope (maximum of the first derivative, inflection point of a sigmoid).
- Integrating to obtain a cumulative quantity: area under the curve up to each X, cumulative amount excreted.
Assumptions and checks#
- The Savitzky-Golay filter (1964) was established for equally spaced X values; Variance fits each local polynomial as a function of the X values themselves, so unequally spaced X values are taken into account (with equally spaced X values, the classic filter is recovered exactly).
- Differentiation by differences amplifies noise: the second derivative of a noisy curve is often unusable without prior smoothing.
- The replicates are replaced by their mean and the points are sorted by X; rows without X or without Y are ignored.
Step by step in Variance#
- Display an XY table and choose Analysis › Describe and Explore › Curve Smoothing, Derivative and Integral.
- Options tab:
- "Operation": "Smooth (Savitzky-Golay)" (default), "First derivative", "Second derivative" or "Integral";
- "Neighbors on each side": k neighbors on each side (2 by default, from 0 to 50), that is a window of 2k + 1 points; 0 does not smooth;
- "Degree of the smoothing polynomial": "Zero (moving average)", "Second" (default), "Fourth" or "Sixth";
- "Smooth before differentiating/integrating" (unchecked): smooths first, with the two previous settings;
- "Integral: Y value at the first X": starting value of the integral (0 by default).
- Data sets tab: check the curves, then OK.
Calculations#
Smoothing (point i, k neighbors, degree d):
window = points i − k … i + k, truncated at the ends of the data
polynomial of degree min(d, number of distinct X values in the window − 1), fitted by least
squares as a function of the offset xj − xi; smoothed value = polynomial at xi
example, 5 points and degree 2: ŷᵢ = (−3yᵢ₋₂ + 12yᵢ₋₁ + 17yᵢ + 12yᵢ₊₁ − 3yᵢ₊₂) / 35
degree 0: simple moving average of the points in the window
First derivative: (yᵢ₊₁ − yᵢ₋₁) / (xᵢ₊₁ − xᵢ₋₁); at the ends, difference with
the single neighbor: (y₂ − y₁)/(x₂ − x₁) and (yₙ − yₙ₋₁)/(xₙ − xₙ₋₁)
Second derivative: the first derivative applied twice (points i − 2 … i + 2)
Integral: I₁ = Y0; Iᵢ₊₁ = Iᵢ + (yᵢ + yᵢ₊₁)/2 · (xᵢ₊₁ − xᵢ) (trapezoids)
Smoothing and derivatives are computed on the values minus the first point of the curve (an exact subtraction for nearby values), the means of replicates included: this changes neither the smoothed curve nor its derivatives, and values close to 10⁹ keep all their digits.
Practical consequences:
- a degree greater than or equal to 2k makes the polynomial pass through all the points of the window: no smoothing (degree 4 or 6 with 2 neighbors, degree 2 with 1 neighbor);
- at the ends, the window is truncated and the smoothing weakens: with 2 neighbors and degree 2, the first and last points do not change;
- the moving average (degree 0) flattens peaks and distorts the ends of a steep curve.
Reading the results#
The "Summary" tab gives "Operation" (the label of the operation) and "Data sets" (number of curves processed). The output table ("Smoothed", "First derivative", "Second derivative" or "Integral", followed by the name of the table) has the X column of the original table and one column per data set; its X values are those of all the data sets pooled, each data set having a value only at its own X values. A derivative is expressed in units of Y per unit of X, an integral in units of Y × X.
Worked example#
Data: the XY sample "Exponential decay (time course)" (means of the duplicates given in the Area Under Curve section).
- "Integral" (Y0 = 0): 0, 86.745, 151.1825… and 367.28 at X = 11, exactly the "Total Area" of Area Under Curve with a baseline of zero: the last value of the cumulative integral is the area under the curve.
- "First derivative": at X = 0, (72.74 − 100.75)/1 = −28.01; at X = 1, (56.135 − 100.75)/(2 − 0) = −22.3075 concentration units per hour.
- "Smooth (Savitzky-Golay)", default settings: at X = 5, (−3 × 41.56 + 12 × 31.045 + 17 × 26.15 + 12 × 21.65 − 3 × 17.175)/35 = 25.734; at X = 0, the value stays 100.75. With "Fourth", the output table reproduces the means exactly; with "Zero (moving average)", X = 0 gives (100.75 + 72.74 + 56.135)/3 = 76.54, very far from 100.75.
On the XY sample "Dose-response (log dose, replicates)", the first derivative of "Control" is maximal at X = −6.5 (50.60, versus 49.63 at X = −7); with "Smooth before differentiating/integrating", it is maximal at X = −7 (48.45, versus 47.37 at −6.5). The point of maximum slope therefore lies between −7 and −6.5, which agrees with the LogEC50 of the nonlinear regression (−6.780, chapter 17); but the derivative locates it only at the nearest measurement point. To estimate a parameter, fit a model.
Reporting the results#
"For the figure, the curves were smoothed with a Savitzky-Golay filter (second-degree polynomial, 5-point window); all analyses were performed on the raw data."
Common pitfalls#
- Analyzing smoothed data (regression, test) as if each point were an independent measurement.
- Smoothing unequally spaced X values with a filter that takes only ranks into account.
- Choosing a degree that is too high for the number of neighbors: the curve does not change.
- Differentiating a noisy curve twice without prior smoothing.
- Processing together curves that do not have the same X values: values are missing in the output table.
References#
- Anderson TW, Darling DA. A test of goodness of fit. Journal of the American Statistical Association 1954;49:765-769.
- Anscombe FJ, Glynn WJ. Distribution of the kurtosis statistic b₂ for normal samples. Biometrika 1983;70:227-234.
- Benjamini Y, Hochberg Y. Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society, Series B 1995;57:289-300.
- Benjamini Y, Krieger AM, Yekutieli D. Adaptive linear step-up procedures that control the false discovery rate. Biometrika 2006;93:491-507.
- Benjamini Y, Yekutieli D. The control of the false discovery rate in multiple testing under dependency. Annals of Statistics 2001;29:1165-1188.
- Cochran WG. Some methods for strengthening the common χ² tests. Biometrics 1954;10:417-451.
- D'Agostino RB. Transformation to normality of the null distribution of g₁. Biometrika 1970;57:679-681.
- D'Agostino RB, Belanger A, D'Agostino RB Jr. A suggestion for using powerful and informative tests of normality. The American Statistician 1990;44:316-321.
- D'Agostino R, Pearson ES. Tests for departure from normality. Empirical results for the distributions of b₂ and √b₁. Biometrika 1973;60:613-622.
- D'Agostino RB, Stephens MA (eds). Goodness-of-Fit Techniques. Marcel Dekker, 1986.
- Dallal GE, Wilkinson L. An analytic approximation to the distribution of Lilliefors's test statistic for normality. The American Statistician 1986;40:294-296.
- Freedman D, Diaconis P. On the histogram as a density estimator: L₂ theory. Zeitschrift für Wahrscheinlichkeitstheorie und verwandte Gebiete 1981;57:453-476.
- Holm S. A simple sequentially rejective multiple test procedure. Scandinavian Journal of Statistics 1979;6:65-70.
- Hyndman RJ, Fan Y. Sample quantiles in statistical packages. The American Statistician 1996;50:361-365.
- Joanes DN, Gill CA. Comparing measures of sample skewness and kurtosis. Journal of the Royal Statistical Society, Series D (The Statistician) 1998;47:183-189.
- Lilliefors HW. On the Kolmogorov-Smirnov test for normality with mean and variance unknown. Journal of the American Statistical Association 1967;62:399-402.
- Matthews JNS, Altman DG, Campbell MJ, Royston P. Analysis of serial measurements in medical research. BMJ 1990;300:230-235.
- Motulsky HJ. Intuitive Biostatistics, 4th ed. Oxford University Press, 2018.
- Razali NM, Wah YB. Power comparisons of Shapiro-Wilk, Kolmogorov-Smirnov, Lilliefors and Anderson-Darling tests. Journal of Statistical Modeling and Analytics 2011;2:21-33.
- Rochon J, Gondan M, Kieser M. To test or not to test: preliminary assessment of normality when comparing two independent samples. BMC Medical Research Methodology 2012;12:81.
- Royston P. Remark AS R94: a remark on algorithm AS 181: the W-test for normality. Applied Statistics 1995;44:547-551.
- Savitzky A, Golay MJE. Smoothing and differentiation of data by simplified least squares procedures. Analytical Chemistry 1964;36:1627-1639.
- Shapiro SS, Wilk MB. An analysis of variance test for normality (complete samples). Biometrika 1965;52:591-611.
- Šidák Z. Rectangular confidence regions for the means of multivariate normal distributions. Journal of the American Statistical Association 1967;62:626-633.
- Sturges HA. The choice of a class interval. Journal of the American Statistical Association 1926;21:65-66.
- Zar JH. Biostatistical Analysis, 5th ed. Pearson, 2010.