hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_correg_pls_pred (g02ld)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_correg_pls_pred (g02ld) calculates predictions given the output from an orthogonal scores PLS regression (nag_correg_pls_svd (g02la) or nag_correg_pls_wold (g02lb)) and nag_correg_pls_fit (g02lc).

Syntax

[yhat, ifail] = g02ld(orig, xbar, ybar, iscale, xstd, ystd, b, isz, z, 'ip', ip, 'my', my, 'n', n, 'mz', mz)
[yhat, ifail] = nag_correg_pls_pred(orig, xbar, ybar, iscale, xstd, ystd, b, isz, z, 'ip', ip, 'my', my, 'n', n, 'mz', mz)

Description

nag_correg_pls_pred (g02ld) calculates the predictions Y^ of a PLS model given a set Z of test data and a set B of parameter estimates as returned by nag_correg_pls_fit (g02lc).
If nag_correg_pls_fit (g02lc) returns parameter estimates for the original data scale, no further information is required.
If nag_correg_pls_fit (g02lc) 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_correg_pls_svd (g02la) and nag_correg_pls_wold (g02lb).

References

None.

Parameters

Compulsory Input Parameters

1:     orig int64int32nag_int scalar
Indicates how parameter estimates are supplied.
orig=1
Parameter estimates are for the original data.
orig=-1
Parameter estimates are for the centred, and possibly scaled, data.
Constraint: orig=-1 or 1.
2:     xbarip – double array
If orig=-1, xbar must contain mean values of predictor variables in the model; otherwise xbar is not referenced.
3:     ybarmy – double array
If orig=-1, ybar must contain the mean value of each response variable in the model; otherwise ybar is not referenced.
4:     iscale int64int32nag_int scalar
If orig=-1, iscale must take the value supplied to either nag_correg_pls_svd (g02la) or nag_correg_pls_wold (g02lb); otherwise iscale is not referenced.
Constraint: if orig=-1, iscale=-1, 1 or 2.
5:     xstdip – double array
If orig=-1 and iscale-1, xstd must contain the scalings of predictor variables in the model as returned from either nag_correg_pls_svd (g02la) or nag_correg_pls_wold (g02lb); otherwise xstd is not referenced.
6:     ystdmy – double array
If orig=-1 and iscale-1, ystd must contain the scalings of response variables as returned from either nag_correg_pls_svd (g02la) or nag_correg_pls_wold (g02lb); otherwise ystd is not referenced.
7:     bldbmy – double array
ldb, the first dimension of the array, must satisfy the constraint
  • if orig=-1, ldbip;
  • if orig=1, ldb1+ip.
If orig=-1, b must contain the parameter estimate for the centred, and possibly scaled, data as returned by nag_correg_pls_fit (g02lc); otherwise b must contain the parameter estimates for the original data as returned by nag_correg_pls_fit (g02lc).
8:     iszmz int64int32nag_int array
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 iszj=1, the jth predictor variable is included in the model, for j=1,2,,mz, otherwise iszj=0.
Constraints:
  • iszj=0​ or ​1, for j=1,2,,mz;
  • jiszj=ip.
9:     zldzmz – double array
ldz, the first dimension of the array, must satisfy the constraint ldzn.
zij contains the ith observation on the jth available predictor variable, for i=1,2,,n and j=1,2,,mz.

Optional Input Parameters

1:     ip int64int32nag_int scalar
Default: the dimension of the arrays xbar, xstd. (An error is raised if these dimensions are not equal.)
The number of predictor variables in the fitted model. ip must take the same value as that supplied to nag_correg_pls_svd (g02la) or nag_correg_pls_wold (g02lb) to fit the model.
Constraint: ip>1.
2:     my int64int32nag_int scalar
Default: the dimension of the arrays ybar, ystd and the second dimension of the array b. (An error is raised if these dimensions are not equal.)
The number of response variables in the fitted model. my must take the same value as that supplied to nag_correg_pls_svd (g02la) or nag_correg_pls_wold (g02lb) to fit the model.
Constraint: my1.
3:     n int64int32nag_int scalar
Default: the first dimension of the array z.
n, the number of observations in the test data Z.
Constraint: n1.
4:     mz int64int32nag_int scalar
Default: the dimension of the array isz and the second dimension of the array z. (An error is raised if these dimensions are not equal.)
The number of available predictor variables in the test data.
Constraint: mzip.

Output Parameters

1:     yhatldyhatmy – double array
yhatij contains the ith predicted value of the jth y-variable in the model.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
Constraint: if orig=-1, iscale=-1, 1 or 2.
Constraint: ip>1.
Constraint: iszj=0​ or ​1.
Constraint: my1.
Constraint: n1.
Constraint: orig=-1 or 1.
   ifail=2
