# Noninferiority test planner

- Human page: https://happytails.ai/en/calculators/noninferiority-test-planner/
- Markdown: https://happytails.ai/en/calculators/noninferiority-test-planner.md
- Structured JSON: https://happytails.ai/agents/en/calculators/noninferiority-test-planner/index.json
- Visibility: public

## Tool capabilities

| Property | Value |
| --- | --- |
| Tool ID | `noninferiority-test-planner` |
| Category | calculators |
| Implementation | Registered implementation. Registration alone is not a production-quality guarantee. |
| Browser execution | Use the visible action or interactive controls. |
| Browser processing | Browser; see tool notes for network behavior. |
| HTTP API | Not callable through HTTP. |
| Browser-agent interface | run_current_tool |

### Implementation notes

Runs on your device. Fix the margin before seeing the data; a nonsignificant result does not show non-inferiority.

### Inputs and settings

No free-text input is required. Use the file inputs and/or settings below.

| Setting | Meaning | Control type | Default | Constraints |
| --- | --- | --- | --- | --- |
| `design` | Outcome | select | "two-sample" | Allowed: two-sample, two-proportions |
| `data` | Data | select | "summary" | Allowed: summary, raw |
| `margin` | Non-inferiority margin | text | "1" |  |
| `direction` | Direction | select | "higher-is-better" | Allowed: higher-is-better, lower-is-better |
| `alpha` | One-sided alpha | text | "0.025" |  |
| `power` | Planning power | text | "0.8" |  |
| `expectedDifference` | Expected true difference for planning | text | "0" |  |
| `planningSd` | Planning standard deviation (optional) | text | "" |  |
| `planningProportion` | Planning control proportion (optional) | text | "" |  |
| `n1` | Treatment group size | text | "120" |  |
| `mean1` | Treatment group mean | text | "7.6" |  |
| `sd1` | Treatment group standard deviation | text | "1.4" |  |
| `n2` | Control group size | text | "120" |  |
| `mean2` | Control group mean | text | "7.8" |  |
| `sd2` | Control group standard deviation | text | "1.5" |  |
| `x1` | Treatment group successes | text | "88" |  |
| `x2` | Control group successes | text | "90" |  |
| `groupColumn` | Group column | text | "group" |  |
| `valueColumn` | Value column | text | "value" |  |
| `missing` | Blank cells | select | "reject" | Allowed: reject, drop |
| `csv` | Raw CSV | textarea | "group,value\nnew,7.9\nnew,6.8\nnew,8.4\ncurrent,7.5\ncurrent,8.1\ncurrent,7.2" |  |

### Browser-agent workflow

1. Open the human page in a browser that supports WebMCP.
2. Discover the interface exposed by that page; use its actual schema.
3. Select files on the page first when the tool requires files.
4. Call `run_current_tool` with valid input and settings.
5. Inspect the returned result or error and the displayed output. Retrieve files from the displayed download links.

Calls do not automatically copy or download results. Browser permissions still apply. Interface availability alone is not proof of successful execution.

### Planning specification

Runs locally in your browser; nothing is uploaded. Group sizes are whole numbers of at least 2 (at least 1 for proportions), SDs are greater than zero, the margin is greater than zero (below 1 for proportions), alpha is from 0.0001 to 0.4999 and power from 0.5001 to 0.9999, and the expected difference for planning lies on the better side of the margin. Setting numbers are plain decimals with a digit before the point, such as 0.95, without exponents. Raw CSV is for means only, in long format with two groups, up to 10,000 rows and 1,000,000 characters; a blank line between rows is rejected and blank lines after the last row are ignored. Downloads: a JSON report, CSV result and plan rows and an SVG chart of the bound against the margin.

This describes intended requirements. Use the implementation notes, interface schema and observed output to determine current support.

### Complete machine-readable capability record

