I am investigating the ExponentialSplinesFitting class in QuantLib. I've used this fitting technique using a variety of systems in the past (including by hand!). The form is $$df(t) = \sum_{n=1}^{N}(\beta(n)\exp(-n \cdot \alpha \cdot t))$$, ie there is one alpha (which QuantLib calls 'kappa') and 1 to N Betas.
QuantLib seems to be hard-coded with 9 Betas (which will reduce to 8 independent Betas if df(0) constrained = 1):
Size ExponentialSplinesFitting::size() const {
return constrainAtZero_ ? 9 : 10;
}
My question is: Why 9?
When using this method in the past, I've used a maximum of 6 in practice. I have found the "best" number to be influenced by the density of bonds across the term structure. Adding more parameters increases the quality of fit at the short end, but can have the side effect of producing unwarranted perturbations at the long end. So unless you have a lot of bonds in the 0-1 year range, using fewer parameters may give a better fit further out. Bottom line: should I be modifying the QL implementation to have a variable number of parameters?