g02ld calculates predictions given the output from an orthogonal scores PLS regression (g02la or g02lb) and g02lc.

# Syntax

C#
```public static void g02ld(
int ip,
int my,
int orig,
double[] xbar,
double[] ybar,
int iscale,
double[] xstd,
double[] ystd,
double[,] b,
int n,
int mz,
int[] isz,
double[,] z,
double[,] yhat,
out int ifail
)```
Visual Basic
```Public Shared Sub g02ld ( _
ip As Integer, _
my As Integer, _
orig As Integer, _
xbar As Double(), _
ybar As Double(), _
iscale As Integer, _
xstd As Double(), _
ystd As Double(), _
b As Double(,), _
n As Integer, _
mz As Integer, _
isz As Integer(), _
z As Double(,), _
yhat As Double(,), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g02ld(
int ip,
int my,
int orig,
array<double>^ xbar,
array<double>^ ybar,
int iscale,
array<double>^ xstd,
array<double>^ ystd,
array<double,2>^ b,
int n,
int mz,
array<int>^ isz,
array<double,2>^ z,
array<double,2>^ yhat,
[OutAttribute] int% ifail
)```
F#
```static member g02ld :
ip : int *
my : int *
orig : int *
xbar : float[] *
ybar : float[] *
iscale : int *
xstd : float[] *
ystd : float[] *
b : float[,] *
n : int *
mz : int *
isz : int[] *
z : float[,] *
yhat : float[,] *
ifail : int byref -> unit
```

#### Parameters

ip
Type: System..::..Int32
On entry: the number of predictor variables in the fitted model. ip must take the same value as that supplied to g02la or g02lb to fit the model.
Constraint: ${\mathbf{ip}}>1$.
my
Type: System..::..Int32
On entry: the number of response variables in the fitted model. my must take the same value as that supplied to g02la or g02lb to fit the model.
Constraint: ${\mathbf{my}}\ge 1$.
orig
Type: System..::..Int32
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$.
xbar
Type: array<System..::..Double>[]()[][]
An array of size [ip]
On entry: if ${\mathbf{orig}}=-1$, xbar must contain mean values of predictor variables in the model; otherwise xbar is not referenced.
ybar
Type: array<System..::..Double>[]()[][]
An array of size [my]
On entry: if ${\mathbf{orig}}=-1$, ybar must contain the mean value of each response variable in the model; otherwise ybar is not referenced.
iscale
Type: System..::..Int32
On entry: if ${\mathbf{orig}}=-1$, iscale must take the value supplied to either g02la or g02lb; otherwise iscale is not referenced.
Constraint: if ${\mathbf{orig}}=-1$, ${\mathbf{iscale}}=-1$, $1$ or $2$.
xstd
Type: array<System..::..Double>[]()[][]
An array of size [ip]
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 g02la or g02lb; otherwise xstd is not referenced.
ystd
Type: array<System..::..Double>[]()[][]
An array of size [my]
On entry: if ${\mathbf{orig}}=-1$ and ${\mathbf{iscale}}\ne -1$, ystd must contain the scalings of response variables as returned from either g02la or g02lb; otherwise ystd is not referenced.
b
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, my]
Note: dim1 must satisfy the constraint:
• if ${\mathbf{orig}}=-1$, $\mathrm{dim1}\ge {\mathbf{ip}}$;
• if ${\mathbf{orig}}=1$, $\mathrm{dim1}\ge 1+{\mathbf{ip}}$.
On entry: if ${\mathbf{orig}}=-1$, b must contain the parameter estimate for the centred, and possibly scaled, data as returned by g02lc; otherwise b must contain the parameter estimates for the original data as returned by g02lc.
n
Type: System..::..Int32
On entry: $n$, the number of observations in the test data $Z$.
Constraint: ${\mathbf{n}}\ge 1$.
mz
Type: System..::..Int32
On entry: the number of available predictor variables in the test data.
Constraint: ${\mathbf{mz}}\ge {\mathbf{ip}}$.
isz
Type: array<System..::..Int32>[]()[][]
An array of size [mz]
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}-1\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-1\right]=0$.
Constraints:
• ${\mathbf{isz}}\left[\mathit{j}-1\right]=0\text{​ or ​}1$, for $\mathit{j}=1,2,\dots ,{\mathbf{mz}}$;
• ${\sum }_{j}{\mathbf{isz}}\left[j-1\right]={\mathbf{ip}}$.
z
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, mz]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{n}}$
On entry: ${\mathbf{z}}\left[\mathit{i}-1,\mathit{j}-1\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}}$.
yhat
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, my]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{n}}$
On exit: ${\mathbf{yhat}}\left[i-1,j-1\right]$ contains the $i$th predicted value of the $j$th $y$-variable in the model.
ifail
Type: System..::..Int32%
On exit: ${\mathbf{ifail}}={0}$ unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

# Description

g02ld 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 g02lc.
If g02lc returns parameter estimates for the original data scale, no further information is required.
If g02lc 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 g02la and g02lb.

None.

# Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDB, LDZ, LDYHAT) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{ip}}\le 1$, or ${\mathbf{my}}<1$, or ${\mathbf{orig}}\ne -1$ or $1$, or ${\mathbf{orig}}=-1$ and ${\mathbf{iscale}}\ne -1$, $1$ or $2$, or ${\mathbf{n}}<1$, or an element of ${\mathbf{isz}}\ne 0$ or $1$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{mz}}<{\mathbf{ip}}$,
${\mathbf{ifail}}=3$
The sum of elements in isz does not equal ip.
${\mathbf{ifail}}=-9000$
An error occured, see message report.
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-4000$
Invalid dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-8000$
Negative dimension for array $〈\mathit{\text{value}}〉$
${\mathbf{ifail}}=-6000$
Invalid Parameters $〈\mathit{\text{value}}〉$

Not applicable.

# Parallelism and Performance

None.

g02ld allocates internally $3×{\mathbf{ip}}+{\mathbf{my}}$ elements of real storage.

# Example

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

Example program (C#): g02lde.cs

Example program data: g02lde.d

Example program results: g02lde.r