DPredict · Guide test 227
Seasonal Kendall or Hirsch–Slack test
Tests monotonic trend while accounting for recurring seasonal strata.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Monotonic trend tests (Mann–Kendall family) — Is the series drifting steadily up or down over time — after allowing for seasons, a covariate or serial correlation — and by how much per period?
In Monotonic trend tests (Mann–Kendall family), choose Test = Seasonal Kendall (Hirsch–Slack).
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Seasonal Kendall (Hirsch–Slack) test
Alternative
Your data
Simulated with known truthShaded bands mark alternate cycles of 4 seasons; each season is compared only with itself.
If H₀ were true
- The reference: how z varies across samples when H₀ is true (normal approximation).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .080).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- Mann–Kendall score within season g
- seasons per cycle
The verdict
z = 1.75, p = .080
p > α = .050: compatible with H₀
Seasonality cannot fake a trend here. Adding the season variances assumes seasons are independent; with serial correlation use the covariance-corrected version.
- Statistic
- 1.749
- p-value
- 0.0804
Seasonal Kendall (Hirsch–Slack) test on 48 observations in cycles of 4 seasons: z = 1.75, p = .080. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: no common monotonic trend after accounting for seasons.
Assumptions
Comparable seasonal strata over years; adequate temporal dependence treatment. Basic seasonal Kendall assumes independence across relevant year comparisons.
Formula
Parameters and notation
Ss is a Mann–Kendall score computed only within season s. Hirsch–Slack-type extensions estimate cross-season covariance.
Structure of the method
Partition observations by prespecified recurring season, compute a Mann–Kendall score within each season across years, and combine scores with the appropriate variance/cross-season covariance. The ordering and seasonal labels define the comparisons; season-level offsets are controlled by design rather than estimated as an arbitrary neural representation.
Estimated and nuisance parameters
Estimate within-season tie corrections and, for correlated-season variants, covariance between seasonal scores. An optional seasonal Sen slope is a separate magnitude estimate. Basic seasonal Kendall and Hirsch–Slack-type covariance adjustments are related variants, not guaranteed numerically equivalent calls.
Settings and design choices
Choose seasonal frequency, missing-season policy, year alignment, directional alternative, and independent versus correlated-season version. Finer strata reduce seasonal confounding but leave fewer observations per stratum. The supplied smk.test example illustrates the basic seasonal test; csmk.test documents a correlated-season alternative.
Fitting and adaptation
Rebuild strata and covariance estimates when moving from monthly to quarterly or another sampling scale. Any bootstrap should resample an appropriate year/block structure while retaining seasons. Do not choose the seasonal grouping by whichever choice gives the smallest p value; that requires separate selection adjustment.
Sensitivity and robustness
Inspect dependence across seasons and years, unequal seasonal coverage, season-specific trends, ties, and shifts in measurement practice. Opposing seasonal trends can cancel in a common score. Plot seasonal trajectories and report whether the common-trend interpretation is substantively justified rather than relying on a single combined significance value.
How to use and calibrate
Use the standardized score’s normal distribution with the covariance scheme appropriate to the selected seasonal version.
Example application
Test a long-run water-quality trend while accounting for monthly seasonality.
Interpretation and pitfalls
Watch out
Summing independent-season variances when seasons are correlated can misstate uncertainty; seasonal structure must be prespecified.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Monthly seasonal Kendall example; frequency=12 defines seasons. This does not automatically correct arbitrary serial dependence.
Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: trend
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
x<-ts(rep(sin(2*pi*(1:12)/12),10)+rnorm(120)+seq_len(120)*.005,frequency=12);print(trend::smk.test(x))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Not run — Syntax checked; runtime not verified in the final environment · needs trend
set.seed(2026)
x<-ts(rep(sin(2*pi*(1:12)/12),10)+rnorm(120)+seq_len(120)*.005,frequency=12);print(trend::smk.test(x))
Sources
- trend — trend · smk.testAuthor documentation/source reviewed: trend 1.1.10.search.r-project.org
- trend — trend · csmk.testAuthor documentation/source reviewed: trend 1.1.10.search.r-project.org
- smk.testsearch.r-project.org
- csmk.testsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Python launcher syntax checked; R backend runtime not verified · R: Syntax checked; runtime not verified in the final environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 227, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT227.