Catalog/stat-linear-regression

Calculators

Simple linear regression (OLS) API

Fit a simple ordinary-least-squares line y = b0 + b1·x (slope = Σ(x−x̄)(y−ȳ)/Σ(x−x̄)²), returning intercept, slope, R², standard errors, the equation, and an optional prediction. Auditable: echoes df and residual SE. Answers 'fit a regression line','slope and intercept of this data','predict y for x=6'.

Price$0.01per request
MethodPOST
Route/v1/calc/stat-linear-regression
StatusLive
MIME typeapplication/json
Rate limit120/minute
CacheNo cache
calcstatisticsregressionolsleast-squaressloper-squaredpredict
API URLhttps://x402.hexl.dev/v1/calc/stat-linear-regression
Integration docs
Example request
{
  "x": [
    1,
    2,
    3,
    4,
    5
  ],
  "y": [
    2,
    4,
    5,
    4,
    5
  ],
  "predictX": 6
}
Example response
{
  "slope": 0.6,
  "intercept": 2.2,
  "rSquared": 0.6,
  "n": 5,
  "df": 3,
  "standardErrorSlope": 0.282843,
  "residualStandardError": 0.894427,
  "equation": "y = 2.2 + 0.6·x",
  "rating": "moderate fit",
  "interpretation": "y = 2.2 + 0.6·x; R²=0.6.",
  "predictX": 6,
  "predictedY": 5.8
}
Input schema
{
  "type": "object",
  "required": [
    "x",
    "y"
  ],
  "properties": {
    "x": {
      "type": "array",
      "items": {
        "type": "number"
      },
      "examples": [
        [
          1,
          2,
          3,
          4,
          5
        ]
      ]
    },
    "y": {
      "type": "array",
      "items": {
        "type": "number"
      },
      "examples": [
        [
          2,
          4,
          5,
          4,
          5
        ]
      ]
    },
    "predictX": {
      "type": "number",
      "description": "optional x to predict y for",
      "examples": [
        6
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}