Durbin-Watson statistic calculator
Six residuals that keep switching sign give squared differences of 3.19 against squared residuals of 1.19, a Durbin-Watson d above 2.5 that hints at negative autocorrelation. A value near 2 means your regression left little first-order structure. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Residuals
- 0.5, -0.3, 0.8, -0.2, 0.1, -0.4
- N
- 6
- Durbin watson
- 2.6806722689
- Statistic
- 2.6806722689
- Sum sq residuals
- 1.19
The Durbin-Watson statistic is the classic first check analysts run after ordinary least squares: it asks whether successive residuals still share a linear dependence that the model failed to absorb. A value near two usually signals little first-order autocorrelation; values near zero suggest positive serial correlation (common in time-ordered economic and sensor data); values near four suggest negative serial correlation.
What the Durbin-Watson statistic measures
The Durbin-Watson statistic compresses that idea into one ratio. When consecutive residuals are almost equal, differences are small and d approaches zero—positive autocorrelation. When consecutive residuals flip sign repeatedly, differences inflate and d moves toward four—negative autocorrelation.
When residuals behave like white noise, the expected value of d is near two for large samples. Textbooks then compare d to lower and upper critical bounds that depend on sample size, number of regressors, and significance level; those tables are a second step. This tool focuses on computing d correctly and transparently from the residual list you already have, so you can feed the result into your preferred critical-value routine, report it in a paper appendix, or freeze it in a regression diagnostic pipeline.
It does not re-fit the model, invent lag-2 tests, or estimate Newey-West standard errors—those are separate intents. Keeping the surface narrow makes the landing match the search phrase people actually type: a Durbin-Watson statistic calculator for residuals.
What you can do with it
Econometrics homework and lab reports
Students paste OLS residuals from a textbook series and confirm d before looking up lower and upper critical bounds for their sample size.
Sensor and time-series QC
Calibration notebooks check first-order residual structure after a linear trend fit without installing a full stats package in the browser.
FAQ
What does a Durbin-Watson value near 2 mean?
Values near 2 usually indicate little first-order residual autocorrelation. Values near 0 suggest positive autocorrelation; values near 4 suggest negative autocorrelation. Formal decisions still need critical bounds for your n and regressor count.
What if I send fewer than two residuals?
The statistic needs successive differences, so at least two finite residual observations are required.
Why is an all-zero residual series rejected?
When every residual is zero the residual sum of squares is zero, so d is undefined.
What does a Durbin-Watson value near 0 or near 4 mean?
Near 0, consecutive residuals are almost equal, a sign of positive autocorrelation that is common in time-ordered economic and sensor data. Near 4, the residuals keep flipping sign, which points to negative autocorrelation.
Does the calculator tell me whether the autocorrelation is significant?
No. It gives d with a rule-of-thumb label. For a formal decision, compare d with the lower and upper critical bounds for your sample size, number of regressors and significance level.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/stat/durbin-watson \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"residuals":[0.5,-0.3,0.8,-0.2,0.1,-0.4]}'const res = await fetch("https://api.kit.forhosting.com/stat/durbin-watson", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"residuals": [
0.5,
-0.3,
0.8,
-0.2,
0.1,
-0.4
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/durbin-watson",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"residuals": [
0.5,
-0.3,
0.8,
-0.2,
0.1,
-0.4
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/durbin-watson", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"residuals":[0.5,-0.3,0.8,-0.2,0.1,-0.4]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"residuals":[0.5,-0.3,0.8,-0.2,0.1,-0.4]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/durbin-watson", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"residuals": [
0.5,
-0.3,
0.8,
-0.2,
0.1,
-0.4
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.durbin_watson",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
This capacity accepts an ordered residual series, computes d = Σ(e_t − e_{t−1})² / Σ e_t² in a single deterministic pass, and returns the statistic with supporting sums so you can audit the arithmetic offline. You need at least two finite residuals; empty, singleton, non-numeric, or all-zero series are rejected with invalid_input rather than a silent NaN.
What the Durbin-Watson statistic measures
After you fit a linear or other parametric regression, the residual vector e_t = y_t − ŷ_t should ideally look like unstructured noise if the model and the sampling assumptions hold. First-order autocorrelation means that e_t tends to track e_{t−1}: large positive residuals follow large positive residuals, or the series alternates in a patterned way. The numerator sums squared successive differences (e_t − e_{t−1})² from t = 2 to n; the denominator is the residual sum of squares Σ e_t².
How to submit residuals and read the JSON result
The interpretation labels are rule-of-thumb bands only: below about 1.5 suggests positive autocorrelation, above about 2.5 suggests negative autocorrelation, and the middle band suggests little first-order structure—they are not formal hypothesis-test decisions. Send a field named residuals (aliases e, errors, and values are accepted) as a JSON array of at least two finite numbers in time or row order. Digit strings inside the array are coerced when they parse to finite floats; objects, booleans, empty strings, NaN, and Infinity fail with invalid_input naming the offending index. You may also pass a JSON-array string or a simple delimited list of numbers if your client serializes text. On success the response echoes n (series length), durbin_watson and statistic (the same rounded d value under both keys for convenience), sum_sq_residuals, sum_sq_diff, a coarse interpretation label for UI copy, and the rounded residual vector for audit. Pricing for a successful API call is a flat $0.002 under the item unit; validation failures never consume balance.
Edge cases, precision, and what this tool does not do
If every residual is exactly zero, the denominator vanishes and Durbin-Watson is mathematically undefined; that case also fails instead of returning Infinity or zero. Related searches such as full Breusch-Godfrey lag tests, Ljung-Box on residuals, variance inflation factors, or refitting OLS with HAC standard errors belong on other landings; this page is dedicated to the Durbin-Watson d statistic from an ordered residual array. Use d as the fast first screen, then escalate to formal critical bounds or lag-robust inference when your sample size, design matrix, and significance level demand it. Extremely large residual values can still overflow double range—the same limit any browser or Worker JSON path shares—so scale your series if you work in pathological units.
Integration use cases
Regression CI diagnostics
Pipelines export residual arrays after each model fit and freeze Durbin-Watson JSON so a silent data-order bug cannot slip into production scoring.
Technical questions
How do I calculate the Durbin-Watson statistic from residuals?
POST an ordered residuals array (at least two finite numbers) to the endpoint or use the free browser form. The response includes durbin_watson = Σ(e_t − e_{t−1})² / Σ e_t² plus the supporting sums.
Is the browser Durbin-Watson calculator free?
Yes. The in-browser runner uses the same library as the API and costs nothing. The API charges $0.002 per successful request from your prepaid KIT balance.