NAG Library Routine Document

g02ldf  (pls_pred)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

g02ldf calculates predictions given the output from an orthogonal scores PLS regression (g02laf or g02lbf) and g02lcf.

2
Specification

Fortran Interface
Subroutine g02ldf ( ip, my, orig, xbar, ybar, iscale, xstd, ystd, b, ldb, n, mz, isz, z, ldz, yhat, ldyhat, ifail)
Integer, Intent (In):: ip, my, orig, iscale, ldb, n, mz, isz(mz), ldz, ldyhat
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: xbar(ip), ybar(my), xstd(ip), ystd(my), b(ldb,my), z(ldz,mz)
Real (Kind=nag_wp), Intent (Inout):: yhat(ldyhat,my)
C Header Interface
#include nagmk26.h
void  g02ldf_ ( const Integer *ip, const Integer *my, const Integer *orig, const double xbar[], const double ybar[], const Integer *iscale, const double xstd[], const double ystd[], const double b[], const Integer *ldb, const Integer *n, const Integer *mz, const Integer isz[], const double z[], const Integer *ldz, double yhat[], const Integer *ldyhat, Integer *ifail)

3
Description

g02ldf 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 g02lcf.
If g02lcf returns parameter estimates for the original data scale, no further information is required.
If g02lcf 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 g02laf and g02lbf.

4
References

None.

5
Arguments

1:     ip – IntegerInput
On entry: the number of predictor variables in the fitted model. ip must take the same value as that supplied to g02laf or g02lbf to fit the model.
Constraint: ip>1.
2:     my – IntegerInput
On entry: the number of response variables in the fitted model. my must take the same value as that supplied to g02laf or g02lbf to fit the model.
Constraint: my1.
3:     orig – IntegerInput
On entry: 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.
4:     xbarip – Real (Kind=nag_wp) arrayInput
On entry: if orig=-1, xbar must contain mean values of predictor variables in the model; otherwise xbar is not referenced.
5:     ybarmy – Real (Kind=nag_wp) arrayInput
On entry: if orig=-1, ybar must contain the mean value of each response variable in the model; otherwise ybar is not referenced.
6:     iscale – IntegerInput
On entry: if orig=-1, iscale must take the value supplied to either g02laf or g02lbf; otherwise iscale is not referenced.
Constraint: if orig=-1, iscale=-1, 1 or 2.
7:     xstdip – Real (Kind=nag_wp) arrayInput
On entry: if orig=-1 and iscale-1, xstd must contain the scalings of predictor variables in the model as returned from either g02laf or g02lbf; otherwise xstd is not referenced.
8:     ystdmy – Real (Kind=nag_wp) arrayInput
On entry: if orig=-1 and iscale-1, ystd must contain the scalings of response variables as returned from either g02laf or g02lbf; otherwise ystd is not referenced.
9:     bldbmy – Real (Kind=nag_wp) arrayInput
On entry: if orig=-1, b must contain the parameter estimate for the centred, and possibly scaled, data as returned by g02lcf; otherwise b must contain the parameter estimates for the original data as returned by g02lcf.
10:   ldb – IntegerInput
On entry: the first dimension of the array b as declared in the (sub)program from which g02ldf is called. If orig=-1, ldb must be at least ip; otherwise b also contains the estimate for the intercept parameter and consequently ldb must be at least 1+ip.
Constraints:
  • if orig=-1, ldbip;
  • if orig=1, ldb1+ip.
11:   n – IntegerInput
On entry: n, the number of observations in the test data Z.
Constraint: n1.
12:   mz – IntegerInput
On entry: the number of available predictor variables in the test data.
Constraint: mzip.
13:   iszmz – Integer arrayInput
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 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.
14:   zldzmz – Real (Kind=nag_wp) arrayInput
On entry: zij contains the ith observation on the jth available predictor variable, for i=1,2,,n and j=1,2,,mz.
15:   ldz – IntegerInput
On entry: the first dimension of the array z as declared in the (sub)program from which g02ldf is called.
Constraint: ldzn.
16:   yhatldyhatmy – Real (Kind=nag_wp) arrayOutput
On exit: yhatij contains the ith predicted value of the jth y-variable in the model.
17:   ldyhat – IntegerInput
On entry: the first dimension of the array yhat as declared in the (sub)program from which g02ldf is called.
Constraint: ldyhatn.
18:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, ip=value.
Constraint: ip>1.
On entry, iscale=value.
Constraint: if orig=-1, iscale=-1, 1 or 2.
On entry, iszj=value, j=value.
Constraint: iszj=0​ or ​1.
On entry, my=value.
Constraint: my1.
On entry, n=value.
Constraint: n1.
On entry, orig=value.
Constraint: orig=-1 or 1.
ifail=2
On entry, ldb=value and ip=value.
Constraint: if orig=-1, ldbip.
On entry, ldb=value and ip+1=value.
Constraint: if orig=1, ldb1+ip.
On entry, ldyhat=value and n=value.
Constraint: ldyhatn.
On entry, ldz=value and n=value.
Constraint: ldzn.
On entry, mz=value and ip=value.
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.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

Not applicable.

8
Parallelism and Performance

g02ldf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9
Further Comments

g02ldf allocates internally 3×ip+my elements of real storage.

10
Example

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

10.1
Program Text

Program Text (g02ldfe.f90)

10.2
Program Data

Program Data (g02ldfe.d)

10.3
Program Results

Program Results (g02ldfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017