nagdmc rbf

NAG DMC

Radial Basis Functions: nagdmc rbf
Purposenagdmc rbf fits a radial basis function (RBF) model to data records with p independent variables.

Declaration#include <nagdmc.h>void nagdmc rbf(long rec1, long nvar, long nrec, long dblk, double data[],long nxvar, long xvar[], long yvar, long nrbf, double cen[],int dtype, int mtype, double m[], int rbftype, double alpha,double tol, double lambda[], double w[], double yhat[],double model[], int *info);

Parameters1:

rec1 – long

Input

On entry: the index in the data of the first data record used in the analysis.
Constraint: rec1 ≥ 0.
2:

nvar – long

Input

On entry: the number of variables in the data.
Constraint: nvar > 1.
3:

nrec – long

Input

On entry: the number of consecutive records, beginning at rec1, used in the analysis.
Constraint: nrec > 1.
4:

dblk – long

Input

On entry: the total number of records in the data block.
Constraint: dblk ≥ rec1 + nrec.
5:

data[dblk ∗ nvar] – doubleInput

On entry: the data values for the jth variable (for j = 0, 1, . . . , nvar−1) are stored in data[i∗nvar+j],
for i = 0, 1, . . . , dblk − 1.
6:nxvar – long

Input

On entry: the number of independent variables. If nxvar = 0 then all variables in the data,excluding yvar, are treated as independent variables.
Constraint: 0 ≤ nxvar < nvar.
7:

xvar[nxvar] – long

Input

On entry: the indices indicating the position in data in which values of the independent variables
are stored. If nxvar = 0 then xvar must be 0, and the indices of independent variables are given by
j = 0, 1, . . . , nvar − 1; j 6= yvar.
Constraints: if nxvar > 0, 0 ≤ xvar[i] < nvar, for i = 0, 1, . . . , nxvar − 1; otherwise xvar must be0.
8:

yvar – long

Input

On entry: the index in data in which values of the dependent variable are stored.
Constraints: 0 ≤ yvar < nvar; if nxvar > 0, yvar 6= xvar[i], for i = 0, 1, . . . , nxvar − 1.
9:

nrbf – long

Input

On entry: the number of RBFs in the model.
Constraint: nrbf ≥ 1.

nagdmc rbf.1

NAG DMC

nagdmc rbf

10:

cen[nrbf∗p] – double
Input
On entry: the locations in the input space of nrbf RBFs, stored by row. The centre location of
the kth RBF on the jth independent variable is given by cen[k ∗ p + j], for j = 0, 1, . . . , p − 1; fork = 0, 1, . . . , nrbf − 1.

11:dtype – int
Input
On entry: the value of dtype describes the distance function used. If dtype = 0, the `2 -norm orEuclidean distance is used; otherwise dtype = 1, and the `2 -norm or Manhattan distance is used.
Constraint: dtype ∈ {0, 1}.

12:

mtype – int
Input
On entry: the value of mtype determines the scaling type used to compute distances; valid options
are:
0:
1:
2:

user-supplied scalar;scale using standard deviations of data;user-supplied scalings.

The Euclidean distance has the additional option:
3: Mahalanobis distances.
Constraint: if dtype = 0, mtype ∈ {0, 1, 2, 3}; otherwise mtype ∈ {0, 1, 2}.
13:m[d ] – double
Input
On entry: an array of d user-supplied scalings used to compute the radial distances. The value ofd depends on the value of mtype. If mtype = 0, d = 1; if mtype = 2, d = p; otherwise m must be
0.
Constraint: if mtype ∈ {0, 2}, m[j] > 0.0 contains the jth user-supplied scaling value, for
j = 0, 1, . . . , d − 1.

14:

rbftype – int
Input
On entry: the value of rbftype determines the kind of radial basis function used in the model:
0: linear
1: cubic
2: thin plate spline
3: Gaussian
4: multiquadric
5: inverse multiquadric
6: Cauchy
Constraint: rbftype ∈ {0, 1, 2, 3, 4, 5, 6}.

15:

alpha – double
Input
On entry: if rbftype ∈ {4, 5, 6}, the value of the RBF parameter α; otherwise alpha is not referenced.
Constraint: if referenced, alpha > 0.0.
Suggested value: if referenced, alpha = 1.0.

16:

tol – double
Input
On entry: the value of tol used to determine the tolerance for setting eigenvalues equal to zero in
the singular value decomposition. If tol is less than the machine accuracy , tol will be set equal to.
Suggested value: tol = 1 × 10−6 .

17:lambda – double
Input
On entry: the value of the the ridge regression parameter, λ, in the penalised sum of squares error
functon. Setting: lambda = 0 gives the ordinary least squares solution.
Constraint: lambda ≥ 0.0.

18:w[1+nrbf ] – double
OutputOn exit: w[k] contains the value of the scalar multiplier on the kth RBF, for k = 0, 1, . . . , nrbf − 1;
the intercept value is stored in w[nrbf].

nagdmc rbf.2

nagdmc rbf

NAG DMC19:yhat[nrec] – double
OutputOn exit: yhat[i] contains the RBF model approximation for the dependent variable in the ith data
record, for i = 0, 1, . . . , nrec − 1.

20:

