g02lc calculates parameter estimates for a given number of factors given the output from an orthogonal scores PLS regression (g02la or g02lb).

# Syntax

C#
```public static void g02lc(
int ip,
int my,
int maxfac,
int nfact,
double[,] p,
double[,] c,
double[,] w,
double rcond,
double[,] b,
int orig,
double[] xbar,
double[] ybar,
int iscale,
double[] xstd,
double[] ystd,
double[,] ob,
int vipopt,
double[,] ycv,
double[,] vip,
out int ifail
)```
Visual Basic
```Public Shared Sub g02lc ( _
ip As Integer, _
my As Integer, _
maxfac As Integer, _
nfact As Integer, _
p As Double(,), _
c As Double(,), _
w As Double(,), _
rcond As Double, _
b As Double(,), _
orig As Integer, _
xbar As Double(), _
ybar As Double(), _
iscale As Integer, _
xstd As Double(), _
ystd As Double(), _
ob As Double(,), _
vipopt As Integer, _
ycv As Double(,), _
vip As Double(,), _
<OutAttribute> ByRef ifail As Integer _
)```
Visual C++
```public:
static void g02lc(
int ip,
int my,
int maxfac,
int nfact,
array<double,2>^ p,
array<double,2>^ c,
array<double,2>^ w,
double rcond,
array<double,2>^ b,
int orig,
array<double>^ xbar,
array<double>^ ybar,
int iscale,
array<double>^ xstd,
array<double>^ ystd,
array<double,2>^ ob,
int vipopt,
array<double,2>^ ycv,
array<double,2>^ vip,
[OutAttribute] int% ifail
)```
F#
```static member g02lc :
ip : int *
my : int *
maxfac : int *
nfact : int *
p : float[,] *
c : float[,] *
w : float[,] *
rcond : float *
b : float[,] *
orig : int *
xbar : float[] *
ybar : float[] *
iscale : int *
xstd : float[] *
ystd : float[] *
ob : float[,] *
vipopt : int *
ycv : float[,] *
vip : float[,] *
ifail : int byref -> unit
```

#### Parameters

