Statistical tests
Plots › Statistical tests (or in the explorer, under the project), in four modes chosen at the top left.
Between classes, variable by variable: each quantitative variable compared between the classes of a qualitative variable.
Two classes (A, the reference, and B): Welch's t test (the default, unequal variances), Student's t or Mann–Whitney (on ranks). Effect: log2 of the ratio of the means B / A (when both means are positive) or Cohen's d. Volcano plot: the effect against -log10(p).
Two classes paired by a key ("Pair by": a variable or an observation ID, the year for two sectors followed over the same years): for each variable, the rows of A and B that share a key, and have a value, make the pairs, and the differences B − A go through the paired t test (the default) or Wilcoxon's signed-rank test. The table gives each variable's number of pairs and the means of A and B over those pairs; the effect is log2 of the ratio of those means (when both are positive) or Cohen's d_z (the mean difference over the standard deviation of the differences). A variable with fewer than three pairs is not tested. A key may appear only once per class: one repeated within A or B is refused, as in "Two variables".
All classes: one-way ANOVA or Kruskal–Wallis; the variables ranked by p.
p values are corrected for multiple comparisons: Benjamini–Hochberg (false discovery rate, the default), Bonferroni, or none. In colour: the variables whose corrected p passes the threshold (and, for two classes, whose effect does too).
Two variables: the test their types call for, its conditions checked, on the observations where both are known. An observation ID (site, sector, year...) can make the groups, like a qualitative variable.
Two qualitative variables: the contingency table and Pearson's chi-square test of independence, with Cramér's V. In red and in blue, the cells more or less frequent than if the two variables were independent (adjusted residual beyond ±1.96). When the expected counts are too small for the chi-square test (one below 1, or more than 20 % below 5: Cochran's rule), Fisher's exact test is recommended; for a 2 × 2 table it is always given, with the odds ratio. Beyond 2 × 2 and 200 observations, its p value is simulated (100,000 tables).
A measurement and a qualitative variable: the measurement compared between the groups, in box plots. Two groups: Welch's t test and Mann–Whitney (exact below 50 values on each side with no ties; otherwise by the normal approximation with continuity correction: the same calculation on every R version). More: one-way ANOVA, Welch's ANOVA and Kruskal–Wallis, each with its pairwise comparisons (Tukey, Games–Howell, Dunn with Holm's correction; up to 50 groups): a click on a test shows them. The rank test is recommended when normality is doubtful in a group (Shapiro–Wilk p < 0.05, or fewer than three observations), Welch's ANOVA when the variances differ (Brown–Forsythe p < 0.05).
A measurement and a qualitative variable, paired by a third variable or ID ("Pair by": the year, for two sectors of a site followed over the same years): the data stay in long format, one row per sector and year. Two levels A and B are compared on the keys both have: the differences B − A by the paired t-test (mean difference, its 95 % interval, Cohen's d_z) and by Wilcoxon's signed-rank test, the rank test recommended when the normality of the differences is doubtful (Shapiro–Wilk p < 0.05; not tested beyond 5,000 pairs, nor with constant differences, which leave Wilcoxon alone). Wilcoxon's p is exact below 50 pairs when no difference is zero or tied; otherwise the zero differences are dropped and p comes from the normal approximation with continuity correction, the same on every R version. At least three pairs are needed, and a key may appear only once per level. The rows left without a partner, and those without a value, are counted and listed; the plot joins each pair. With three levels or more, the table below can also list every pair of levels, each on its own shared keys, with Holm's correction over the pairs tested, for the test chosen above (a click on a test): when all the levels share the same keys, those of pairwise.t.test() and pairwise.wilcox.test() with paired = TRUE. A pair not tested (fewer than three shared keys, a key twice in a level, the same value in every pair) says why, and a click on a pair compares it; when A and B can't be compared, the table stays, under their reason. "Pairs of levels within each" (a qualitative variable or an ID: the site) keeps to the pairs of levels of the same group, the sectors of each site compared two by two. Holm's correction covers the pairs tested, all groups together; the raw p reads one site at a time. A level belongs to the group its rows carry: one with rows in several groups is refused, and those without a group are listed. Above the pairs comes the omnibus test, for both paired tests: Friedman's test on the keys where every level has a value (complete blocks; the keys left out for a missing level are counted), its χ², degrees of freedom and p, with Kendall's W = χ² / (n (k − 1)) as effect size (0: no agreement from one key to the next, 1: the same ranking of the levels at every key), as a sentence. Within each group, one Friedman test per group, on its own levels and complete keys, its p corrected by Holm over the groups tested; a group with fewer than three levels or fewer than two complete keys gets no test, and the reason is given.
Two measurements: Pearson's and Spearman's correlations; Spearman is recommended when normality is doubtful for either. Paired by "the observation (same row)", two measurements of the same rows (before and after, say) are compared instead: the differences Variable 2 − Variable 1, on the observations where both are known, by the same two paired tests.
The recommended test's result comes as a sentence ready for a report (copy it with the button next to it), with its effect size: Cramér's V, odds ratio, Cohen's d or d_z, rank-biserial correlation, η², ε², r or ρ. Mann–Whitney's names both groups with their medians.
Correlation matrix: the Pearson or Spearman correlations of all the quantitative variables (300 at most), each pair on the observations where both are known, p values corrected for the number of pairs. A click on a pair, in the table or the plot, tests it in "Two variables".
Before/after (BACI): a change of management on some units (the impact) compared with units left as they were (the controls), as in a before-after control-impact design. Choose a quantitative response, a time (a variable or an observation ID: the year, or dates) and a unit (a qualitative variable or an ID: the sector), then tick the impact unit(s) and the control unit(s). At each time, the gap d_t is the mean of the impact rows minus the mean of the control rows, at the times where both have a value (one row per unit and time gives the mean of the units; the times with one side only are listed and left out): with dates, the impact and the controls counted on the same day; to compare years, take the year. The event is the first time counted as "after" (a number for a time made of numbers; a date for a time made of dates, where a year is its 1 January): for a spring density that responds to the previous year's management, the year after the change. The times before it are "before"; "after" runs to an optional end, of the time's kind too (with dates, 31/12/2012 for the end of 2012: a year alone is refused, as is a date for a time made of numbers), the later times shown in grey, out of the test. With at least two times in each period, the gaps after are compared with those before: Welch's t test (the default), Student's t (equal variances: a linear model of the gap on the period) or Mann–Whitney (on ranks); the effect is the change in the mean gap, after minus before, with its 95 % interval, and the result comes as a sentence ready for a report. The plot shows the gaps over time, the event and each period's mean; until an event is entered, the gaps alone. The times are treated as independent: successive gaps that resemble each other (autocorrelation) make the p value too small. "Fit the mixed model" accounts for it: it adds to the project two variables worth 0 or 1, "BACI period (2007)" (1 from the event on, 0 before) and "BACI impact (S1 vs S2, S3)" (1 for the impact units, 0 for the controls, missing for the other units), then the linear mixed model y ~ period × impact + (1 | unit) on the rows of the impact and control units with a known time, up to the end if there is one: a random intercept per unit and, with "with CAR1 in time" (ticked by default when every unit has at least three times; impossible when a unit has several rows at the same time), a CAR1 autocorrelation along the time within each unit.
A variable of that name, or of that name followed by (2), (3)..., or of its name in the other language, that already has these values is used as it is; otherwise the variable takes the first of these names that is free (a name held by other values: other units beyond the three named, another time, a time corrected since); Ctrl+Z removes them, as for a new variable. The model joins the project (named "BACI <response>"; the same settings refit the same model) and its views open. Back in the BACI view, its BACI effect, the period × impact coefficient with its 95 % interval and p value, comes as a sentence under the test's, saying that this model accounts for the units and, with CAR1, for the autocorrelation. Its Methods text says it is the BACI model and what its two variables are worth.
This page is part of the guide installed with Nuée (USER-GUIDE.txt, also in Help › User guide).