NAG CL Interface
e01cec (dim1_​monconv_​disc)

Settings help

CL Name Style:


1 Purpose

e01cec computes, for a given set of data points, the forward values and other values required for monotone convex interpolation as defined in Hagan and West (2008). This form of interpolation is particularly suited to the construction of yield curves in Financial Mathematics but can be applied to any data where it is desirable to preserve both monotonicity and convexity.

2 Specification

#include <nag.h>
void  e01cec (Integer n, double lam, Nag_Boolean negfor, Nag_Boolean yfor, const double x[], const double y[], double comm[], NagError *fail)
The function may be called by the names: e01cec, nag_interp_dim1_monconv_disc or nag_interp_1d_monconv_disc.

3 Description

e01cec computes, for a set of data points, (xi,yi) , for i=1,2,,n, the discrete forward rates, fid, and the instantaneous forward rates, fi, which are used in a monotone convex interpolation method that attempts to preserve both the monotonicity and the convexity of the original data. The monotone convex interpolation method is due to Hagan and West and is described in Hagan and West (2006), Hagan and West (2008) and West (2011).
The discrete forward rates are defined simply, for ordered data, by
f1d=y1; fid = xi yi - xi-1 yi-1 xi - xi-1 ,   for ​ i=2,3,,n. (1)
The discrete forward rates, if pre-computed, may be supplied instead of y, in which case the original values y are computed using the inverse of (1).
The data points xi need not be ordered on input (though yi must correspond to xi); a set of ordered and scaled values ξi are calculated from xi and stored.
In its simplest form, the instantaneous forward rates, fi, at the data points are computed as linear interpolations of the fid:
fi = xi - xi-1 xi+1 - xi-1 fi+1d + xi+1 - xi xi+1 - xi-1 fid ,   for ​ i=2,3,,n-1 f1 = f2d - 1 2 (f2-f2d) fn = fnd - 1 2 (fn-1-fnd). (2)
If it is required, as a constraint, that these values should never be negative then a limiting filter is applied to f as described in Section 3.6 of West (2011).
An ameliorated (smoothed) form of this linear interpolation for the forward rates is implemented using the amelioration (smoothing) parameter λ. For λ0, equation (2) is used (with possible post-process filtering); for 0<λ1, the ameliorated method described fully in West (2011) is used.
The values computed by e01cec are used by e01cfc to compute, for a given value x^, the monotone convex interpolated (or extrapolated) value y^(x^) and the corresponding instantaneous forward rate f; the curve gradient at x^ can be derived as y=(f-y^)/x^ for x^0.

4 References

Hagan P S and West G (2006) Interpolation methods for curve construction Applied Mathematical Finance 13(2) 89–129
Hagan P S and West G (2008) Methods for constructing a yield curve WILLMOTT Magazine May 70–81
West G (2011) The monotone convex method of interpolation Financial Modelling Agency

5 Arguments

1: n Integer Input
On entry: n, the number of data points.
Constraint: n2.
2: lam double Input
On entry: λ, the amelioration (smoothing) parameter. Forward rates are first computed using (2) and then, if λ>0, a limiting filter is applied which depends on neighbouring discrete forward values. This filter has a smoothing effect on the curve that increases with λ.
Suggested value: λ=0.2.
Constraint: 0.0lam1.0.
3: negfor Nag_Boolean Input
On entry: determines whether or not to allow negative forward rates.
negfor=Nag_TRUE
Negative forward rates are permitted.
negfor=Nag_FALSE
Forward rates calculated must be non-negative.
4: yfor Nag_Boolean Input
On entry: determines whether the array y contains values, y, or discrete forward rates fd.
yfor=Nag_TRUE
y contains the discrete forward rates fid, for i=1,2,,n.
yfor=Nag_FALSE
y contains the values yi, for i=1,2,,n.
5: x[n] const double Input
On entry: x, the (possibly unordered) set of data points.
6: y[n] const double Input
On entry:
If yfor=Nag_TRUE, the discrete forward rates fid corresponding to the data points xi, for i=1,2,,n.
If yfor=Nag_FALSE, the data values yi corresponding to the data points xi, for i=1,2,,n.
7: comm[4×n+10] double Communication Array
On exit: contains information to be passed to e01cfc. The information stored includes the discrete forward rates fd, the instantaneous forward rates f, and the ordered data points ξ.
8: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_DATA_NOT_UNIQUE
On entry, x contains duplicate data points.
NE_INT
On entry, n=value.
Constraint: n2.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_REAL
On entry, lam=value.
Constraint: 0.0lam1.0.

7 Accuracy

The computational errors in the values stored in the array comm should be negligible in most practical situations.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
e01cec is not threaded in any implementation.

9 Further Comments

e01cec internally allocates 9n reals.

10 Example

See e01cfc.