ds@mcpanalytics.aiEmail your data and your question and get an answer about your own data, with the method shown.Email your data and question. Get an answer.
Which way is this heading? Trends over time analyses | MCP Analytics
Question

Which way is this heading?

By MCP Analytics Team | Published , updated

Compare two groups? Find what drives an outcome? Spot a trend? The question decides which statistics fit, so it is the first thing to get right.

See a worked example

How the analyses here work

Worked example

Are weekly orders at this store really rising, or is it week-to-week noise?

The data. standard_trend_test_v2.csv, the published sample file for Trend test: 105 rows; columns week_start, store_id, weekly_orders, notes. Sample data, not a customer's.

The calculation. Python, standard library only. This exact code ran against the file when this page was built, and printed the output below it.

import csv
from datetime import date
rows = list(csv.DictReader(open("standard_trend_test_v2.csv")))
week = {}
for r in rows:
    if r["week_start"] == "n/a" or not r["weekly_orders"]:
        continue  # undated or empty rows have no place in time
    if r["week_start"] in week and r["notes"] != "restated":
        continue  # a repeated week keeps its restated figure
    week[r["week_start"]] = float(r["weekly_orders"])
ds = sorted(week)
x = [(date.fromisoformat(d) - date.fromisoformat(ds[0])).days / 7
     for d in ds]
y = [week[d] for d in ds]
mx, my = sum(x) / len(x), sum(y) / len(y)
slope = (sum((a - mx) * (b - my) for a, b in zip(x, y))
         / sum((a - mx) ** 2 for a in x))
s = sum((y[j] > y[i]) - (y[j] < y[i])
        for i in range(len(y)) for j in range(i + 1, len(y)))
print(len(y), "weeks kept of", len(rows), "rows,", ds[0], "to", ds[-1])
print("least-squares slope:", round(slope, 2), "orders per week")
print("Mann-Kendall S:", s, "of", len(y) * (len(y) - 1) // 2, "pairs")
99 weeks kept of 105 rows, 2024-01-01 to 2025-12-22
least-squares slope: 0.73 orders per week
Mann-Kendall S: 4295 of 4851 pairs

What it says. The straight-line slope is 0.73 more orders each week, about 38 a year. The Mann-Kendall count agrees without assuming a straight line: of 4851 pairs of weeks, later weeks are higher in so many more pairs than lower (S = 4295) that a flat series would almost never produce it.

What it does not say. 6 rows were set aside: undated weeks, empty values, and the superseded copy of a restated week. Promotion weeks were kept; they sit above the line and pull it up a little. A rising trend says nothing about why, and it is not a forecast.

Run Trend test on this file or your own, or open its stored sample report.

Sources

Further reading on the method in the worked example. Each reference was looked up and its authors, title, year and venue confirmed between 27 October 2026 and 30 October 2026.

  1. Mann H (1945). Nonparametric Tests Against Trend. Econometrica. https://doi.org/10.2307/1907187
  2. Kendall M (1938). A new measure of rank correlation. Biometrika. https://doi.org/10.1093/biomet/30.1-2.81
  3. Hyndman R, Athanasopoulos G. Forecasting: Principles and Practice (3rd ed.). https://otexts.com/fpp3/

By MCP Analytics Team. Updated November 2026. Analysis list from the library catalog.

A delivered report from this list

Changepoint Detection: sample report Open full report →

The stored sample report for Changepoint Detection. Each analysis has its own report layout; open its page to see what it returns.