Gauss programs for estimating the term structure of interest rates

Lars E.O. Svensson

Please print and read this page before unzipping the file below.

This page contains contains information on how to set up and run my Gauss procedures for estimating the term structure of interest rates. It assumes familiarity with Gauss, and requires Gauss 386i VM version 3.1.4 (or later) with Publication Quality Graphics and the Maxlik module.

I regret that I do not have time for any customer support.

The following is a brief explanation of what needs to be done to run the program. For ease of transfer, the directory structure in the zipfile has been set up to be consistent with the directory structure on
the harddisk. Take care to preserve this directory structure. Therefore, when unzipping, use the option “Use Folder Name” or equivalent, and specify the c drive as target. The unzip command will then create the subdirectories C:\GAUSS\SRCLS, C:\RES\TERM2\DATA, C:\RES\TERM2\OUT and
C:\RES\TERM2\PROG. The C:\GAUSS\SRCLS subdirectory now contains procedures that are essential to run the actual program. The programs that calculate forward rates are called ?x.P (?=DE, FR, GB, IT, SWE, US) and are located in C:\RES\TERM2\PROG. Edit and run these program to calculate or print forward rates.

The ASCII files that contain the data are called ?c, ?m, and ?y for coupon, maturity, and yield files respectively. These files have 17 columns (trading date + 16 bonds). To include more bonds than 16, a small adjustment needs to be made: when loading the data, in the program Gauss performs a RESHAPE command to create a matrix with 17 columns. To include 16+x bonds for estimation, simply change 17 to 17+x in the RESHAPE command.

Some of the values in the ASCII files are “.”. This denotes missing values. Missing values have been included only for convenience, to make maturity dates line up more conformably column-wise. The location or inclusion of missing values is unconstrained (except for first location), but if there is a
missing values in column z of of one data file for one country, the two other data files for that country must also include a missing value at the same location.

The result files with the estimated parameters are called ?res2x.fmt. To save new parameters, answer “y” to the question after estimation.

The section entitled Switches in the beginning of the program contains user parameters that may need to be changed (self-explanatory parameters are omitted):

obs: which observation to estimate (37=’1994.0504′)
nsx: =1 implies using the extended version of Nelson & Siegel
with two more parameters
restr: =1 imposes the restriction that must go through first
observation (ie overnight rate)

Running the programs

Run the programs from the directory c:\res\term2\prog. Other directory structures are possible, but then the programs need to be edited accordingly.

Gauss needs acess to the maxlik, maxutil, publication quality graphics, and my procedures. To accomplish this, include a reference to maxlik, pgraph, and ls in the startup file. Also, the program allres.p must be run prior to running the the ?x.p programs: most conveniently done in the startup file. An example of how this might be done is included in C:\GAUSS\STARTUP.

Preset programs

There are two programs (figure1.p and figure2.p) included in the directory c:\res\term2\prog that are preset in order to produce figure 3.1 and 4.1 from the article “New Techniques to Extract Market Expectations from Financial Instruments” (Svensson, Lars. E.O. and Söderlind, Paul, 1997, CEPR Discussion Paper Series, No 1556, Journal of Monetary Economics 40(2) (1997), 373-429). These diagrams can also be found in Svensson, Lars E.O., “Estimating and Interpreting Forward Interest Rates: Sweden 1992-1994”, Working Paper No. WP/94/114, International Monetary Fund, Washington, D.C. and in Svensson, Lars E.O., “Estimating Forward Interest Rates with the Extended Nelson & Siegel Method”, Quarterly Review, Sveriges Riksbank, 1995:3, 13-26.


Convergence problems. Check that the data is correct. Change the initial guess of starting parameters. Change from “extended N&S” to N&S: in cases where N&S gives ok fit, extended tends to be over-parameterized, and then has convergence problems.

Matrices not conformable. A favorite Gauss error message. Here it usually means that a missing value is inconsistent with other data files.

Note that the file Allres.p must be run prior to running the programs. It loads the files containing the estimated parameters that are used as starting values (optionally).

Please report any errors found.

Please notify me that you will download the programs.

Download zip file: (right-click and save to your harddisk)

Paper Abstract 1 | Paper Abstract 2