Examples Using NAG and Excel
All the example spreadsheets below use 32bit NAG Libraries and can be used with 32bit version of Microsoft Excel only. 64bit versions of some examples can be made available upon request. Please contact us via support@nag.co.uk for more information.
Basic examples:
 How to compute the matrix exponential, and other matrix functions, of a real matrix using the Schur–Parlett algorithm
 Using the NAG Fortran Library ^{NEW AT MARK 24}
 How to compute the Cholesky factorization of a real symmetric positive definite matrix
 Using the NAG Fortran Library ^{NEW EXAMPLE}
 How to reduce a real m by n matrix to bidiagonal form by an orthogonal transformation
 Using the NAG Fortran Library ^{NEW EXAMPLE}
 How to compute the singular value decomposition of a real upper or lower bidiagonal matrix
 Using the NAG Fortran Library ^{NEW EXAMPLE}
 How to compute the maximum likelihood estimates of the parameters of a factor analysis model
 Using the NAG Fortran Library ^{NEW EXAMPLE}
 How to calculate multivariate probability
 How to find a zero of a function using a reverse communication interface
 How to compute the option price given by the Black–Scholes–Merton formula together with its Greeks
 How to compute the option price given by Heston's stochastic volatility model together with its Greeks ^{NEW EXAMPLE}
 How to solve a Markowitz Modern Portfolio optimization problem
 How to compute the 2D discrete wavelet transform ^{NEW AT MARK 23}
 How to perform quantile linear regression ^{NEW AT MARK 23}
 How to compute a definite integral over a finite range to a specified relative accuracy using a method described by Patterson.
 Using the NAG Fortran Library ^{NEW EXAMPLE}
 Miscellaneous Examples Of and General Notes On
Using the NAG C Library
Advanced examples:
 How to use the scaled Wiener increments produced using a Brownian bridge generator to compute numerical solutions to stochastic differential equations (SDEs) driven by (free or nonfree) Wiener processes
 Using the NAG Fortran Library ^{NEW AT MARK 24}
 How to compute the Nearest Correlation Matrix (NCM), in the Frobenius norm, or weighted Frobenius norm, and optionally with bounds on the eigenvalues, or with kfactor structure, and how to find eigenvalues for both symmetric and asymmetric matrices ^{NEW AT MARK 23}
 How to compute the Nearest Correlation Matrix (NCM), in the Frobenius norm, or weighted Frobenius norm, or elementwise weightings and optionally with bounds on the eigenvalues, or with kfactor structure, and how to find eigenvalues for both symmetric and asymmetric matrices. ^{NEW AT MARK 24}
 How to find the global optimum of a multivariate function using multilevel coordinate search algorithm
 How to solve a nonlinear leastsquares problem using the sequential quadratic programming (SQP) method
 How to find a minimum of a function, subject to fixed upper and lower bounds (no derivatives required) using the BOBYQA algorithm
 How to obtain KaplanMeier estimates for censored data
 How to perform GARCH time series identification, estimation and forecasting
 How to perform ARIMA time series identification, estimation and forecasting
 How to implement Local Volatility model using Dupire formula and a collection of NAG interpolation routines and a PDE solver ^{NEW EXAMPLE}
NAG Statistical AddIns for Excel
The NAG Statistical AddIns contain a considerable number of statistical routines grouped together in one spreadsheet. These include functions for:
 Simple statistics
 Regression analysis
 Time series modelling
 GLMs
 PCA
 Factor, Cluster, and Discriminant Analyses
 Non parametric tests
 And others…
All functions can be called via Excel's function wizard and the spreadsheet is supplied with a NAG menu with utilities for expanding the results and extracting formatted data.
The spreadsheet works with the 32bit NAG Fortran Library FLDLL244ML with Excel 2003, 2007, and 2010 (32bit).
The zip file contains the Excel spreadsheet, a README file and Windows help file.
Please note, that in order to be able to read the help file on Windows Vista and later versions of Windows you need to download a Windows Help component from http://support.microsoft.com/kb/917607 free of charge. To avoid any potential problems with the Microsoft Validation Program, you might consider using Internet Explorer to perform this download.
If you wish to use the AddIns in 64bit Excel 2010 please contact support@nag.co.uk.
NAG Survival Analysis for Excel
The NAG Survival Analysis spreadsheet contains functions to:
 Compute KaplanMeier estimates of survival probabilities (with plots)
 Compute rank statistics for comparing survival curves
 Fit Cox's proportional hazard model
All functions can be called via Excel's function wizard and the spreadsheet is supplied with a NAG menu with utilities for expanding the results and extracting formatted data.
The spreadsheet works with the 32bit NAG Fortran Library FLDLL244ML with Excel 2003, 2007, and 2010 (32bit).
The zip file contains the Excel spreadsheet and a README file.
If you wish to use the AddIns in 64bit Excel 2010 please contact support@nag.co.uk.
 Using the NAG Library for .NET in Excel ^{NEW EXAMPLE}
This archive contains a demo which uses methods from the NAG Library for .NET in an Excel spreadsheet to fit a bicubic spline surface to a set of points in 3D space. More information about the demo can be found in this README (a copy of which is also contained in the archive).
If you wish to use any of these examples you need to have the appropriate NAG Library installed. All examples use 32bit NAG Libraries. 64bit versions are available upon request. If you wish to use NAG Excel examples in 64bit Excel 2010 please contact sales@nag.co.uk. The table below shows NAG Product codes depending on which version of Excel and which type of NAG Library you use.






To access a trial of these libraries please go to our download page. To run the demonstrations effectively you must have macros enabled in Excel. We suggest you save the file (using right click 'Save As') and then open from the saved location. Before you run a demonstration please refer to the Help and Information buttons within the Excel workbook, where available.The examples are supplied with the appropriate VB headers. If you would like to call other routines from the NAG Library, please download the headers via the hyperlinks listed at the bottom of this page (where applicable, otherwise please contact support).
Additional examples of calling NAG routines from Excel are available for most of the above libraries. For the C Library, these examples are available for download for CLW3223DAL. For FLDLL244ML, once the library has been downloaded and installed, the examples can be found in the Samples/Excel_Examples subdirectory of the library installation directory.