Constraint: if orig=1, ldb1+ip.
Constraint: if orig=-1, ldbip.
Constraint: ldyhatn.
Constraint: ldzn.
Constraint: mzip.
   ifail=3
On entry, the number of elements of isz equal to 1 is not ip.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Not applicable.

Further Comments

nag_correg_pls_pred (g02ld) allocates internally 3×ip+my elements of double storage.

Example

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


fprintf('g02ld example results\n\n');

n = 15;
z = zeros(n,n);
z(:,1:8) = ...
       [-2.6931, -2.5271, -1.2871, 3.0777,  0.3891, -0.0701,  1.9607, -1.6324;
        -2.6931, -2.5271, -1.2871, 3.0777,  0.3891, -0.0701,  1.9607, -1.6324;
        -2.6931, -2.5271, -1.2871, 3.0777,  0.3891, -0.0701,  0.0744, -1.7333;
        -2.6931, -2.5271, -1.2871, 3.0777,  0.3891, -0.0701,  0.0744, -1.7333;
        -2.6931, -2.5271, -1.2871, 2.8369,  1.4092, -3.1398,  0.0744, -1.7333;
        -2.6931, -2.5271, -1.2871, 3.0777,  0.3891, -0.0701, -4.7548,  3.6521;
        -2.6931, -2.5271, -1.2871, 3.0777,  0.3891, -0.0701,  0.0744, -1.7333;
        -2.6931, -2.5271, -1.2871, 3.0777,  0.3891, -0.0701,  2.4064,  1.7438;
        -2.6931, -2.5271, -1.2871, 0.0744, -1.7333,  0.0902,  0.0744, -1.7333;
         2.2261, -5.3648,  0.3049, 3.0777,  0.3891, -0.0701,  0.0744, -1.7333;
        -4.1921, -1.0285, -0.9801, 3.0777,  0.3891, -0.0701,  0.0744, -1.7333;
        -4.9217,  1.2977,  0.4473, 3.0777,  0.3891, -0.0701,  0.0744, -1.7333;
        -2.6931, -2.5271, -1.2871, 3.0777,  0.3891, -0.0701,  2.2261, -5.3648;
        -2.6931, -2.5271, -1.2871, 3.0777,  0.3891, -0.0701, -4.9217,  1.2977;
        -2.6931, -2.5271, -1.2871, 3.0777,  0.3891, -0.0701, -4.1921, -1.0285];
z(:,9:n) = ...
       [ 0.5746,  1.9607, -1.6324, 0.5740,  2.8369,  1.4092, -3.1398;
         0.5746,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398;
         0.0902,  1.9607, -1.6324, 0.5746,  2.8369,  1.4092, -3.1398;
         0.0902,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398;
         0.0902,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398;
         0.8524,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398;
         0.0902,  0.0744, -1.7333, 0.0902, -1.2201,  0.8829,  2.2253;
         1.1057,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398;
         0.0902,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398;
         0.0902,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398;
         0.0902,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398;
         0.0902,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398;
         0.3049,  2.2261, -5.3648, 0.3049,  2.8369,  1.4092, -3.1398;
         0.4473,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398;
        -0.9801,  0.0744, -1.7333, 0.0902,  2.8369,  1.4092, -3.1398];


% Means and scalings
orig = int64(-1);
xbar = [-2.6137; -2.3614; -1.0449;  2.8614;  0.3156;
        -0.2641; -0.3146; -1.1221;  0.2401;  0.4694;
        -1.9619;  0.1691;  2.5664;  1.3741; -2.7821];
ybar = [0.452];
iscale = int64(1);
xstd = [ 1.4956;  1.3233;  0.5829;  0.7735;  0.6247;
         0.7966;  2.4113;  2.0421;  0.4678;  0.8197;
         0.9420;  0.1735;  1.0475;  0.1359;  1.3853];
ystd = [0.9062];

b    = [-0.1383;  0.0572; -0.1906;  0.1238;  0.0591;
         0.0936; -0.2842;  0.4713;  0.2661; -0.0914;
         0.1226; -0.0488;  0.0332;  0.0332; -0.0332];
isz = ones(n, 1, 'int64');

% Calculate predictions
[yhat, ifail] = g02ld( ...
                       orig, xbar, ybar, iscale, xstd, ystd, b, isz, z);

% Display results
disp('Predicted values');
disp(yhat);


g02ld example results

Predicted values
    0.2132
    0.5152
    0.1437
    0.4459
    0.1716
    2.4809
    0.0964
    1.4475
   -0.1546
   -0.5492
    0.5393
    0.2686
   -1.1332
    1.7975
    0.4973


PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015