ip
Type: System..::..Int32
On entry: $m$, the number of predictor variables in the fitted model.
Constraint: ${\mathbf{ip}}>1$.
my
Type: System..::..Int32
On entry: $r$, the number of response variables.
Constraint: ${\mathbf{my}}\ge 1$.
maxfac
Type: System..::..Int32
On entry: $k$, the number of factors available in the PLS model.
Constraint: $1\le {\mathbf{maxfac}}\le {\mathbf{ip}}$.
nfact
Type: System..::..Int32
On entry: $l$, the number of factors to include in the calculation of parameter estimates.
Constraint: $1\le {\mathbf{nfact}}\le {\mathbf{maxfac}}$.
p
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, maxfac]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{ip}}$
On entry: $x$-loadings as returned from g02la and g02lb.
c
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, maxfac]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{my}}$
On entry: $y$-loadings as returned from g02la and g02lb.
w
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, maxfac]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{ip}}$
On entry: $x$-weights as returned from g02la and g02lb.
rcond
Type: System..::..Double
On entry: singular values of ${P}^{\mathrm{T}}W$ less than rcond times the maximum singular value are treated as zero when calculating parameter estimates. If rcond is negative, a value of $0.005$ is used.
b
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, my]
Note: dim1 must satisfy the constraint: $\mathrm{dim1}\ge {\mathbf{ip}}$
On exit: ${\mathbf{b}}\left[\mathit{i}-1,\mathit{j}-1\right]$ contains the parameter estimate for the $\mathit{i}$th predictor variable in the model for the $\mathit{j}$th response variable, for $\mathit{i}=1,2,\dots ,{\mathbf{ip}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{my}}$.
orig
Type: System..::..Int32
On entry: indicates how parameter estimates are calculated.
${\mathbf{orig}}=-1$
Parameter estimates for the centered, and possibly, scaled data.
${\mathbf{orig}}=1$
Parameter estimates for the original data.
Constraint: ${\mathbf{orig}}=-1$ or $1$.
xbar
Type: array<System..::..Double>[]()[][]
An array of size [ip]
On entry: if ${\mathbf{orig}}=1$, 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$, 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$, 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$, the scalings of response variables as returned from either g02la or g02lb; otherwise ystd is not referenced.
ob
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}}+1$;
• otherwise $\mathrm{dim1}\ge 1$.
On exit: if ${\mathbf{orig}}=1$, ${\mathbf{ob}}\left[0,\mathit{j}-1\right]$ contains the intercept value for the $\mathit{j}$th response variable, and ${\mathbf{ob}}\left[\mathit{i},\mathit{j}-1\right]$ contains the parameter estimate on the original scale for the $\mathit{i}$th predictor variable in the model, for $\mathit{i}=1,2,\dots ,{\mathbf{ip}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{my}}$. Otherwise ob is not referenced.
vipopt
Type: System..::..Int32
On entry: a flag that determines variable influence on projections (VIP) options.
${\mathbf{vipopt}}=0$
VIP are not calculated.
${\mathbf{vipopt}}=1$
VIP are calculated for predictor variables using the mean explained variance in responses.
${\mathbf{vipopt}}={\mathbf{my}}$
VIP are calculated for predictor variables for each response variable in the model.
Note that setting ${\mathbf{vipopt}}={\mathbf{my}}$ when ${\mathbf{my}}=1$ gives the same result as setting ${\mathbf{vipopt}}=1$ directly.
Constraint: ${\mathbf{vipopt}}=0$, $1$ or ${\mathbf{my}}$.
ycv
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, my]
Note: dim1 must satisfy the constraint: if ${\mathbf{vipopt}}\ne 0$, $\mathrm{dim1}\ge {\mathbf{nfact}}$
On entry: if ${\mathbf{vipopt}}\ne 0$, ${\mathbf{ycv}}\left[\mathit{i}-1,\mathit{j}-1\right]$ is the cumulative percentage of variance of the $\mathit{j}$th response variable explained by the first $\mathit{i}$ factors, for $\mathit{i}=1,2,\dots ,{\mathbf{nfact}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{my}}$; otherwise ycv is not referenced.
vip
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, vipopt]
Note: dim1 must satisfy the constraint: if ${\mathbf{vipopt}}\ne 0$, $\mathrm{dim1}\ge {\mathbf{ip}}$
On exit: if ${\mathbf{vipopt}}=1$, ${\mathbf{vip}}\left[\mathit{i}-1,0\right]$ contains the VIP statistic for the $\mathit{i}$th predictor variable in the model for all response variables, for $\mathit{i}=1,2,\dots ,{\mathbf{ip}}$.
If ${\mathbf{vipopt}}={\mathbf{my}}$, ${\mathbf{vip}}\left[\mathit{i}-1,\mathit{j}-1\right]$ contains the VIP statistic for the $\mathit{i}$th predictor variable in the model for the $\mathit{j}$th response variable, for $\mathit{i}=1,2,\dots ,{\mathbf{ip}}$ and $\mathit{j}=1,2,\dots ,{\mathbf{my}}$.
Otherwise vip is not referenced.
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

The parameter estimates $B$ for a $l$-factor orthogonal scores PLS model with $m$ predictor variables and $r$ response variables are given by,
 $B=WPTW-1CT, B∈ℝm×r,$
where $W$ is the $m$ by $k$ ($\ge l$) matrix of $x$-weights; $P$ is the $m$ by $k$ matrix of $x$-loadings; and $C$ is the $r$ by $k$ matrix of $y$-loadings for a fitted PLS model.
The parameter estimates $B$ are for centred, and possibly scaled, predictor data ${X}_{1}$ and response data ${Y}_{1}$. Parameter estimates may also be given for the predictor data $X$ and response data $Y$.
Optionally, g02lc will calculate variable influence on projection (VIP) statistics, see Wold (1994).

# References

Wold S (1994) PLS for multivariate linear modelling QSAR: chemometric methods in molecular design Methods and Principles in Medicinal Chemistry (ed van de Waterbeemd H) Verlag-Chemie

# Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDP, LDC, LDW, LDB, LDOB, LDYCV, LDVIP) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{ip}}<2$, 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{vipopt}}\ne 0$, $1$ or ${\mathbf{my}}$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{maxfac}}<1$ or ${\mathbf{maxfac}}>{\mathbf{ip}}$, or ${\mathbf{nfact}}<1$ or ${\mathbf{nfact}}>{\mathbf{maxfac}}$,
${\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}}〉$

# Accuracy

The calculations are based on the singular value decomposition of ${P}^{\mathrm{T}}W$.

# Parallelism and Performance

None.

g02lc allocates internally $l\left(l+r+4\right)+\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(2l,r\right)$ elements of real storage.

# Example

This example reads in details of a PLS model, and a set of parameter estimates are calculated along with their VIP statistics.

Example program (C#): g02lce.cs

Example program data: g02lce.d

Example program results: g02lce.r