fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Distress-Model Ensemble

Install and import#

bash
npm install fintech-algorithms
ts
import { distressModelEnsemble } from "fintech-algorithms/fundamental-analysis-and-valuation/integrated-equity-scoring/distress-model-ensemble";

Signature#

distressModelEnsemble(data)

Pools the eligible distress models into one weight-averaged probability and reports how widely those models disagree.

Parameters#

NameTypeNotes
data{ models: Array<{ name?: string; eligible: boolean; distress_probability: number; weight: number }> }models is the candidate list. Only rows whose eligible is exactly true contribute; each of those needs a distress_probability between 0 and 1 and a positive weight, and name falls back to model when absent. Rows that are not eligible are skipped without validation.

Returns#

{ state: string; method: string; eligible_models: Array<{ name: string; probability: number; weight: number }>; model_count: number; distress_probability: number; weighted_stddev: number; disagreement_range: number; agreement: number; band: string; calibration_boundary: string }

eligible_models lists the contributing rows and model_count their number. distress_probability is the weighted mean, weighted_stddev the weighted standard deviation around it, disagreement_range the highest probability minus the lowest, and agreement one minus that range. band is high-review at 0.66 or above, watch at 0.33 or above, otherwise lower-review.

Errors#

  • When models is not a nonempty list, or an entry is not an object — throws TypeError
  • When an eligible model's distress_probability or weight is not a finite number — throws TypeError
  • When an eligible model's weight is not positive, or its distress_probability is below 0 or above 1 — throws RangeError
  • When no model is marked eligible — throws RangeError

Complexity: time O(n), space O(n).

Worked example#

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input#

data
{
  "models": [
    {
      "name": "altman",
      "distress_probability": 0.18,
      "weight": 1,
      "eligible": true
    },
    {
      "name": "ohlson",
      "distress_probability": 0.24,
      "weight": 1,
      "eligible": true
    },
    {
      "name": "zmijewski",
      "distress_probability": 0.3,
      "weight": 0.5,
      "eligible": true
    }
  ]
}

Call#

distressModelEnsemble(data)

Returns#

object with 10 fields: state, method, eligible_models, model_count, distress_probability, weighted_stddev, disagreement_range, agreement, …

{
  "state": "calculated",
  "method": "weighted-distress-probability-ensemble",
  "eligible_models": [
    {
      "name": "altman",
      "probability": 0.18,
      "weight": 1
    },
    {
      "name": "ohlson",
      "probability": 0.24,
      "weight": 1
    },
    {
      "name": "zmijewski",
      "probability": 0.3,
      "weight": 0.5
    }
  ],
  "model_count": 3,
  "distress_probability": 0.22799999999999998,
  "weighted_stddev": 0.04489988864128729,
  "disagreement_range": 0.12,
  "agreement": 0.88,
  "band": "lower-review",
  "calibration_boundary": "weighted aggregation preserves supplied probabilities; it does not recalibrate them"
}

Other exports#

This module also exports calculate, pointInTimeStockScoringInputAssembly, stockScoringPeerCohortResolver, fundamentalMetricDirectionAndPeerNormalization, modelApplicabilityAndVariantRouter, accountingFinancialHealthComposite, earningsQualityComposite, dividendSafetyScore, balanceSheetResilienceScore, crossModelConflictAndDoubleCountingResolver, overallExplainableStockScore, scoreConfidenceMissingDataPenaltyAndAbstention, marketWideStockScreeningAndRanking, stockScoreHistoryMigrationAndChangeAttribution. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams#

Distress-Model Ensemble — evidence clock
Distress-Model Ensemble — model anatomy
Distress-Model Ensemble — system map
Distress-Model Ensemble — threshold and interpretation
Distress-Model Ensemble — variant boundaries

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

The rest of the Integrated Equity Scoring family#