nag_pls_orth_scores_wold (g02lbc) fits an orthogonal scores partial least squares (PLS) regression by using Wold's iterative method.
| #include <nag.h> |
| #include <nagg02.h> |
| void |
nag_pls_orth_scores_wold (Nag_OrderType order,
Integer n,
Integer mx,
const double x[],
Integer pdx,
const Integer isx[],
Integer ip,
Integer my,
const double y[],
Integer pdy,
double xbar[],
double ybar[],
Nag_ScalePredictor iscale,
double xstd[],
double ystd[],
Integer maxfac,
Integer maxit,
double tau,
double xres[],
Integer pdxres,
double yres[],
Integer pdyres,
double w[],
Integer pdw,
double p[],
Integer pdp,
double t[],
Integer pdt,
double c[],
Integer pdc,
double u[],
Integer pdu,
double xcv[],
double ycv[],
Integer pdycv,
NagError *fail) |
|
The first of the
factors PLS methods extract from the data predicts both
and
by regressing on a
column vector of
scores:
where the column vectors of
-loadings
and
-loadings
are calculated in the least squares sense:
The method extracts subsequent PLS factors by repeating the above process with the residual matrices:
and with orthogonal scores:
Wold H (1966) Estimation of principal components and related models by iterative least-squares In: Multivariate Analysis (ed P R Krishnaiah) 391–420 Academic Press NY
- 1:
order – Nag_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
. See
Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint:
or Nag_ColMajor.
- 2:
n – IntegerInput
-
On entry:
, the number of observations.
Constraint:
.
- 3:
mx – IntegerInput
-
On entry: the number of predictor variables.
Constraint:
.
- 4:
x[] – const doubleInput
-
Note: the dimension,
dim, of the array
x
must be at least
- when ;
- when .
Where
appears in this document, it refers to the array element
- when ;
- when .
On entry: must contain the th observation on the th predictor variable, for and .
- 5:
pdx – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
x.
Constraints:
- if ,
;
- if , .
- 6:
isx[mx] – const IntegerInput
-
On entry: indicates which predictor variables are to be included in the model.
- The th predictor variable (with variates in the th column of ) is included in the model.
- Otherwise.
Constraint:
the sum of elements in
isx must equal
ip.
- 7:
ip – IntegerInput
-
On entry:
, the number of predictor variables in the model.
Constraint:
.
- 8:
my – IntegerInput
-
On entry:
, the number of response variables.
Constraint:
.
- 9:
y[] – const doubleInput
-
Note: the dimension,
dim, of the array
y
must be at least
- when ;
- when .
Where
appears in this document, it refers to the array element
- when ;
- when .
On entry: must contain the th observation for the th response variable, for and .
- 10:
pdy – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
y.
Constraints:
- if ,
;
- if , .
- 11:
xbar[ip] – doubleOutput
-
On exit: mean values of predictor variables in the model.
- 12:
ybar[my] – doubleOutput
-
On exit: the mean value of each response variable.
- 13:
iscale – Nag_ScalePredictorInput
-
On entry: indicates how predictor variables are scaled.
- Data are scaled by the standard deviation of variables.
- Data are scaled by user-supplied scalings.
- No scaling.
Constraint:
, or .
- 14:
xstd[ip] – doubleInput/Output
-
On entry: if
,
must contain the user-supplied scaling for the
th predictor variable in the model, for
. Otherwise
xstd need not be set.
On exit: if
, standard deviations of predictor variables in the model. Otherwise
xstd is not changed.
- 15:
ystd[my] – doubleInput/Output
-
On entry: if
,
must contain the user-supplied scaling for the
th response variable in the model, for
. Otherwise
ystd need not be set.
On exit: if
, the standard deviation of each response variable. Otherwise
ystd is not changed.
- 16:
maxfac – IntegerInput
-
On entry:
, the number of latent variables to calculate.
Constraint:
.
- 17:
maxit – IntegerInput
-
On entry: if
,
maxit is not referenced; otherwise the maximum number of iterations used to calculate the
-weights.
Suggested value:
.
Constraint:
if , .
- 18:
tau – doubleInput
-
On entry: if
,
tau is not referenced; otherwise the iterative procedure used to calculate the
-weights will halt if the Euclidean distance between two subsequent estimates is less than or equal to
tau.
Suggested value:
.
Constraint:
if , .
- 19:
xres[] – doubleOutput
-
Note: the dimension,
dim, of the array
xres
must be at least
- when ;
- when .
The
th element of the matrix is stored in
- when ;
- when .
On exit: the predictor variables' residual matrix .
- 20:
pdxres – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
xres.
Constraints:
- if ,
;
- if , .
- 21:
yres[] – doubleOutput
-
Note: the dimension,
dim, of the array
yres
must be at least
- when ;
- when .
The
th element of the matrix is stored in
- when ;
- when .
On exit: the residuals for each response variable, .
- 22:
pdyres – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
yres.
Constraints:
- if ,
;
- if , .
- 23:
w[] – doubleOutput
-
Note: the dimension,
dim, of the array
w
must be at least
- when ;
- when .
The
th element of the matrix
is stored in
- when ;
- when .
On exit: the th column of contains the -weights , for .
- 24:
pdw – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
w.
Constraints:
- if ,
;
- if , .
- 25:
p[] – doubleOutput
-
Note: the dimension,
dim, of the array
p
must be at least
- when ;
- when .
The
th element of the matrix
is stored in
- when ;
- when .
On exit: the th column of contains the -loadings , for .
- 26:
pdp – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
p.
Constraints:
- if ,
;
- if , .
- 27:
t[] – doubleOutput
-
Note: the dimension,
dim, of the array
t
must be at least
- when ;
- when .
The
th element of the matrix
is stored in
- when ;
- when .
On exit: the th column of contains the -scores , for .
- 28:
pdt – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
t.
Constraints:
- if ,
;
- if , .
- 29:
c[] – doubleOutput
-
Note: the dimension,
dim, of the array
c
must be at least
- when ;
- when .
The
th element of the matrix
is stored in
- when ;
- when .
On exit: the th column of contains the -loadings , for .
- 30:
pdc – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
c.
Constraints:
- if ,
;
- if , .
- 31:
u[] – doubleOutput
-
Note: the dimension,
dim, of the array
u
must be at least
- when ;
- when .
The
th element of the matrix
is stored in
- when ;
- when .
On exit: the th column of contains the -scores , for .
- 32:
pdu – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
u.
Constraints:
- if ,
;
- if , .
- 33:
xcv[maxfac] – doubleOutput
-
On exit: contains the cumulative percentage of variance in the predictor variables explained by the first factors, for .
- 34:
ycv[] – doubleOutput
-
Note: the dimension,
dim, of the array
ycv
must be at least
- when ;
- when .
Where
appears in this document, it refers to the array element
- when ;
- when .
On exit: is the cumulative percentage of variance of the th response variable explained by the first factors, for and .
- 35:
pdycv – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
ycv.
Constraints:
- if ,
;
- if , .
- 36:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
- NE_ALLOC_FAIL
Dynamic memory allocation failed.
- NE_BAD_PARAM
On entry, argument had an illegal value.
- NE_INT
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INT_2
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: if , .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
- NE_INT_ARG_CONS
On entry,
ip is not equal to the sum of
isx elements:
,
.
- NE_INT_ARRAY_VAL_1_OR_2
On entry, element
of
isx is invalid.
- 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.
- NE_REAL
On entry, .
Constraint: if , .
In general, the iterative method used in the calculations is less accurate (but faster) than the singular value decomposition approach adopted by
nag_pls_orth_scores_svd (g02lac).
This example reads in data from an experiment to measure the biological activity in a chemical compound, and a PLS model is estimated.