Comparing Ideal Body Weight Formulas in TypeScript


Disclosure: This article may contain affiliate links. We only recommend products we believe in.

In clinical informatics, calculating Ideal Body Weight (IBW) is essential for adjusting drug dosages (like aminoglycosides or chemotherapy) and configuring mechanical ventilators. Four primary formulas dominate the clinical literature: Devine, Robinson, Miller, and Hamwi.

For developers building medical calculations or fitness software, implementing these formulas in a strongly-typed language like TypeScript ensures input safety and clear data structures. In this article, we will implement all four formulas in TypeScript, model their parameters with explicit types, and compare their outputs.

The Clinical Equations

All four formulas assume a baseline height of 5 feet (60 inches). Height above this threshold is multiplied by a formula-specific constant.

FormulaSexBase Weight (5 ft)Per Inch Over 5 ft
Devine (1974)Male50.0 kg2.3 kg
Female45.5 kg2.3 kg
Robinson (1983)Male52.0 kg1.9 kg
Female49.0 kg1.7 kg
Miller (1983)Male56.2 kg1.41 kg
Female53.1 kg1.36 kg
Hamwi (1964)Male48.0 kg2.7 kg
Female45.5 kg2.2 kg

TypeScript Implementation

Let’s model this in TypeScript. We will define strict union types for biological sex, interface types for input parameters, and a structured return interface that returns the result for all formulas simultaneously to facilitate comparison.

// Type definitions
export type BiologicalSex = 'male' | 'female';

export interface IBWInput {
  sex: BiologicalSex;
  heightInches: number;
}

export interface IBWComparisonResult {
  devine: number;
  robinson: number;
  miller: number;
  hamwi: number;
  average: number;
}

/**
 * Calculates Ideal Body Weight (IBW) using Devine, Robinson, Miller, and Hamwi formulas.
 * All outputs are returned in kilograms (kg).
 */
export function calculateIBW(input: IBWInput): IBWComparisonResult {
  const { sex, heightInches } = input;

  if (heightInches <= 0) {
    throw new Error("Height must be a positive number.");
  }

  // Calculate inches over 5 feet (60 inches)
  // Clinical note: if height is under 5 feet, clinical practice differs. 
  // Commonly, the subtraction is allowed to go negative, or a flat baseline is used.
  const inchesOver5Feet = Math.max(0, heightInches - 60);

  let devine = 0;
  let robinson = 0;
  let miller = 0;
  let hamwi = 0;

  if (sex === 'male') {
    devine = 50.0 + 2.3 * inchesOver5Feet;
    robinson = 52.0 + 1.9 * inchesOver5Feet;
    miller = 56.2 + 1.41 * inchesOver5Feet;
    hamwi = 48.0 + 2.7 * inchesOver5Feet;
  } else {
    devine = 45.5 + 2.3 * inchesOver5Feet;
    robinson = 49.0 + 1.7 * inchesOver5Feet;
    miller = 53.1 + 1.36 * inchesOver5Feet;
    hamwi = 45.5 + 2.2 * inchesOver5Feet;
  }

  // Round values to two decimal places
  const round = (val: number) => Math.round(val * 100) / 100;

  const results = {
    devine: round(devine),
    robinson: round(robinson),
    miller: round(miller),
    hamwi: round(hamwi)
  };

  const average = (results.devine + results.robinson + results.miller + results.hamwi) / 4;

  return {
    ...results,
    average: round(average)
  };
}

Comparing the Outputs (Data Analysis)

When building client interfaces, it is useful to show how these formulas diverge as height increases. Because each formula uses a different scaling factor, height variations lead to significant differences.

For example, let’s look at the outputs of our TypeScript function for a 6’2” (74 inches) male:

  • Hamwi (highest multiplier): 48 + (2.7 * 14) = 85.8 kg (189.1 lbs)
  • Devine: 50 + (2.3 * 14) = 82.2 kg (181.2 lbs)
  • Robinson: 52 + (1.9 * 14) = 78.6 kg (173.3 lbs)
  • Miller (lowest multiplier): 56.2 + (1.41 * 14) = 75.94 kg (167.4 lbs)

The difference between Hamwi and Miller for a tall individual is nearly 10 kg (22 lbs)! This shows that choosing one formula over another can significantly alter clinical dosage calculations.

Architectural Guidelines for Developers

If you are developing a health platform, keep these technical architectural rules in mind:

  1. Differentiate Clinical vs. Fitness Use Cases: For clinical mechanical ventilation, the Devine formula is the default industry standard. For fitness targets, IBW is rarely appropriate on its own because it ignores skeletal frame size and muscle mass.
  2. Model with Lean Body Mass (LBM): Instead of using a raw IBW formula, use the user’s estimated body fat percentage to calculate LBM: LBM = weight * (1 - body_fat_percentage)
  3. Perform Unit Conversions Safely: In TypeScript, implement a utility function to handle imperial-to-metric conversions, always using a single source of truth for constants (e.g., 1 inch = 2.54 cm).

For details on coding body composition models, see our guides on Implementing Logarithmic US Navy Body Fat Formulas in JavaScript and How to Build a BMI Calculator in JavaScript.