```json
{
  "id": "noninferiority-test-planner",
  "category": "calculators",
  "built": true,
  "requirements": "Runs locally in your browser; nothing is uploaded. Group sizes are whole numbers of at least 2 (at least 1 for proportions), SDs are greater than zero, the margin is greater than zero (below 1 for proportions), alpha is from 0.0001 to 0.4999 and power from 0.5001 to 0.9999, and the expected difference for planning lies on the better side of the margin. Setting numbers are plain decimals with a digit before the point, such as 0.95, without exponents. Raw CSV is for means only, in long format with two groups, up to 10,000 rows and 1,000,000 characters; a blank line between rows is rejected and blank lines after the last row are ignored. Downloads: a JSON report, CSV result and plan rows and an SVG chart of the bound against the margin.",
  "implementation": {
    "fields": [
      {
        "key": "design",
        "label": "Outcome",
        "value": "two-sample",
        "type": "select",
        "values": [
          "two-sample",
          "two-proportions"
        ],
        "labels": {
          "two-sample": "Means of two independent groups",
          "two-proportions": "Proportions in two groups"
        }
      },
      {
        "key": "data",
        "label": "Data",
        "value": "summary",
        "type": "select",
        "values": [
          "summary",
          "raw"
        ],
        "labels": {
          "summary": "Summary statistics",
          "raw": "Raw CSV values (means only)"
        }
      },
      {
        "key": "margin",
        "label": "Non-inferiority margin",
        "value": "1",
        "type": "text",
        "maxLength": 40,
        "help": "Greater than zero, in the units of the difference (a proportion below 1 for proportions). Fix it before seeing the data."
      },
      {
        "key": "direction",
        "label": "Direction",
        "value": "higher-is-better",
        "type": "select",
        "values": [
          "higher-is-better",
          "lower-is-better"
        ],
        "labels": {
          "higher-is-better": "Higher values are better",
          "lower-is-better": "Lower values are better"
        }
      },
      {
        "key": "alpha",
        "label": "One-sided alpha",
        "value": "0.025",
        "type": "text",
        "maxLength": 40,
        "help": "From 0.0001 to 0.4999. One-sided 0.025 matches a two-sided 95 percent interval."
      },
      {
        "key": "power",
        "label": "Planning power",
        "value": "0.8",
        "type": "text",
        "maxLength": 40,
        "help": "From 0.5001 to 0.9999."
      },
      {
        "key": "expectedDifference",
        "label": "Expected true difference for planning",
        "value": "0",
        "type": "text",
        "maxLength": 40,
        "help": "Treatment minus control assumed when planning, for example 0."
      },
      {
        "key": "planningSd",
        "label": "Planning standard deviation (optional)",
        "value": "",
        "type": "text",
        "maxLength": 40,
        "help": "Leave blank to use the pooled SD of the data.",
        "showWhen": {
          "design": [
            "two-sample"
          ]
        }
      },
      {
        "key": "planningProportion",
        "label": "Planning control proportion (optional)",
        "value": "",
        "type": "text",
        "maxLength": 40,
        "help": "Between 0 and 1. Leave blank to use the observed control proportion.",
        "showWhen": {
          "design": [
            "two-proportions"
          ]
        }
      },
      {
        "key": "n1",
        "label": "Treatment group size",
        "value": "120",
        "type": "text",
        "maxLength": 40,
        "help": "Whole number of at least 2 (at least 1 for proportions).",
        "showWhen": {
          "design": [
            "two-sample",
            "two-proportions"
          ],
          "data": [
            "summary"
          ]
        }
      },
      {
        "key": "mean1",
        "label": "Treatment group mean",
        "value": "7.6",
        "type": "text",
        "maxLength": 40,
        "help": "Use a decimal point and no thousands separators.",
        "showWhen": {
          "design": [
            "two-sample"
          ],
          "data": [
            "summary"
          ]
        }
      },
      {
        "key": "sd1",
        "label": "Treatment group standard deviation",
        "value": "1.4",
        "type": "text",
        "maxLength": 40,
        "help": "Sample SD with n - 1, greater than zero.",
        "showWhen": {
          "design": [
            "two-sample"
          ],
          "data": [
            "summary"
          ]
        }
      },
      {
        "key": "n2",
        "label": "Control group size",
        "value": "120",
        "type": "text",
        "maxLength": 40,
        "help": "Whole number of at least 2 (at least 1 for proportions).",
        "showWhen": {
          "design": [
            "two-sample",
            "two-proportions"
          ],
          "data": [
            "summary"
          ]
        }
      },
      {
        "key": "mean2",
        "label": "Control group mean",
        "value": "7.8",
        "type": "text",
        "maxLength": 40,
        "help": "Use a decimal point and no thousands separators.",
        "showWhen": {
          "design": [
            "two-sample"
          ],
          "data": [
            "summary"
          ]
        }
      },
      {
        "key": "sd2",
        "label": "Control group standard deviation",
        "value": "1.5",
        "type": "text",
        "maxLength": 40,
        "help": "Sample SD with n - 1, greater than zero.",
        "showWhen": {
          "design": [
            "two-sample"
          ],
          "data": [
            "summary"
          ]
        }
      },
      {
        "key": "x1",
        "label": "Treatment group successes",
        "value": "88",
        "type": "text",
        "maxLength": 40,
        "help": "Whole number from 0 to the group size.",
        "showWhen": {
          "design": [
            "two-proportions"
          ]
        }
      },
      {
        "key": "x2",
        "label": "Control group successes",
        "value": "90",
        "type": "text",
        "maxLength": 40,
        "help": "Whole number from 0 to the group size.",
        "showWhen": {
          "design": [
            "two-proportions"
          ]
        }
      },
      {
        "key": "groupColumn",
        "label": "Group column",
        "value": "group",
        "type": "text",
        "maxLength": 200,
        "help": "Exact header. The first group to appear is the treatment group.",
        "showWhen": {
          "data": [
            "raw"
          ]
        }
      },
      {
        "key": "valueColumn",
        "label": "Value column",
        "value": "value",
        "type": "text",
        "maxLength": 200,
        "help": "Exact header of the numeric outcome column.",
        "showWhen": {
          "data": [
            "raw"
          ]
        }
      },
      {
        "key": "missing",
        "label": "Blank cells",
        "value": "reject",
        "type": "select",
        "values": [
          "reject",
          "drop"
        ],
        "labels": {
          "reject": "Stop and show an error",
          "drop": "Drop incomplete rows"
        },
        "showWhen": {
          "data": [
            "raw"
          ]
        }
      },
      {
        "key": "csv",
        "label": "Raw CSV",
        "value": "group,value\nnew,7.9\nnew,6.8\nnew,8.4\ncurrent,7.5\ncurrent,8.1\ncurrent,7.2",
        "type": "textarea",
        "maxLength": 1000000,
        "help": "Two groups in long format, up to 10,000 rows and 1,000,000 characters.",
        "showWhen": {
          "data": [
            "raw"
          ]
        }
      }
    ],
    "registrationFamily": "statistical-comparison-tests",
    "input": false,
    "note": "Runs on your device. Fix the margin before seeing the data; a nonsignificant result does not show non-inferiority.",
    "experience": {
      "automatic": false,
      "single": false,
      "inputMaxLength": 1000000,
      "inputMode": "text",
      "label": "Summary statistics",
      "placeholder": "Enter values in the form fields",
      "help": "Use the fields for summaries, or choose Raw CSV values to paste data. Up to 1,000,000 characters. Review the settings before running.",
      "action": null
    },
    "mode": "explicit",
    "interactive": false
  },
  "execution": "Browser interface",
  "api": null,
  "browser_agent": {
    "supported": true,
    "name": "run_current_tool",
    "discovery": "WebMCP on the human page in a supporting browser",
    "verification": "See audit/API-AUDIT.md; availability is not verification"
  }
}
```

