NAG FL Interface
e01cef (dim1_monconv_disc)
1
Purpose
e01cef 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
Fortran Interface
Integer, Intent (In) |
:: |
n |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
lam, x(n), y(n) |
Real (Kind=nag_wp), Intent (Out) |
:: |
comm(4*n+10) |
Logical, Intent (In) |
:: |
negfor, yfor |
|
C Header Interface
#include <nag.h>
void |
e01cef_ (const Integer *n, const double *lam, const logical *negfor, const logical *yfor, const double x[], const double y[], double comm[], Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
e01cef_ (const Integer &n, const double &lam, const logical &negfor, const logical &yfor, const double x[], const double y[], double comm[], Integer &ifail) |
}
|
The routine may be called by the names e01cef or nagf_interp_dim1_monconv_disc.
3
Description
e01cef computes, for a set of data points,
, for
, the discrete forward rates,
, and the instantaneous forward rates,
, 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
The discrete forward rates, if pre-computed, may be supplied instead of
, in which case the original values
are computed using the inverse of
(1).
The data points need not be ordered on input (though must correspond to ); a set of ordered and scaled values are calculated from and stored.
In its simplest form, the instantaneous forward rates,
, at the data points are computed as linear interpolations of the
:
If it is required, as a constraint, that these values should never be negative then a limiting filter is applied to
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
, equation
(2) is used (with possible post-process filtering); for
, the ameliorated method described fully in
West (2011) is used.
The values computed by
e01cef are used by
e01cff to compute, for a given value
, the monotone convex interpolated (or extrapolated) value
and the corresponding instantaneous forward rate
; the curve gradient at
can be derived as
for
.
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:
– Integer
Input
-
On entry: , the number of data points.
Constraint:
.
-
2:
– Real (Kind=nag_wp)
Input
-
On entry:
, the amelioration (smoothing) parameter. Forward rates are first computed using
(2) and then, if
, 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:
.
Constraint:
.
-
3:
– Logical
Input
-
On entry: determines whether or not to allow negative forward rates.
- Negative forward rates are permitted.
- Forward rates calculated must be non-negative.
-
4:
– Logical
Input
-
On entry: determines whether the array
y contains values,
, or discrete forward rates
.
- y contains the discrete forward rates
, for .
- y contains the values
, for .
-
5:
– Real (Kind=nag_wp) array
Input
-
On entry: , the (possibly unordered) set of data points.
-
6:
– Real (Kind=nag_wp) array
Input
-
On entry:
If , the discrete forward rates corresponding to the data points
, for .
If , the data values corresponding to the data points
, for .
-
7:
– Real (Kind=nag_wp) array
Communication Array
-
On exit: contains information to be passed to
e01cff. The information stored includes the discrete forward
rates
, the
instantaneous forward rates
, and the ordered data points
.
-
8:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
On entry,
x contains duplicate data points.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
The computational errors in the values stored in the array
comm should be negligible in most practical situations.
8
Parallelism and Performance
e01cef is not threaded in any implementation.
e01cef internally allocates reals.
10
Example
See
Section 10 in
e01cff.