g02 Chapter Contents
g02 Chapter Introduction
NAG C Library Manual

NAG Library Function Documentnag_pls_orth_scores_pred (g02ldc)

1  Purpose

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

2  Specification

 #include #include
 void nag_pls_orth_scores_pred (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)

3  Description

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

None.

5  Arguments

1:     orderNag_OrderTypeInput
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.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or Nag_ColMajor.
2:     ipIntegerInput
On entry: the number of predictor variables in the fitted model. ip must take the same value as that supplied to nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (g02lbc) to fit the model.
Constraint: ${\mathbf{ip}}>1$.
3:     myIntegerInput
On entry: the number of response variables in the fitted model. my must take the same value as that supplied to nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (g02lbc) to fit the model.
Constraint: ${\mathbf{my}}\ge 1$.
4:     origNag_EstimatesOptionInput
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:     xbar[ip]const doubleInput
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:     ybar[my]const doubleInput
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:     iscaleNag_ScalePredictorInput
On entry: if ${\mathbf{orig}}=\mathrm{Nag_EstimatesStand}$, iscale must take the value supplied to either nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (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:     xstd[ip]const doubleInput
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 nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (g02lbc); otherwise xstd is not referenced.
9:     ystd[my]const doubleInput
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 nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (g02lbc); otherwise ystd is not referenced.
10:   b[$\mathit{dim}$]const doubleInput
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 nag_pls_orth_scores_fit (g02lcc); otherwise b must contain the parameter estimates for the original data as returned by nag_pls_orth_scores_fit (g02lcc).
11:   pdbIntegerInput
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:   nIntegerInput
On entry: $n$, the number of observations in the test data $Z$.
Constraint: ${\mathbf{n}}\ge 1$.
13:   mzIntegerInput
On entry: the number of available predictor variables in the test data.
Constraint: ${\mathbf{mz}}\ge {\mathbf{ip}}$.
14:   isz[mz]const IntegerInput
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:   z[$\mathit{dim}$]const doubleInput
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:   pdzIntegerInput
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:   yhat[$\mathit{dim}$]doubleOutput
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:   pdyhatIntegerInput
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:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
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[j-1\right]=〈\mathit{\text{value}}〉$, $j=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{isz}}\left[j-1\right]=0\text{​ 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.

7  Accuracy

Not applicable.

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

9  Example

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

9.1  Program Text

Program Text (g02ldce.c)

9.2  Program Data

Program Data (g02ldce.d)

9.3  Program Results

Program Results (g02ldce.r)