G02LAF (PDF version)
G02 Chapter Contents
G02 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G02LAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

G02LAF fits an orthogonal scores partial least squares (PLS) regression by using singular value decomposition.

2  Specification

SUBROUTINE G02LAF ( N, MX, X, LDX, ISX, IP, MY, Y, LDY, XBAR, YBAR, ISCALE, XSTD, YSTD, MAXFAC, XRES, LDXRES, YRES, LDYRES, W, LDW, P, LDP, T, LDT, C, LDC, U, LDU, XCV, YCV, LDYCV, IFAIL)
INTEGER  N, MX, LDX, ISX(MX), IP, MY, LDY, ISCALE, MAXFAC, LDXRES, LDYRES, LDW, LDP, LDT, LDC, LDU, LDYCV, IFAIL
REAL (KIND=nag_wp)  X(LDX,MX), Y(LDY,MY), XBAR(IP), YBAR(MY), XSTD(IP), YSTD(MY), XRES(LDXRES,IP), YRES(LDYRES,MY), W(LDW,MAXFAC), P(LDP,MAXFAC), T(LDT,MAXFAC), C(LDC,MAXFAC), U(LDU,MAXFAC), XCV(MAXFAC), YCV(LDYCV,MY)

3  Description

Let X1 be the mean-centred n by m data matrix X of n observations on m predictor variables. Let Y1 be the mean-centred n by r data matrix Y of n observations on r response variables.
The first of the k factors PLS methods extract from the data predicts both X1 and Y1 by regressing on t1 a column vector of n scores:
X^1 = t1 p1T Y^1 = t1 c1T , with ​ t1T t1 = 1 ,  
where the column vectors of m x-loadings p1 and r y-loadings c1 are calculated in the least squares sense:
p1T = t1T X1 c1T = t1T Y1 .  
The x-score vector t1=X1w1 is the linear combination of predictor data X1 that has maximum covariance with the y-scores u1=Y1c1, where the x-weights vector w1 is the normalised first left singular vector of X1T Y1.
The method extracts subsequent PLS factors by repeating the above process with the residual matrices:
Xi = Xi-1 - X^ i-1 Yi = Yi-1 - Y^ i-1 , i=2,3,,k ,  
and with orthogonal scores:
tiT tj = 0 , j=1,2,,i-1 .  
Optionally, in addition to being mean-centred, the data matrices X1 and Y1 may be scaled by standard deviations of the variables. If data are supplied mean-centred, the calculations are not affected within numerical accuracy.

4  References

None.

5  Arguments