## Page guide

Test whether a new option is not worse than a control by more than a margin you fixed in advance, using a one-sided confidence bound for a difference in means or proportions, and plan the sample size per group.

How can we improve this tool?

Report a problem or share an idea.

Please leave out private information. Your message and the tool name go to our team via PostHog.

### How to use Noninferiority test planner

1. Choose means or proportions and whether you have summaries or raw CSV values.
2. Enter the margin you fixed before seeing the data, the direction, alpha and planning power.
3. Enter the group summaries, or paste the CSV.
4. Run the test, compare the confidence bound with the margin, and download the report and plan.

## Useful next steps

- [Sample size calculator](https://happytails.ai/en/calculators/sample-size-calculator/) ([Markdown](https://happytails.ai/en/calculators/sample-size-calculator.md))

- [Confidence interval calculator](https://happytails.ai/en/calculators/confidence-interval-calculator/) ([Markdown](https://happytails.ai/en/calculators/confidence-interval-calculator.md))

- [Pooled summary statistics](https://happytails.ai/en/calculators/pooled-summary-statistics/) ([Markdown](https://happytails.ai/en/calculators/pooled-summary-statistics.md))

## How the test works

The difference is treatment minus control. When higher values are better, the null hypothesis is that the difference is at most minus the margin, and non-inferiority is shown when the one-sided 1 - alpha lower confidence bound lies above it; when lower is better the upper bound must lie below the margin. Means use Welch's t, and proportions use an unpooled Wald z, which needs reasonably large groups. A one-sided alpha of 0.025 matches a two-sided 95 percent interval.

### Sample size plan

The plan uses the normal-approximation formulas of Chow, Shao and Wang (2008, Sample Size Calculations in Clinical Research, 2nd ed., sections 3.2 and 4.2) for the chosen alpha, power, margin and expected difference. Means use the planning SD or the pooled SD of the data; proportions use the planning control proportion or the observed one. The expected difference must lie on the better side of the margin (above minus the margin when higher is better, below the margin when lower is better), or no sample size can show non-inferiority. Results are rounded up per group.

### Limits

The margin must be justified and fixed before the data are seen, and justifying it is your responsibility; this tool makes no regulatory claim. A nonsignificant result does not show non-inferiority, and a non-inferiority result does not show that the new option is better.
