Class NelsonSiegel

java.lang.Object
com.quantfinlib.rates.NelsonSiegel

public final class NelsonSiegel extends Object
NELSON-SIEGEL yield-curve fit — the parametric answer to "what SHAPE is the curve", where YieldCurve is the exact-repricing answer to "what IS the curve". Central banks (ECB, Fed) publish curves in exactly this form because four numbers carry the whole story:
  z(t) = b0 + b1 · (1−e^{−t/λ})/(t/λ) + b2 · [(1−e^{−t/λ})/(t/λ) − e^{−t/λ}]
  • b0 — the LEVEL: z(∞), where the long end settles;
  • b1 — the SLOPE: z(0) = b0 + b1, so b1 < 0 is an upward curve and b1 > 0 is INVERSION — the recession-signal number;
  • b2 — the CURVATURE: the mid-curve hump, peaking near t ≈ λ;
  • λ — WHERE the hump sits (years).

Fitting exploits the model's one great convenience: for FIXED λ the model is LINEAR in (b0, b1, b2) — an exact 3×3 least-squares solve. So the fit is a log-spaced grid search over λ with an OLS solve at each node, keeping the whole thing deterministic and free of local-minimum roulette (the classic failure of fitting all four jointly). Betas are NOT constrained to "sensible" signs: an inverted curve is data, not an error.

Use the parametric fit for smoothing noisy quotes, cross-country comparison, and factor analysis (level/slope/curvature ARE the first three PCA factors of yield curves, to good approximation); use the bootstrap when you need every input repriced exactly. Research lane.

  • Method Details

    • fit

      public static NelsonSiegel.Fit fit(double[] tenorYears, double[] zeroRates)
      Fits by log-spaced λ grid (0.1y–10y, 80 nodes) + exact OLS per node.
      Parameters:
      tenorYears - observation tenors, ≥ 4 distinct, all > 0
      zeroRates - observed zero rates (continuously compounded)