nag_pls_orth_scores_svd (g02lac) fits an orthogonal scores partial least squares (PLS) regression by using singular value decomposition.
| #include <nag.h> |
| #include <nagg02.h> |
| void |
nag_pls_orth_scores_svd (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,
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:
None.
- 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:
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 .
- 18:
pdxres – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
xres.
Constraints:
- if ,
;
- if , .
- 19:
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, .
- 20:
pdyres – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
yres.
Constraints:
- if ,
;
- if , .
- 21:
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 .
- 22:
pdw – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
w.
Constraints:
- if ,
;
- if , .
- 23:
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 .
- 24:
pdp – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
p.
Constraints:
- if ,
;
- if , .
- 25:
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 .
- 26:
pdt – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
t.
Constraints:
- if ,
;
- if , .
- 27:
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 .
- 28:
pdc – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
c.
Constraints:
- if ,
;
- if , .
- 29:
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 .
- 30:
pdu – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
u.
Constraints:
- if ,
;
- if , .
- 31:
xcv[maxfac] – doubleOutput
-
On exit: contains the cumulative percentage of variance in the predictor variables explained by the first factors, for .
- 32:
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 .
- 33:
pdycv – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
ycv.
Constraints:
- if ,
;
- if , .
- 34:
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: .
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.
The computed singular value decomposition is nearly the exact singular value decomposition for a nearby matrix
, where
and
is the
machine precision.
This example reads in data from an experiment to measure the biological activity in a chemical compound, and a PLS model is estimated.