The function may be called by the names: g02kac, nag_correg_ridge_opt or nag_regsn_ridge_opt.
A linear model has the form:
is an matrix of values of a dependent variable;
is a scalar intercept term;
is an matrix of values of independent variables;
is an matrix of unknown values of parameters;
is an matrix of unknown random errors such that variance of .
Let be the mean-centred and the mean-centred . Furthermore, is scaled such that the diagonal elements of the cross product matrix are one. The linear model now takes the form:
Ridge regression estimates the parameters in a penalised least squares sense by finding the that minimizes
where denotes the -norm and is a scalar regularization or ridge parameter. For a given value of , the parameter estimates are found by evaluating
Note that if the ridge regression solution is equivalent to the ordinary least squares solution.
Rather than calculate the inverse of () directly, g02kac uses the singular value decomposition (SVD) of . After decomposing into where and are orthogonal matrices and is a diagonal matrix, the parameter estimates become
A consequence of introducing the ridge parameter is that the effective number of parameters, , in the model is given by the sum of diagonal elements of
Any multi-collinearity in the design matrix may be highlighted by calculating the variance inflation factors for the fitted model. The th variance inflation factor, , is a scaled version of the multiple correlation coefficient between independent variable and the other independent variables, , and is given by
The variance inflation factors are calculated as the diagonal elements of the matrix:
which, using the SVD of , is equivalent to the diagonal elements of the matrix:
Although parameter estimates are calculated by using , it is usual to report the parameter estimates associated with . These are calculated from , and the means and scalings of . Optionally, either or may be calculated.
The method can adopt one of four criteria to minimize while calculating a suitable value for :
(a)Generalized cross-validation (GCV):
(b)Unbiased estimate of variance (UEV):
(c)Future prediction error (FPE):
(d)Bayesian information criterion (BIC):
where is the sum of squares of residuals. However, the function returns all four of the above prediction errors regardless of the one selected to minimize the ridge parameter, . Furthermore, the function will optionally return the leave-one-out cross-validation (LOOCV) prediction error.
Hastie T, Tibshirani R and Friedman J (2003) The Elements of Statistical Learning: Data Mining, Inference and Prediction Springer Series in Statistics
Moody J.E. (1992) The effective number of parameters: An analysis of generalisation and regularisation in nonlinear learning systems In: Neural Information Processing Systems (eds J E Moody, S J Hanson, and R P Lippmann) 4 847–854 Morgan Kaufmann San Mateo CA
1: – Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by . See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
2: – IntegerInput
On entry: , the number of observations.
3: – IntegerInput
On entry: the number of independent variables available in the data matrix .
4: – const doubleInput
Note: the dimension, dim, of the array x
must be at least
where appears in this document, it refers to the array element
On entry: the values of independent variables in the data matrix .
5: – IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
if , ;
6: – const IntegerInput
On entry: indicates which independent variables are included in the model.
The th variable in x will be included in the model.
Variable is excluded.
or , for .
7: – IntegerInput
On entry: , the number of independent variables in the model.
On entry: singular values less than tau of the SVD of the data matrix will be set equal to zero.
9: – const doubleInput
On entry: the values of the dependent variable .
10: – double *Input/Output
On entry: an initial value for the ridge regression parameter ; used as a starting point for the optimization.
On exit: h is the optimized value of the ridge regression parameter .
11: – Nag_PredictErrorInput
On entry: the measure of prediction error used to optimize the ridge regression parameter . The value of opt must be set equal to one of:
Generalized cross-validation (GCV);
Unbiased estimate of variance (UEV)
Future prediction error (FPE)
Bayesian information criteron (BIC).
, , or .
12: – Integer *Input/Output
On entry: the maximum number of iterations allowed to optimize the ridge regression parameter .
On exit: the number of iterations used to optimize the ridge regression parameter within tol.
13: – doubleInput
On entry: iterations of the ridge regression parameter will halt when consecutive values of lie within tol.
14: – double *Output
On exit: the number of effective parameters, , in the model.
15: – Nag_EstimatesOptionInput
On entry: if , the parameter estimates are calculated for the original data; otherwise and the parameter estimates are calculated for the standardized data.
16: – doubleOutput
On exit: contains the intercept and parameter estimates for the fitted ridge regression model in the order indicated by isx. The first element of b contains the estimate for the intercept;
contains the parameter estimate for the th independent variable in the model, for .
17: – doubleOutput
On exit: the variance inflation factors in the order indicated by isx. For the
th independent variable in the model, is the value of , for .
18: – doubleOutput
On exit: is the value of the th residual for the fitted ridge regression model, for .
19: – double *Output
On exit: the sum of squares of residual values.
20: – Integer *Output
On exit: the degrees of freedom for the residual sum of squares rss.
21: – Nag_OptionLOOInput
On entry: if , the leave-one-out cross-validation estimate of prediction error is calculated; otherwise no such estimate is calculated and .
22: – doubleOutput
On exit: the first four elements contain, in this order, the measures of prediction error: GCV, UEV, FPE and BIC.
If , is the LOOCV estimate of prediction error; otherwise is not referenced.
23: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
On entry, ; .
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument had an illegal value.
On entry, .
On entry, .
On entry, and .
On entry, ; . Constraint: .
On entry, ; .
On entry, .
On entry, .
Constraint: or .
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.
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.
On entry, .
On entry, .
On entry, .
SVD failed to converge.
Maximum number of iterations used.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g02kac is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g02kac makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
g02kac allocates internally elements of double precision storage.
This example reads in data from an experiment to model body fat, and a ridge regression is calculated that optimizes GCV prediction error.