# Diagnostic Test Calculator

> Computes positive and negative predictive values, likelihood ratios, post-test probabilities, accuracy and the expected numbers of true/false positives and negatives per 1,000 people tested from a test's sensitivity, specificity and the disease prevalence.

- Calculator id: `diagnostic-test` · Category: Statistics & Probability (`statistics`) · Tool name: `calculate_diagnostic_test_predictive_values`
- Canonical page: https://tttkmbb.com/statistics/diagnostic-test · This document: https://tttkmbb.com/statistics/diagnostic-test.md · JSON definition: https://tttkmbb.com/statistics/diagnostic-test.json

## Purpose

Computes positive and negative predictive values, likelihood ratios, post-test probabilities, accuracy and the expected numbers of true/false positives and negatives per 1,000 people tested from a test's sensitivity, specificity and the disease prevalence.

**Use when:** You know a screening or diagnostic test's sensitivity and specificity and the pre-test probability (prevalence) and want to know what a positive or negative result means for an individual.

**Do not use when:** You need to compute sensitivity and specificity themselves from a 2×2 table of test results (they are TP/(TP+FN) and TN/(TN+FP)), or the inputs are fractions 0–1 (use bayes-theorem). Informational; not medical advice.

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `sensitivity_percent` | number | % | required | Percentage of people with the condition who test positive (true positive rate). (min 0, max 100) |
| `specificity_percent` | number | % | required | Percentage of people without the condition who test negative (true negative rate). (min 0, max 100) |
| `prevalence_percent` | number | % | required | Percentage of the tested population that has the condition. (> 0) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `ppv_percent` | number | % | Probability of having the condition given a positive result (post-test probability after a positive). |
| `npv_percent` | number | % | Probability of not having the condition given a negative result. |
| `post_test_probability_negative_percent` | number | % | 100 − NPV: probability of the condition despite a negative result. |
| `likelihood_ratio_positive` | number |  | sensitivity / (1 − specificity); > 10 is a strong positive result (omitted when specificity is 100 %). |
| `likelihood_ratio_negative` | number |  | (1 − sensitivity) / specificity; < 0.1 is a strong negative result (omitted when specificity is 0 %). |
| `true_positives_per_1000` | number |  | People with the condition who test positive, per 1,000 tested. |
| `false_negatives_per_1000` | number |  | People with the condition who test negative. |
| `false_positives_per_1000` | number |  | People without the condition who test positive. |
| `true_negatives_per_1000` | number |  | People without the condition who test negative. |
| `accuracy_percent` | number | % | (true positives + true negatives) / all tested. |

## Formula

`per 1000: TP = 10·prev·sens/100, FN = 10·prev − TP, TN = 10·(100 − prev)·spec/100, FP = 10·(100 − prev) − TN; PPV = TP/(TP + FP); NPV = TN/(TN + FN); LR+ = sens/(100 − spec); LR− = (100 − sens)/spec; accuracy = (TP + TN)/1000`

Predictive values depend strongly on prevalence: the same test has a much lower PPV in screening (low prevalence) than in symptomatic patients. Equivalent to Bayes' theorem with prevalence as the prior.

## Data Sources

- Altman DG, Bland JM (1994) Diagnostic tests 2: predictive values, BMJ 309:102 — https://www.bmj.com/content/309/6947/102 (peer_reviewed, retrieved 2026-09-24)
- Deeks JJ, Altman DG (2004) Diagnostic tests 4: likelihood ratios, BMJ 329:168-169 — https://www.bmj.com/content/329/7458/168 (peer_reviewed, retrieved 2026-09-24)
- Wikipedia – Sensitivity and specificity — https://en.wikipedia.org/wiki/Sensitivity_and_specificity (reference, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/diagnostic-test?sensitivity_percent=…&specificity_percent=…&prevalence_percent=…`
- `POST https://tttkmbb.com/api/v1/calculate/diagnostic-test` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/diagnostic-test · OpenAPI operationId `calculate_diagnostic_test_predictive_values` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "diagnostic-test", "inputs": {…}}`

## Example

- Screening: sensitivity 90 %, specificity 95 %, prevalence 1 %: inputs `{"sensitivity_percent":90,"specificity_percent":95,"prevalence_percent":1}` → `{"ppv_percent":15.38,"npv_percent":99.89,"post_test_probability_negative_percent":0.11,"likelihood_ratio_positive":18,"likelihood_ratio_negative":0.1053,"true_positives_per_1000":9,"false_negatives_per_1000":1,"false_positives_per_1000":49.5,"true_negatives_per_1000":940.5,"accuracy_percent":94.95}`
- Symptomatic patients: sensitivity 95 %, specificity 90 %, prevalence 30 %: inputs `{"sensitivity_percent":95,"specificity_percent":90,"prevalence_percent":30}` → `{"ppv_percent":80.28,"npv_percent":97.67,"likelihood_ratio_positive":9.5,"likelihood_ratio_negative":0.0556,"true_positives_per_1000":285,"false_positives_per_1000":70,"accuracy_percent":91.5}`

```
GET https://tttkmbb.com/api/v1/calculate/diagnostic-test?sensitivity_percent=90&specificity_percent=95&prevalence_percent=1
```

## Limitations

You need to compute sensitivity and specificity themselves from a 2×2 table of test results (they are TP/(TP+FN) and TN/(TN+FP)), or the inputs are fractions 0–1 (use bayes-theorem). Informational; not medical advice. Predictive values depend strongly on prevalence: the same test has a much lower PPV in screening (low prevalence) than in symptomatic patients. Equivalent to Bayes' theorem with prevalence as the prior. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why is the PPV only 15 % with a 95 % specific test?**

At 1 % prevalence, 990 of 1,000 people are healthy and 5 % of them (49.5) test falsely positive, against only 9 true positives; predictive values depend on prevalence, sensitivity and specificity do not.

**How do I use the likelihood ratios?**

Post-test odds = pre-test odds × LR. LR+ above 10 or LR− below 0.1 change the probability substantially; values near 1 make the test uninformative.

## Related

- [Bayes' Theorem Calculator](https://tttkmbb.com/statistics/bayes-theorem.md) — Same calculation with probabilities as fractions.
- [Odds Ratio Calculator](https://tttkmbb.com/statistics/odds-ratio.md) — Association measures for a 2×2 exposure table.
