NAG Library Routine Document

g02lbf (pls_wold)

1
Purpose

g02lbf fits an orthogonal scores partial least squares (PLS) regression by using Wold's iterative method.

2
Specification

Fortran Interface
Subroutine g02lbf ( n, mx, x, ldx, isx, ip, my, y, ldy, xbar, ybar, iscale, xstd, ystd, maxfac, maxit, tau, xres, ldxres, yres, ldyres, w, ldw, p, ldp, t, ldt, c, ldc, u, ldu, xcv, ycv, ldycv, ifail)
Integer, Intent (In):: n, mx, ldx, isx(mx), ip, my, ldy, iscale, maxfac, maxit, ldxres, ldyres, ldw, ldp, ldt, ldc, ldu, ldycv
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: x(ldx,mx), y(ldy,my), tau
Real (Kind=nag_wp), Intent (Inout):: 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), ycv(ldycv,my)
Real (Kind=nag_wp), Intent (Out):: xbar(ip), ybar(my), xcv(maxfac)
C Header Interface
#include <nagmk26.h>
void  g02lbf_ (const Integer *n, const Integer *mx, const double x[], const Integer *ldx, const Integer isx[], const Integer *ip, const Integer *my, const double y[], const Integer *ldy, double xbar[], double ybar[], const Integer *iscale, double xstd[], double ystd[], const Integer *maxfac, const Integer *maxit, const double *tau, double xres[], const Integer *ldxres, double yres[], const Integer *ldyres, double w[], const Integer *ldw, double p[], const Integer *ldp, double t[], const Integer *ldt, double c[], const Integer *ldc, double u[], const Integer *ldu, double xcv[], double ycv[], const Integer *ldycv, Integer *ifail)

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 a t1 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

Wold H (1966) Estimation of principal components and related models by iterative least squares In: Multivariate Analysis (ed P R Krishnaiah) 391–420 Academic Press NY

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 g02lbf 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 g02lbf 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:   maxit – IntegerInput
On entry: if my=1, maxit is not referenced; otherwise the maximum number of iterations used to calculate the x-weights.
Suggested value: maxit=200.
Constraint: if my>1, maxit>1.
17:   tau – Real (Kind=nag_wp)Input
On entry: if my=1, tau is not referenced; otherwise the iterative procedure used to calculate the x-weights will halt if the Euclidean distance between two subsequent estimates is less than or equal to tau.
Suggested value: tau=1.0E−4.
Constraint: if my>1, tau>0.0.
18:   xresldxresip – Real (Kind=nag_wp) arrayOutput
On exit: the predictor variables' residual matrix Xk.
19:   ldxres – IntegerInput
On entry: the first dimension of the array xres as declared in the (sub)program from which g02lbf is called.
Constraint: ldxresn.
20:   yresldyresmy – Real (Kind=nag_wp) arrayOutput
On exit: the residuals for each response variable, Yk.
21:   ldyres – IntegerInput
On entry: the first dimension of the array yres as declared in the (sub)program from which g02lbf is called.
Constraint: ldyresn.
22:   wldwmaxfac – Real (Kind=nag_wp) arrayOutput
On exit: the jth column of W contains the x-weights wj, for j=1,2,,maxfac.
23:   ldw – IntegerInput
On entry: the first dimension of the array w as declared in the (sub)program from which g02lbf is called.
Constraint: ldwip.
24:   pldpmaxfac – Real (Kind=nag_wp) arrayOutput
On exit: the jth column of P contains the x-loadings pj, for j=1,2,,maxfac.
25:   ldp – IntegerInput
On entry: the first dimension of the array p as declared in the (sub)program from which g02lbf is called.
Constraint: ldpip.
26:   tldtmaxfac – Real (Kind=nag_wp) arrayOutput
On exit: the jth column of T contains the x-scores tj, for j=1,2,,maxfac.
27:   ldt – IntegerInput
On entry: the first dimension of the array t as declared in the (sub)program from which g02lbf is called.
Constraint: ldtn.
28:   cldcmaxfac – Real (Kind=nag_wp) arrayOutput
On exit: the jth column of C contains the y-loadings cj, for j=1,2,,maxfac.
29:   ldc – IntegerInput
On entry: the first dimension of the array c as declared in the (sub)program from which g02lbf is called.
Constraint: ldcmy.
30:   uldumaxfac – Real (Kind=nag_wp) arrayOutput
On exit: the jth column of U contains the y-scores uj, for j=1,2,,maxfac.
31:   ldu – IntegerInput
On entry: the first dimension of the array u as declared in the (sub)program from which g02lbf is called.
Constraint: ldun.
32:   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.
33:   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.
34:   ldycv – IntegerInput
On entry: the first dimension of the array ycv as declared in the (sub)program from which g02lbf is called.
Constraint: ldycvmaxfac.
35:   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, iscale=value.
Constraint: iscale=-1 or 1.
On entry, isxvalue is invalid.
Constraint: isxj=0 or 1, for all j.
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: ldyres<n.
On entry, maxfac=value and ip=value.
Constraint: 1maxfacip.
On entry, my=value and maxit=value.
Constraint: if my>1, maxit>1.
On entry, tau=value.
Constraint: if my>1, tau>0.0.
ifail=3
On entry, ip=value and sumisx=value.
Constraint: the sum of elements in isx must equal ip.
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

In general, the iterative method used in the calculations is less accurate (but faster) than the singular value decomposition approach adopted by g02laf.

8
Parallelism and Performance

g02lbf 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

g02lbf allocates internally (n+r) elements of real storage.

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 (g02lbfe.f90)

10.2
Program Data

Program Data (g02lbfe.d)

10.3
Program Results

Program Results (g02lbfe.r)