model[6 + (p + 1)(nrbf+1) + d] – double
OutputOn exit: contains information that specifies the RBF model for use in nagdmc predict rbf, whered = 1 if mtype = 0; d = p ∗ (p + 1)/2 if mtype = 3; and otherwise d = p. If model is 0, it is notreferenced and model summary information is not returned.

21:

info – int *On exit: info gives information on the success of the function call:

Outputi; i = 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, . . . , 15, 17: the specification of the ith formal parameter wasincorrect.
41: computation of the pseudo inverse failed; increasing the value of λ may avoid this error
return.
42: an error occurred computing the scalings.
99: the function failed to allocate enough memory.
100: an internal error occurred during the execution of the function.

Notation
nrec
datanxvar
nrbf
alpha
tollambdaw
yhat

the number of data records in the analysis, n.
the data values, X.
determines the number of independent variables in the analysis, p − 1.
the number of RBFs in the model, t.
a parameter for several RBFs, α.
the tolerance used in the SVD computation, τ .
the value of the regularisation parameter, λ.
the weights, wk
the RBF model approximations, ŷi , for i = 1, 2, . . . , n.

Description
Let X be a set of n data records xi on p − 1 variables, for i = 1, 2, . . . , n. Furthermore, let the valueof the dependent variable for xi be yi and assume that:yi = f (xi ) + ,for some unknown function f (·) and noise  drawn at random from a Normal distribution with zeromean and unit variance.
A radial basis function (RBF) model approximates the function f (·) by a linear combination of t
basis functions, giving an approximate value ŷi of the dependent value for xi by calculating:ŷi =tXwk hik + b,

k=1

where b is a scalar intercept term and hik = φ(zik ) is the value of an RBF φ(·) for a radial distancezik between xi and a centre location ck of the kth RBF. Equivalently, we can write:ŷi =t+1
X

wk hik ,k=1

by setting hit+1 = 1, for i = 1, 2, . . . , n.
Radial distances can be computed by one of the following distance functions:(a) the `2 -norm or Euclidean distance,1/2,zik = (xi − ck )S −1 (xi − ck )Tnagdmc rbf.3

nagdmc rbf

NAG DMCin which the metric S can be one of:(i) a diagonal matrix where each of p − 1 diagonal elements takes a user-suppliedvalue u.
(ii) a diagonal matrix where the jth diagonal element is the standard deviation of
the jth independent variable, for j = 1, 2, . . . , p − 1.
(iii) the variance-covariance matrix of the data values of independent variables,giving the Mahalanobis distance.
(iv) a diagonal matrix of p − 1 elements where the jth diagonal element takes theuser-supplied value uj , for j = 1, 2, . . . , p − 1.
(b) the `1 -norm or Manhattan distance,zik =pX(xij − ckj )/sj ,j=1

where | · | denotes the modulus operator and the scalings sj can be one of:(i) a user-supplied value sj = u, for j = 1, 2, . . . , p − 1.
(ii) scale by using standard deviations: sj equals the standard deviation of the jth
independent variable, for j = 1, 2, . . . , p − 1.
(iii) user-supplied values sj = uj , for j = 1, 2, . . . , p − 1.
The centre locations {ck ; k = 1, 2, . . . , t} can be any suitable (p − 1)-dimensional vectors. Common
methods for selecting centre locations of RBFs include:(a) the values on the independent variables for a random subset of t of the n data records;(b) the results of a cluster analysis for the independent variables of the n data records for tclusters.
The following radial basis functions φ(·) are available in NAG DMC:(a) linear: φ(z) = z;(b) cubic: φ(z) = z 3 ;(c) thin plate spline: φ(z) = z 2 ln(z);2(d) Gaussian: φ(z) = exp−z √;(e) multiquadric: φ(z, α) = z 2 + α2 ;(f) inverse multiquadric: φ(z, α) = (z 2 + α2 )−1/2 ;(g) Cauchy: φ(z, α) = (z 2 + α2 )−1 .
Values for the weights wk ; k = 1, 2, . . . , t + 1 are found by minimising the penalised (regularised)sum of squares error function:nXi=12(yi − ŷi ) + λ

t+1X

wk2 ,

k=1

by computing the pseudo-inverse of a n by t + 1 matrix H the (i, k)th element of which is hik andwith the value λ added to its diagonal elements. A singular value decomposition is used to compute
this inverse with singular values less than the largest singular value multiplied by τ treated as zero;τ can be the value of machine precision or, as suggested by Golub and van Loan (1983), a value
consistent with the accuracy of the data.

References and Further Reading
Golub G H and van Loan C F (1983) Matrix Computations John Hopkins University Press.
Light W A (1992) Some aspects of radial basis function approximation Approximation Theory,Spline Functions and Applications 356 163–190.
Miccheli C A (1986) Interpolation of scattered data: distance matrices and conditionally positivedata. Constructive Approximation 2 11–22.
Powell M J D (1985) Radial basis functions for multivariable interpolation: a review In Cox M Gand Mason J C (Editors) Algorithms for Approximation Clarendon Press Oxford.

nagdmc rbf.4

NAG DMC

nagdmc rbf

See Also
nagdmc rbf predict
rbf ex.c

predicts values of dependent variables given new data on independent
variables and a fitted RBF model.
the example calling program.

nagdmc rbf.5