RainbowStats · Command reference
MANN_KENDALL
Test whether values tend to increase or decrease over time, and estimate the rate of change with Sen’s slope.
Syntax
MANN_KENDALL(series)Supply one dated series with 3 to 3,000 usable observations. The operator omits undated or nonfinite observations, sorts by time and rejects repeated timestamps. Sen’s slope is the median of all pairwise changes divided by elapsed time in fractional UTC calendar years.
Try it in the workspace
Fit=MANN_KENDALL(UNRATE)
EX(Fit,"slideshow")For the monthly unemployment rate, slope units are percentage points per year. The two-sided normal approximation accounts for tied values and applies a continuity correction. Its p-value assumes independent observations. Seasonality, serial dependence or a level shift can affect interpretation. Small samples may need an exact test.
Do the regression residuals drift over time?
Fit monthly housing starts against building permits over 2000–2024, then test the dated residuals for a monotonic trend.
Housing=SERIES_BETWEEN(LIST(HOUSTNSA,PERMITNSA),20000101,20241231)
Fit=REGRESSION(Housing)
Trend=EX(Fit,"mann_kendall")
EX(Trend,"slideshow")Read EX(Trend,"slope") as the estimated annual change in residuals, in units of the dependent variable. A positive slope means actual minus fitted tends to rise over time. Use EX(Fit,"autocorrelation") to inspect dependence in the original residuals. The Mann–Kendall p-value assumes independent observations and can be misleading when the residuals are serially correlated.
Available extracts
Save the result as Fit, then run an extract such as EX(Fit,"summary").
| Key | Result |
|---|---|
summary | Sample size, omissions, score, standardized statistic, p-value and slope. |
chart | Observed values and fitted Sen trend over time. |
acf | ACF and PACF of detrended residuals. Lags count observations, so their duration varies when dates are irregular. |
slope | Numeric Sen slope in series units per calendar year. |
score | Numeric S, the number of increasing pairs minus decreasing pairs. |
z | Numeric continuity-corrected standardized S. |
pvalue | Numeric two-sided approximate p-value. |
slideshow | Default display with summary, trend chart and residual diagnostics. |
Reference result
For the 100 annual observations in R’s datasets::Nile (1871–1970), date each value January 1 of its year. Expect S = −1,387, Z = −4.12807, p = 0.0000365826 and Sen’s slope = −2.6 series units per year.