Datalens.ai
← All algorithms

STATISTICAL-TESTS

page_trend_test

Perform Page's Test, a measure of trend in observations between treatments.

Example of usage

Python API reference included; executable data demonstration pending review.

Usage / limitations

+Use when: Evaluate statistical evidence.

−Limitations: Check input requirements, mathematical assumptions and version-specific behaviour before using.

Mathematical formula

See method documentation: implementation and assumptions vary.
Sample dataShow
{
  "variable": "clinical_study",
  "domain": "Illustrative clinical trial and laboratory measurements",
  "feature_names": [
    "baseline_score",
    "treated_score",
    "control_score"
  ],
  "records": [
    {
      "participant": "P01",
      "baseline_score": 12.0,
      "treated_score": 8.0,
      "control_score": 13.0
    },
    {
      "participant": "P02",
      "baseline_score": 15.0,
      "treated_score": 11.0,
      "control_score": 16.0
    },
    {
      "participant": "P03",
      "baseline_score": 14.0,
      "treated_score": 10.0,
      "control_score": 16.0
    },
    {
      "participant": "P04",
      "baseline_score": 18.0,
      "treated_score": 13.0,
      "control_score": 19.0
    },
    {
      "participant": "P05",
      "baseline_score": 16.0,
      "treated_score": 11.0,
      "control_score": 17.0
    },
    {
      "participant": "P06",
      "baseline_score": 20.0,
      "treated_score": 15.0,
      "control_score": 21.0
    },
    {
      "participant": "P07",
      "baseline_score": 17.0,
      "treated_score": 12.0,
      "control_score": 19.0
    },
    {
      "participant": "P08",
      "baseline_score": 19.0,
      "treated_score": 14.0,
      "control_score": 20.0
    },
    {
      "participant": "P09",
      "baseline_score": 21.0,
      "treated_score": 16.0,
      "control_score": 23.0
    },
    {
      "participant": "P10",
      "baseline_score": 22.0,
      "treated_score": 17.0,
      "control_score": 22.0
    },
    {
      "participant": "P11",
      "baseline_score": 24.0,
      "treated_score": 18.0,
      "control_score": 25.0
    },
    {
      "participant": "P12",
      "baseline_score": 23.0,
      "treated_score": 17.0,
      "control_score": 24.0
    }
  ]
}

Code example (Python)

# DataLens.ai example — page_trend_test
# Domain: illustrative clinical trial and laboratory measurements.
# Sample input is included by Copy input + code + test.
import numpy as np
from scipy import stats
baseline = np.array([row["baseline_score"] for row in clinical_study["records"]], dtype=float)
treated = np.array([row["treated_score"] for row in clinical_study["records"]], dtype=float)
control = np.array([row["control_score"] for row in clinical_study["records"]], dtype=float)

# Test an ordered improvement across three repeated time points.
# Here lower symptom scores indicate improvement over successive visits.
measurements = np.column_stack([baseline, control, treated])
result = stats.page_trend_test(measurements, predicted_ranks=[2, 3, 1])
assert np.isfinite(result.statistic) and 0 <= result.pvalue <= 1

print("Expected output verified")