# NAG CL Interfaceg02ldc (pls_​pred)

Settings help

CL Name Style:

## 1Purpose

g02ldc calculates predictions given the output from an orthogonal scores PLS regression (g02lac or g02lbc) and g02lcc.

## 2Specification

 #include
 void g02ldc (Nag_OrderType order, Integer ip, Integer my, Nag_EstimatesOption orig, const double xbar[], const double ybar[], Nag_ScalePredictor iscale, const double xstd[], const double ystd[], const double b[], Integer pdb, Integer n, Integer mz, const Integer isz[], const double z[], Integer pdz, double yhat[], Integer pdyhat, NagError *fail)
The function may be called by the names: g02ldc, nag_correg_pls_pred or nag_pls_orth_scores_pred.

## 3Description

g02ldc 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 g02lcc.
If g02lcc returns parameter estimates for the original data scale, no further information is required.
If g02lcc 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 g02lac and g02lbc.

None.

## 5Arguments

1: $\mathbf{order}$Nag_OrderType Input
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 ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. 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.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{ip}$Integer Input
On entry: the number of predictor variables in the fitted model. ip must take the same value as that supplied to g02lac or g02lbc to fit the model.
Constraint: ${\mathbf{ip}}>1$.
3: $\mathbf{my}$Integer Input
On entry: the number of response variables in the fitted model. my must take the same value as that supplied to g02lac or g02lbc to fit the model.
Constraint: ${\mathbf{my}}\ge 1$.
4: $\mathbf{orig}$Nag_EstimatesOption Input
On entry: indicates how parameter estimates are supplied.
${\mathbf{orig}}=\mathrm{Nag_EstimatesOrig}$
Parameter estimates are for the original data.
${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$
Parameter estimates are for the centred, and possibly scaled, data.
Constraint: ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$ or $\mathrm{Nag_EstimatesOrig}$.
5: $\mathbf{xbar}\left[{\mathbf{ip}}\right]$const double Input
On entry: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$, xbar must contain mean values of predictor variables in the model; otherwise xbar is not referenced.
6: $\mathbf{ybar}\left[{\mathbf{my}}\right]$const double Input
On entry: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$, ybar must contain the mean value of each response variable in the model; otherwise ybar is not referenced.
7: $\mathbf{iscale}$Nag_ScalePredictor Input
On entry: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$, iscale must take the value supplied to either g02lac or g02lbc; otherwise iscale is not referenced.
Constraint: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$, ${\mathbf{iscale}}=\mathrm{Nag_PredNoScale}$, $\mathrm{Nag_PredStdScale}$ or $\mathrm{Nag_PredUserScale}$.
8: $\mathbf{xstd}\left[{\mathbf{ip}}\right]$const double Input
On entry: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$ and ${\mathbf{iscale}}\ne \mathrm{Nag_PredNoScale}$, xstd must contain the scalings of predictor variables in the model as returned from either g02lac or g02lbc; otherwise xstd is not referenced.
9: $\mathbf{ystd}\left[{\mathbf{my}}\right]$const double Input
On entry: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$ and ${\mathbf{iscale}}\ne \mathrm{Nag_PredNoScale}$, ystd must contain the scalings of response variables as returned from either g02lac or g02lbc; otherwise ystd is not referenced.
10: $\mathbf{b}\left[\mathit{dim}\right]$const double Input
Note: the dimension, dim, of the array b must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdb}}×{\mathbf{my}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{ip}}×{\mathbf{pdb}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ and ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,1+{\mathbf{ip}}×{\mathbf{pdb}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ and ${\mathbf{orig}}=\mathrm{Nag_EstimatesOrig}$.
the $\left(i,j\right)$th element of the matrix $B$ is stored in
• ${\mathbf{b}}\left[\left(j-1\right)×{\mathbf{pdb}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{pdb}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$, b must contain the parameter estimate for the centred, and possibly scaled, data as returned by g02lcc; otherwise b must contain the parameter estimates for the original data as returned by g02lcc.
11: $\mathbf{pdb}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array b.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$,
• if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$, ${\mathbf{pdb}}\ge {\mathbf{ip}}$;
• if ${\mathbf{orig}}=\mathrm{Nag_EstimatesOrig}$, ${\mathbf{pdb}}\ge 1+{\mathbf{ip}}$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdb}}\ge {\mathbf{my}}$.
12: $\mathbf{n}$Integer Input
On entry: $n$, the number of observations in the test data $Z$.
Constraint: ${\mathbf{n}}\ge 1$.
13: $\mathbf{mz}$Integer Input
On entry: the number of available predictor variables in the test data.
Constraint: ${\mathbf{mz}}\ge {\mathbf{ip}}$.
14: $\mathbf{isz}\left[{\mathbf{mz}}\right]$const Integer Input
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}}$.
15: $\mathbf{z}\left[\mathit{dim}\right]$const double Input
Note: the dimension, dim, of the array z must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdz}}×{\mathbf{mz}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdz}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
where ${\mathbf{Z}}\left(i,j\right)$ appears in this document, it refers to the array element
• ${\mathbf{z}}\left[\left(j-1\right)×{\mathbf{pdz}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{z}}\left[\left(i-1\right)×{\mathbf{pdz}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
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}}$.
16: $\mathbf{pdz}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array z.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdz}}\ge {\mathbf{n}}$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdz}}\ge {\mathbf{mz}}$.
17: $\mathbf{yhat}\left[\mathit{dim}\right]$double Output
Note: the dimension, dim, of the array yhat must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdyhat}}×{\mathbf{my}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdyhat}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
where ${\mathbf{YHAT}}\left(i,j\right)$ appears in this document, it refers to the array element
• ${\mathbf{yhat}}\left[\left(j-1\right)×{\mathbf{pdyhat}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{yhat}}\left[\left(i-1\right)×{\mathbf{pdyhat}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: ${\mathbf{YHAT}}\left(i,j\right)$ contains the $i$th predicted value of the $j$th $y$-variable in the model.
18: $\mathbf{pdyhat}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array yhat.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdyhat}}\ge {\mathbf{n}}$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdyhat}}\ge {\mathbf{my}}$.
19: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_ENUM_CHARACTER
On entry, ${\mathbf{iscale}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$, ${\mathbf{iscale}}=\mathrm{Nag_PredNoScale}$, $\mathrm{Nag_PredStdScale}$ or $\mathrm{Nag_PredUserScale}$.
NE_INT
On entry, ${\mathbf{ip}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ip}}>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{pdb}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}>0$.
On entry, ${\mathbf{pdyhat}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdyhat}}>0$.
On entry, ${\mathbf{pdz}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdz}}>0$.
NE_INT_2
On entry, ${\mathbf{mz}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ip}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{mz}}\ge {\mathbf{ip}}$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ip}}+1=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesOrig}$, ${\mathbf{pdb}}\ge 1+{\mathbf{ip}}$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ip}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$, ${\mathbf{pdb}}\ge {\mathbf{ip}}$.
On entry, ${\mathbf{pdb}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{my}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdb}}\ge {\mathbf{my}}$.
On entry, ${\mathbf{pdyhat}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{my}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdyhat}}\ge {\mathbf{my}}$.
On entry, ${\mathbf{pdyhat}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdyhat}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{pdz}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{mz}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdz}}\ge {\mathbf{mz}}$.
On entry, ${\mathbf{pdz}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdz}}\ge {\mathbf{n}}$.
NE_INT_ARG_CONS
On entry, the number of elements of isz equal to $1$ is not ip.
NE_INT_ARRAY_VAL_1_OR_2
On entry, ${\mathbf{isz}}\left[⟨\mathit{\text{value}}⟩\right]=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{isz}}\left[j-1\right]=0$ or $1$.
NE_INTERNAL_ERROR
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.
NE_NO_LICENCE
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.

Not applicable.

## 8Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
g02ldc 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.

## 9Further Comments

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

## 10Example

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

### 10.1Program Text

Program Text (g02ldce.c)

### 10.2Program Data

Program Data (g02ldce.d)

### 10.3Program Results

Program Results (g02ldce.r)