1:     N – INTEGERInput
On entry: n, the number of observations.
Constraint: N>1.
2:     MX – INTEGERInput
On entry: the number of predictor variables.
Constraint: MX>1.
3:     XLDXMX – REAL (KIND=nag_wp) arrayInput
On entry: Xij must contain the ith observation on the jth predictor variable, for i=1,2,,N and j=1,2,,MX.
4:     LDX – INTEGERInput
On entry: the first dimension of the array X as declared in the (sub)program from which G02LAF is called.
Constraint: LDXN.
5:     ISXMX – INTEGER arrayInput
On entry: indicates which predictor variables are to be included in the model.
ISXj=1
The jth predictor variable (with variates in the jth column of X) is included in the model.
ISXj=0
Otherwise.
Constraint: the sum of elements in ISX must equal IP.
6:     IP – INTEGERInput
On entry: m, the number of predictor variables in the model.
Constraint: 1<IPMX.
7:     MY – INTEGERInput
On entry: r, the number of response variables.
Constraint: MY1.
8:     YLDYMY – REAL (KIND=nag_wp) arrayInput
On entry: Yij must contain the ith observation for the jth response variable, for i=1,2,,N and j=1,2,,MY.
9:     LDY – INTEGERInput
On entry: the first dimension of the array Y as declared in the (sub)program from which G02LAF is called.
Constraint: LDYN.
10:   XBARIP – REAL (KIND=nag_wp) arrayOutput
On exit: mean values of predictor variables in the model.
11:   YBARMY – REAL (KIND=nag_wp) arrayOutput
On exit: the mean value of each response variable.
12:   ISCALE – INTEGERInput
On entry: indicates how predictor variables are scaled.
ISCALE=1
Data are scaled by the standard deviation of variables.
ISCALE=2
Data are scaled by user-supplied scalings.
ISCALE=-1
No scaling.
Constraint: ISCALE=-1, 1 or 2.
13:   XSTDIP – REAL (KIND=nag_wp) arrayInput/Output
On entry: if ISCALE=2, XSTDj must contain the user-supplied scaling for the jth predictor variable in the model, for j=1,2,,IP. Otherwise XSTD need not be set.
On exit: if ISCALE=1, standard deviations of predictor variables in the model. Otherwise XSTD is not changed.
14:   YSTDMY – REAL (KIND=nag_wp) arrayInput/Output
On entry: if ISCALE=2, YSTDj must contain the user-supplied scaling for the jth response variable in the model, for j=1,2,,MY. Otherwise YSTD need not be set.
On exit: if ISCALE=1, the standard deviation of each response variable. Otherwise YSTD is not changed.
15:   MAXFAC – INTEGERInput
On entry: k, the number of latent variables to calculate.
Constraint: 1MAXFACIP.
16:   XRESLDXRESIP – REAL (KIND=nag_wp) arrayOutput
On exit: the predictor variables' residual matrix Xk.
17:   LDXRES – INTEGERInput
On entry: the first dimension of the array XRES as declared in the (sub)program from which G02LAF is called.
Constraint: LDXRESN.
18:   YRESLDYRESMY – REAL (KIND=nag_wp) arrayOutput
On exit: the residuals for each response variable, Yk.
19:   LDYRES – INTEGERInput
On entry: the first dimension of the array YRES as declared in the (sub)program from which G02LAF is called.
Constraint: LDYRESN.
20:   WLDWMAXFAC – REAL (KIND=nag_wp) arrayOutput
On exit: the jth column of W contains the x-weights wj, for j=1,2,,MAXFAC.
21:   LDW – INTEGERInput
On entry: the first dimension of the array W as declared in the (sub)program from which G02LAF is called.
Constraint: LDWIP.
22:   PLDPMAXFAC – REAL (KIND=nag_wp) arrayOutput
On exit: the jth column of P contains the x-loadings pj, for j=1,2,,MAXFAC.
23:   LDP – INTEGERInput
On entry: the first dimension of the array P as declared in the (sub)program from which G02LAF is called.
Constraint: LDPIP.
24:   TLDTMAXFAC – REAL (KIND=nag_wp) arrayOutput
On exit: the jth column of T contains the x-scores tj, for j=1,2,,MAXFAC.
25:   LDT – INTEGERInput
On entry: the first dimension of the array T as declared in the (sub)program from which G02LAF is called.
Constraint: LDTN.
26:   CLDCMAXFAC – REAL (KIND=nag_wp) arrayOutput
On exit: the jth column of C contains the y-loadings cj, for j=1,2,,MAXFAC.
27:   LDC – INTEGERInput
On entry: the first dimension of the array C as declared in the (sub)program from which G02LAF is called.
Constraint: LDCMY.
28:   ULDUMAXFAC – REAL (KIND=nag_wp) arrayOutput
On exit: the jth column of U contains the y-scores uj, for j=1,2,,MAXFAC.
29:   LDU – INTEGERInput
On entry: the first dimension of the array U as declared in the (sub)program from which G02LAF is called.
Constraint: LDUN.
30:   XCVMAXFAC – REAL (KIND=nag_wp) arrayOutput
On exit: XCVj contains the cumulative percentage of variance in the predictor variables explained by the first j factors, for j=1,2,,MAXFAC.
31:   YCVLDYCVMY – REAL (KIND=nag_wp) arrayOutput
On exit: YCVij is the cumulative percentage of variance of the jth response variable explained by the first i factors, for i=1,2,,MAXFAC and j=1,2,,MY.
32:   LDYCV – INTEGERInput
On entry: the first dimension of the array YCV as declared in the (sub)program from which G02LAF is called.
Constraint: LDYCVMAXFAC.
33:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry, element value of ISX is invalid.
On entry, ISCALE=value.
Constraint: ISCALE=-1 or 1.
On entry, MX=value.
Constraint: MX>1.
On entry, MY=value.
Constraint: MY1.
On entry, N=value.
Constraint: N>1.
IFAIL=2
On entry, IP=value and MX=value.
Constraint: 1<IPMX.
On entry, LDC=value and MY=value.
Constraint: LDCMY.
On entry, LDP=value and IP=value.
Constraint: LDPIP.
On entry, LDT=value and N=value.
Constraint: LDTN.
On entry, LDU=value and N=value.
Constraint: LDUN.
On entry, LDW=value and IP=value.
Constraint: LDWIP.
On entry, LDX=value and N=value.
Constraint: LDXN.
On entry, LDXRES=value and N=value.
Constraint: LDXRESN.
On entry, LDY=value and N=value.
Constraint: LDYN.
On entry, LDYCV=value and MAXFAC=value.
Constraint: LDYCVMAXFAC.
On entry, LDYRES=value and N=value.
Constraint: LDYRESN.
On entry, MAXFAC=value and IP=value.
Constraint: 1MAXFACIP.
IFAIL=3
On entry, IP is not equal to the sum of ISX elements: IP=value, sumISX=value.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7  Accuracy

The computed singular value decomposition is nearly the exact singular value decomposition for a nearby matrix A+E , where
E2 = Oε A2 ,  
and ε  is the machine precision.

8  Parallelism and Performance

G02LAF 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 routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

G02LAF allocates internally 2mr + A + max3A+B,5A + r  elements of real storage, where A=minm,r and B=maxm,r.

10  Example

This example reads in data from an experiment to measure the biological activity in a chemical compound, and a PLS model is estimated.

10.1  Program Text

Program Text (g02lafe.f90)

10.2  Program Data

Program Data (g02lafe.d)

10.3  Program Results

Program Results (g02lafe.r)


G02LAF (PDF version)
G02 Chapter Contents
G02 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2016