Skip to main content

Overview

The RAADS-R scoring engine implements the validated clinical scoring algorithm for the Ritvo Autism Asperger Diagnostic Scale-Revised. The implementation includes dual scoring engines for cross-validation and comprehensive test coverage.

Core Scoring Functions

Item Scoring

Each question item is scored based on the response index (0-3) and whether it’s a normative or symptom item.
export function scoreItem(responseIndex: number, isNormative: boolean): number {
  return isNormative ? responseIndex : 3 - responseIndex;
}

Scoring Logic

The scoring algorithm differentiates between two types of items:
Symptom Items
default
Items where higher response frequency indicates stronger autistic traits.Formula: score = 3 - responseIndex
  • “True now and when I was young” (index 0) → 3 points
  • “True only now” (index 1) → 2 points
  • “True only when I was younger than 16” (index 2) → 1 point
  • “Never true” (index 3) → 0 points
Normative Items
reversed
Items where lower response frequency indicates stronger autistic traits. Scoring is reversed.Formula: score = responseIndex
  • “True now and when I was young” (index 0) → 0 points
  • “True only now” (index 1) → 1 point
  • “True only when I was younger than 16” (index 2) → 2 points
  • “Never true” (index 3) → 3 points
The dataset contains 17 normative items out of 80 total items. Normative items are distributed across domains: Social (14), Language (1), and Sensory (2). The Interests domain has no normative items.

Total Score Computation

The computeResults function aggregates individual item scores into domain and total scores:
scoring.ts:18
export function computeResults(responses: Responses, dataset: Dataset): Results {
  const itemMap = new Map(dataset.items.map((item) => [item.id, item]));

  const domains: DomainResult[] = dataset.meta.domains.map((domain) => {
    let score = 0;
    for (const itemId of domain.itemIds) {
      const item = itemMap.get(itemId);
      if (!item) continue;
      const response = responses[itemId];
      if (response === undefined) continue;
      score += scoreItem(response, item.isNormative);
    }
    return {
      key: domain.key,
      label: domain.label,
      score,
      maxScore: domain.maxScore,
      cutoff: domain.cutoff,
      aboveCutoff: score > domain.cutoff,
    };
  });

  const total = domains.reduce((sum, d) => sum + d.score, 0);

  return {
    total,
    totalMax: 240,
    totalCutoff: dataset.meta.totalCutoff,
    aboveTotalCutoff: total > dataset.meta.totalCutoff,
    domains,
  };
}

Algorithm Steps

  1. Map Creation: Build a lookup map of item ID → item object for O(1) access
  2. Domain Scoring: For each domain, iterate through its item IDs:
    • Retrieve the item and response
    • Score using scoreItem(response, item.isNormative)
    • Sum all item scores for the domain
  3. Cutoff Evaluation: Compare domain score against cutoff using strict > operator
  4. Total Score: Sum all domain scores (maximum possible: 240)
  5. Total Cutoff: Evaluate against total cutoff (65)

Domain Structure

  • Item Count: 39 items
  • Normative Items: 14
  • Max Score: 117
  • Cutoff: Domain-specific (see dataset)

Dual Engine Validation

The codebase implements two mathematically equivalent scoring engines to ensure correctness:
  • Primary Engine (scoring.ts): Uses arithmetic formula 3 - responseIndex
  • Alternative Engine (scoring-alt.ts): Uses lookup tables SYMPTOM_SCORES and NORMATIVE_SCORES
Both engines are tested to produce identical results across all possible input combinations. See the Testing page for validation test coverage.

Cutoff Interpretation

The cutoff comparison uses strict greater-than (>), not greater-than-or-equal-to.
  • Score of 65 (equal to cutoff): aboveTotalCutoff = false
  • Score of 66 (above cutoff): aboveTotalCutoff = true
This is clinically significant and validated through boundary tests in src/__tests__/scoring.test.ts:212-238.

Implementation Files

  • Primary Engine: src/engine/scoring.ts
  • Alternative Engine: src/engine/scoring-alt.ts
  • Type Definitions: src/data/dataset.schema.ts
  • Validation Tests: src/__tests__/scoring.test.ts

Build docs developers (and LLMs) love