This ABA Theil-Sen slope calculator summarizes a straight trend with the median of the eligible slopes between observed pairs. The construction can reduce the influence of an extreme Y value compared with ordinary least squares, but it cannot rescue a weak design. Keep the direct graph, complete pairwise-slope audit, and collection conditions beside the fitted line.
Clinicians & ABA Professionals / Data, Outcomes and Clinical Decision-Making.
The question this slope can answer
Sen's original paper defines a robust regression-coefficient estimate as the median of pairwise slopes. The official NIST Theil-Sen Fit documentation describes a simple linear fit with fixed X and omits pairs whose X values are equal. Current SciPy theilslopes documentation uses the same median-slope foundation and exposes two intercept conventions. These references describe a statistical method. They do not make it an ABA standard, validate a clinical measure, or authorize a decision.
Use this worksheet for a prespecified descriptive question about the straight median-pairwise trend across fixed elapsed-time values. It needs numeric X and Y values, a defensible linear summary, and a reason to treat X as fixed or effectively free of relevant measurement error. The output is a slope in Y units per X unit plus an intercept under a declared convention.
That is narrower than asking whether an intervention caused change. Sequential observations from one person can be autocorrelated, exposed to changing conditions, and span phase boundaries. The calculation does not turn those observations into independent units or estimate experimental control. A direct time-series graph and the design logic remain primary.
The current BACB Ethics Codes and BCBA Test Content Outline provide professional context for competent measurement, data display, documentation, and interpretation. Neither requires Theil-Sen regression. The Standards for Educational and Psychological Testing support tying an interpretation to its intended use and supporting evidence.
A prespecified trend record
Complete this section before generating or sorting slopes.
Design fieldPrespecified entryObservable construct and Y definitionIndependent unit or series identityX definition, origin, and unitsWhy X is fixed for this useY units and recording ruleLinear-summary rationaleInclusion and exclusion rulesDuplicate-X ruleExclude only the undefined pairwise slope; retain both rowsMissing-data rulePrimary intercept conventionJoint median residual or separate mediansData version and extraction timeIntended descriptive useQualified reviewers
Choose the X origin and units deliberately. Numbering sessions 1, 2, 3 answers a different rate question from using elapsed days when visits are irregularly spaced. Changing only the origin shifts the intercept without changing the slope. Reversing X reverses the slope sign. Neither recoding should be chosen merely to improve the answer's appearance.
Input table
Retain one row per observation in the original order.
Observation keyFixed X valueY valuePhase or conditionSource/version noteObservation 1Observation 2Observation 3...
Do not silently average duplicate X rows. Two observations collected at the same X value may both matter. They remain in the input, while the slope between that pair is undefined because its denominator is zero. Missing rows, condition changes, redefinitions, and justified exclusions belong in the visible record.
Pairwise slopes and the audit total
For every unordered pair i<j with different X values, calculate:
sij = (yj-yi) / (xj-x_i)
With n rows there are n(n-1)/2 total unordered pairs. Classify each pair as eligible when xj != xi or as duplicate-X excluded when xj = xi. Check:
eligible slope count + duplicate-X pair count = n(n-1)/2
That accounting covers every unordered pair. A steep, flat, or surprising eligible slope stays in the list. Robustness comes from the median operation, not from deleting inconvenient slopes.
PairChange in XChange in YEligible?Pairwise slope or reason excluded1 with 21 with 32 with 3...
Sort all eligible slopes from smallest to largest. For an odd count, select the middle value. For an even count, average the two middle values. Keep full precision for the median calculation and round only the displayed result.
Slope and intercept conventions
The slope estimate is:
bhat = median(sij for all i<j with xj != xi)
The original slope construction does not uniquely determine an intercept. This page displays two conventions so a reviewer can see whether the choice matters.
- Joint median-residual convention, documented by NIST:
ajoint = median(yi - bhat xi). - Separate-medians convention, the SciPy default:
aseparate = median(yi) - bhat median(xi).
Name one convention as primary before calculating. Report the other as a sensitivity result, not as a second preferred answer. For either selected intercept a, calculate yhati=a+bhat xi and residual ei=yi-yhati from unrounded values. A residual display can reveal curvature, phase shifts, changing spread, or a single influential region that the slope alone hides.
Fictional five-point example
Consider fabricated values X=[1,2,3,4,5] and Y=[2,4,5,8,30]. They are arithmetic fixtures, not client or practice data. The ten eligible slopes are:
[2, 1.5, 2, 7, 1, 2, 8.6666666667, 3, 12.5, 22]
Sorted, they are [1,1.5,2,2,2,3,7,8.6666666667,12.5,22]. Because there are ten slopes, the median is the average of the fifth and sixth values:
b_hat = (2+3)/2 = 2.5
For the joint convention, the unrounded residual candidates yi-bhat xi are [-0.5,-1,-2.5,-2,17.5]; their median is ajoint=-1. The fitted line is y_hat=-1+2.5x.
For the separate-medians convention, median(Y)=5 and median(X)=3, so a_separate=5-(2.5)(3)=-2.5. The slope is identical, but the intercept and fitted values differ. That visible difference is why the convention must be declared.
The last fabricated Y value creates several very large pairwise slopes, yet the median remains 2.5. This illustrates reduced sensitivity in the fixture, not permission to ignore the point. Review its accuracy, clinical meaning, relationship to any condition change, and whether one straight line is inadequate.
Boundary and invariance checks
Exact points on y=1+2x return slope 2 and intercept 1 under both displayed conventions. Adding a constant to every Y value leaves the slope unchanged and shifts both intercepts by that constant. Multiplying every Y value by a positive constant multiplies the slope and intercept by that constant. Reversing the X direction reverses the slope sign and changes the intercept according to the new coding.
When all X values are equal, every pair is a duplicate-X pair and no slope exists. When some X values repeat, retain the rows, exclude only their undefined within-X slopes, and audit the count. If fewer than one eligible slope remains, the result is undefined. A constant Y series with varying X yields slope zero, but zero does not by itself mean stable measurement, effective treatment, or absence of clinically important variation.
Meaningful measurement error in X exceeds this worksheet's fixed-X premise. Deming regression addresses a different errors-in-variables question when both axes are noisy and a defensible variance ratio is available. Do not switch methods after viewing which slope looks preferable.
Interpreting a robust descriptive trend
Use the ABA Theil-Sen slope calculator as an inspectable record. Report the construct, X and Y units, X origin, row count, total pair count, duplicate-X exclusions, eligible slope count, sorted middle slope or slopes, median slope, primary intercept convention, both intercept values, fitted values, residual review, graph, and intended use. State whether the observations are sequential, nested, or otherwise dependent.
The slope is a compact description of a linear trend in the observed data. It is not a treatment-effect estimate, a test of statistical significance, a prediction guarantee, or a substitute for visual analysis. It does not show who benefited, identify a functional relation, establish reliability, or define a clinically important rate of change.
Theil-Sen can still mislead when the line is a poor summary, when phase changes are pooled, or when the predictor does not have the fixed meaning assumed. A qualified reviewer should inspect the graph, excluded and duplicate-X pairs, residual pattern, observation quality, contextual changes, and the perspectives of the person and caregivers affected by the decision.
Conditions that need another method
Pause for abrupt phase changes, strong curvature, time-varying measurement, serial dependence that matters to the intended conclusion, repeated or clustered series, unequal weights, censored values, uncertain observation identity, or a predictor with meaningful measurement error. A phase-comparison worksheet, segmented model, time-series method, hierarchical model, Deming regression, or another approach may be more suitable, but method selection needs qualified review.
Obtain statistical or research-methods review for confidence intervals, hypothesis tests, permutation procedures, bootstrap choices, covariate adjustment, extrapolation, sample-size planning, or generalization beyond the displayed observations. This page intentionally calculates no confidence interval or p-value.
Data protection and provenance
Use the minimum information needed for review. Keep identifiable row-level material only in approved systems, restrict access, and retain a versioned audit trail. The HHS Privacy Rule summary and HHS Security Rule summary describe federal requirements for regulated entities. State and organizational rules may add duties. This page is not legal advice.
Copyable result record
Result fieldValueData versionConstruct and Y definitionX definition, origin, and unitsFixed-X rationaleObservation rows nTotal unordered pairsEligible pairwise slopesDuplicate-X excluded pairsSorted middle slope value or valuesMedian slope b_hatPrimary intercept conventionJoint interceptSeparate-medians interceptFitted and residual display reviewedPhase, dependence, and context notesIntended interpretation and limitsReviewer and review date
Related resources
- ABA Phase Level, Trend, Variability and Immediacy Calculator for Clinicians
- ABA Tau and Baseline-Trend Correction Sensitivity Calculator for Clinicians
- ABA Deming Regression Measurement-Error Ratio Sensitivity Calculator for Clinicians
- ABA Kendall Tau-B Tied-Pair Rank Association Calculator for Clinicians
Sources
- Sen, Estimates of the Regression Coefficient Based on Kendall's Tau.
- NIST Theil-Sen Fit documentation.
- SciPy theilslopes documentation.
- Behavior Analyst Certification Board Ethics Codes.
- BCBA Test Content Outline, Sixth Edition.
- Standards for Educational and Psychological Testing.
- HHS Summary of the HIPAA Privacy Rule.
- HHS Summary of the HIPAA Security Rule.