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

# NAG Library Routine DocumentG02LDF

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.

## 1  Purpose

G02LDF calculates predictions given the output from an orthogonal scores PLS regression (G02LAF or G02LBF) and G02LCF.

## 2  Specification

 SUBROUTINE G02LDF ( IP, MY, ORIG, XBAR, YBAR, ISCALE, XSTD, YSTD, B, LDB, N, MZ, ISZ, Z, LDZ, YHAT, LDYHAT, IFAIL)
 INTEGER IP, MY, ORIG, ISCALE, LDB, N, MZ, ISZ(MZ), LDZ, LDYHAT, IFAIL REAL (KIND=nag_wp) XBAR(IP), YBAR(MY), XSTD(IP), YSTD(MY), B(LDB,MY), Z(LDZ,MZ), YHAT(LDYHAT,MY)

## 3  Description

G02LDF calculates the predictions $\stackrel{^}{Y}$ of a PLS model given a set $Z$ of test data and a set $B$ of parameter estimates as returned by G02LCF.
If G02LCF returns parameter estimates for the original data scale, no further information is required.
If G02LCF returns parameter estimates for the centred, and possibly scaled, data, further information is required. The means of variables in the fitted model must be supplied. In the case of a PLS model fitted by using scaled data, the means and standard deviations of variables in the fitted model must also be supplied. These means and standard deviations are those returned by either G02LAF and G02LBF.

None.

## 5  Arguments

1:     $\mathrm{IP}$ – INTEGERInput
On entry: the number of predictor variables in the fitted model. IP must take the same value as that supplied to G02LAF or G02LBF to fit the model.
Constraint: ${\mathbf{IP}}>1$.
2:     $\mathrm{MY}$ – INTEGERInput
On entry: the number of response variables in the fitted model. MY must take the same value as that supplied to G02LAF or G02LBF to fit the model.
Constraint: ${\mathbf{MY}}\ge 1$.
3:     $\mathrm{ORIG}$ – INTEGERInput
On entry: indicates how parameter estimates are supplied.
${\mathbf{ORIG}}=1$
Parameter estimates are for the original data.
${\mathbf{ORIG}}=-1$
Parameter estimates are for the centred, and possibly scaled, data.
Constraint: ${\mathbf{ORIG}}=-1$ or $1$.
4:     $\mathrm{XBAR}\left({\mathbf{IP}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: if ${\mathbf{ORIG}}=-1$, XBAR must contain mean values of predictor variables in the model; otherwise XBAR is not referenced.
5:     $\mathrm{YBAR}\left({\mathbf{MY}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: if ${\mathbf{ORIG}}=-1$, YBAR must contain the mean value of each response variable in the model; otherwise YBAR is not referenced.
6:     $\mathrm{ISCALE}$ – INTEGERInput
On entry: if ${\mathbf{ORIG}}=-1$, ISCALE must take the value supplied to either G02LAF or G02LBF; otherwise ISCALE is not referenced.
Constraint: if ${\mathbf{ORIG}}=-1$, ${\mathbf{ISCALE}}=-1$, $1$ or $2$.
7:     $\mathrm{XSTD}\left({\mathbf{IP}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: if ${\mathbf{ORIG}}=-1$ and ${\mathbf{ISCALE}}\ne -1$, XSTD must contain the scalings of predictor variables in the model as returned from either G02LAF or G02LBF; otherwise XSTD is not referenced.
8:     $\mathrm{YSTD}\left({\mathbf{MY}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: if ${\mathbf{ORIG}}=-1$ and ${\mathbf{ISCALE}}\ne -1$, YSTD must contain the scalings of response variables as returned from either G02LAF or G02LBF; otherwise YSTD is not referenced.
9:     $\mathrm{B}\left({\mathbf{LDB}},{\mathbf{MY}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: if ${\mathbf{ORIG}}=-1$, B must contain the parameter estimate for the centred, and possibly scaled, data as returned by G02LCF; otherwise B must contain the parameter estimates for the original data as returned by G02LCF.
10:   $\mathrm{LDB}$ – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which G02LDF is called. If ${\mathbf{ORIG}}=-1$, LDB must be at least IP; otherwise B also contains the estimate for the intercept parameter and consequently LDB must be at least $1+{\mathbf{IP}}$.
Constraints:
• if ${\mathbf{ORIG}}=-1$, ${\mathbf{LDB}}\ge {\mathbf{IP}}$;
• if ${\mathbf{ORIG}}=1$, ${\mathbf{LDB}}\ge 1+{\mathbf{IP}}$.
11:   $\mathrm{N}$ – INTEGERInput
On entry: $n$, the number of observations in the test data $Z$.
Constraint: ${\mathbf{N}}\ge 1$.
12:   $\mathrm{MZ}$ – INTEGERInput
On entry: the number of available predictor variables in the test data.
Constraint: ${\mathbf{MZ}}\ge {\mathbf{IP}}$.
13:   $\mathrm{ISZ}\left({\mathbf{MZ}}\right)$ – INTEGER arrayInput
On entry: indicates which predictor variables are to be included in the model. Predictor variables included from Z must be in the same order as those included in the fitted model.
If ${\mathbf{ISZ}}\left(\mathit{j}\right)=1$, the $\mathit{j}$th predictor variable is included in the model, for $\mathit{j}=1,2,\dots ,{\mathbf{MZ}}$, otherwise ${\mathbf{ISZ}}\left(j\right)=0$.
Constraints:
• ${\mathbf{ISZ}}\left(\mathit{j}\right)=0\text{​ or ​}1$, for $\mathit{j}=1,2,\dots ,{\mathbf{MZ}}$;
• ${\sum }_{j}{\mathbf{ISZ}}\left(j\right)={\mathbf{IP}}$.
14:   $\mathrm{Z}\left({\mathbf{LDZ}},{\mathbf{MZ}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{Z}}\left(\mathit{i},\mathit{j}\right)$ contains the $\mathit{i}$th observation on the $\mathit{j}$th available predictor variable, for $\mathit{i}=1,2,\dots ,{\mathbf{N}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{MZ}}$.
15:   $\mathrm{LDZ}$ – INTEGERInput
On entry: the first dimension of the array Z as declared in the (sub)program from which G02LDF is called.
Constraint: ${\mathbf{LDZ}}\ge {\mathbf{N}}$.
16:   $\mathrm{YHAT}\left({\mathbf{LDYHAT}},{\mathbf{MY}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{YHAT}}\left(i,j\right)$ contains the $i$th predicted value of the $j$th $y$-variable in the model.
17:   $\mathrm{LDYHAT}$ – INTEGERInput
On entry: the first dimension of the array YHAT as declared in the (sub)program from which G02LDF is called.
Constraint: ${\mathbf{LDYHAT}}\ge {\mathbf{N}}$.
18:   $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ 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\text{​ 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 $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{IFAIL}}=1$
On entry, ${\mathbf{IP}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{IP}}>1$.
On entry, ${\mathbf{ISCALE}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{ORIG}}=-1$, ${\mathbf{ISCALE}}=-1$, $1$ or $2$.
On entry, ${\mathbf{ISZ}}\left(j\right)=〈\mathit{\text{value}}〉$, $j=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ISZ}}\left(j\right)=0\text{​ or ​}1$.
On entry, ${\mathbf{MY}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{MY}}\ge 1$.
On entry, ${\mathbf{N}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{N}}\ge 1$.
On entry, ${\mathbf{ORIG}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ORIG}}=-1$ or $1$.
${\mathbf{IFAIL}}=2$
On entry, ${\mathbf{LDB}}=〈\mathit{\text{value}}〉$ and ${\mathbf{IP}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{ORIG}}=-1$, ${\mathbf{LDB}}\ge {\mathbf{IP}}$.
On entry, ${\mathbf{LDB}}=〈\mathit{\text{value}}〉$ and ${\mathbf{IP}}+1=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{ORIG}}=1$, ${\mathbf{LDB}}\ge 1+{\mathbf{IP}}$.
On entry, ${\mathbf{LDYHAT}}=〈\mathit{\text{value}}〉$ and ${\mathbf{N}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{LDYHAT}}\ge {\mathbf{N}}$.
On entry, ${\mathbf{LDZ}}=〈\mathit{\text{value}}〉$ and ${\mathbf{N}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{LDZ}}\ge {\mathbf{N}}$.
On entry, ${\mathbf{MZ}}=〈\mathit{\text{value}}〉$ and ${\mathbf{IP}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{MZ}}\ge {\mathbf{IP}}$.
${\mathbf{IFAIL}}=3$
On entry, the number of elements of ISZ equal to $1$ is not IP.
${\mathbf{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.
${\mathbf{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.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

Not applicable.

## 8  Parallelism and Performance

G02LDF 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

G02LDF allocates internally $3×{\mathbf{IP}}+{\mathbf{MY}}$ elements of real storage.

## 10  Example

This example reads in parameter estimates for a fitted PLS model and prediction data, and the PLS model predictions are calculated.

### 10.1  Program Text

Program Text (g02ldfe.f90)

### 10.2  Program Data

Program Data (g02ldfe.d)

### 10.3  Program Results

Program Results (g02ldfe.r)

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