nag_pls_orth_scores_pred (g02ldc) (PDF version)
g02 Chapter Contents
g02 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_pls_orth_scores_pred (g02ldc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_pls_orth_scores_pred (g02ldc) calculates predictions given the output from an orthogonal scores PLS regression (nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (g02lbc)) and nag_pls_orth_scores_fit (g02lcc).

2  Specification

#include <nag.h>
#include <nagg02.h>
void  nag_pls_orth_scores_pred (Nag_OrderType order, Integer ip, Integer my, Nag_EstimatesOption orig, const double xbar[], const double ybar[], Nag_ScalePredictor iscale, const double xstd[], const double ystd[], const double b[], Integer pdb, Integer n, Integer mz, const Integer isz[], const double z[], Integer pdz, double yhat[], Integer pdyhat, NagError *fail)

3  Description

nag_pls_orth_scores_pred (g02ldc) 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_pls_orth_scores_fit (g02lcc).
If nag_pls_orth_scores_fit (g02lcc) returns parameter estimates for the original data scale, no further information is required.
If nag_pls_orth_scores_fit (g02lcc) 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_pls_orth_scores_svd (g02lac) and nag_pls_orth_scores_wold (g02lbc).

4  References

None.

5  Arguments

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 order=Nag_RowMajor. See Section 2.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2:     ip IntegerInput
On entry: the number of predictor variables in the fitted model. ip must take the same value as that supplied to nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (g02lbc) to fit the model.
Constraint: ip>1.
3:     my IntegerInput
On entry: the number of response variables in the fitted model. my must take the same value as that supplied to nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (g02lbc) to fit the model.
Constraint: my1.
4:     orig Nag_EstimatesOptionInput
On entry: indicates how parameter estimates are supplied.
orig=Nag_EstimatesOrig
Parameter estimates are for the original data.
orig=Nag_EstimatesStand
Parameter estimates are for the centred, and possibly scaled, data.
Constraint: orig=Nag_EstimatesStand or Nag_EstimatesOrig.
5:     xbar[ip] const doubleInput
On entry: if orig=Nag_EstimatesStand, xbar must contain mean values of predictor variables in the model; otherwise xbar is not referenced.
6:     ybar[my] const doubleInput
On entry: if orig=Nag_EstimatesStand, ybar must contain the mean value of each response variable in the model; otherwise ybar is not referenced.
7:     iscale Nag_ScalePredictorInput
On entry: if orig=Nag_EstimatesStand, iscale must take the value supplied to either nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (g02lbc); otherwise iscale is not referenced.
Constraint: if orig=Nag_EstimatesStand, iscale=Nag_PredNoScale, Nag_PredStdScale or Nag_PredUserScale.
8:     xstd[ip] const doubleInput
On entry: if orig=Nag_EstimatesStand and iscaleNag_PredNoScale, xstd must contain the scalings of predictor variables in the model as returned from either nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (g02lbc); otherwise xstd is not referenced.
9:     ystd[my] const doubleInput
On entry: if orig=Nag_EstimatesStand and iscaleNag_PredNoScale, ystd must contain the scalings of response variables as returned from either nag_pls_orth_scores_svd (g02lac) or nag_pls_orth_scores_wold (g02lbc); otherwise ystd is not referenced.
10:   b[dim] const doubleInput
Note: the dimension, dim, of the array b must be at least
  • max1,pdb×my when order=Nag_ColMajor;
  • max1,ip×pdb when order=Nag_RowMajor and orig=Nag_EstimatesStand;
  • max1,1+ip×pdb when order=Nag_RowMajor and orig=Nag_EstimatesOrig.
The i,jth element of the matrix B is stored in
  • b[j-1×pdb+i-1] when order=Nag_ColMajor;
  • b[i-1×pdb+j-1] when order=Nag_RowMajor.
On entry: if orig=Nag_EstimatesStand, b must contain the parameter estimate for the centred, and possibly scaled, data as returned by nag_pls_orth_scores_fit (g02lcc); otherwise b must contain the parameter estimates for the original data as returned by nag_pls_orth_scores_fit (g02lcc).
11:   pdb IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array b.
Constraints:
  • if order=Nag_ColMajor,
    • if orig=Nag_EstimatesStand, pdbip;
    • if orig=Nag_EstimatesOrig, pdb1+ip;
  • if order=Nag_RowMajor, pdbmy.
12:   n IntegerInput
On entry: n, the number of observations in the test data Z.
Constraint: n1.
13:   mz IntegerInput
On entry: the number of available predictor variables in the test data.
Constraint: mzip.
14:   isz[mz] const IntegerInput
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 isz[j-1]=1, the jth predictor variable is included in the model, for j=1,2,,mz, otherwise isz[j-1]=0.
Constraints:
  • isz[j-1]=0​ or ​1, for j=1,2,,mz;
  • jisz[j-1]=ip.
15:   z[dim] const doubleInput
Note: the dimension, dim, of the array z must be at least
  • max1,pdz×mz when order=Nag_ColMajor;
  • max1,n×pdz when order=Nag_RowMajor.
Where Zi,j appears in this document, it refers to the array element
  • z[j-1×pdz+i-1] when order=Nag_ColMajor;
  • z[i-1×pdz+j-1] when order=Nag_RowMajor.
On entry: Zi,j contains the ith observation on the jth available predictor variable, for i=1,2,,n and j=1,2,,mz.
16:   pdz IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array z.
Constraints:
  • if order=Nag_ColMajor, pdzn;
  • if order=Nag_RowMajor, pdzmz.
17:   yhat[dim] doubleOutput
Note: the dimension, dim, of the array yhat must be at least
  • max1,pdyhat×my when order=Nag_ColMajor;
  • max1,n×pdyhat when order=Nag_RowMajor.
Where YHATi,j appears in this document, it refers to the array element
  • yhat[j-1×pdyhat+i-1] when order=Nag_ColMajor;
  • yhat[i-1×pdyhat+j-1] when order=Nag_RowMajor.
On exit: YHATi,j contains the ith predicted value of the jth y-variable in the model.
18:   pdyhat IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array yhat.
Constraints:
  • if order=Nag_ColMajor, pdyhatn;
  • if order=Nag_RowMajor, pdyhatmy.
19:   fail NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_ENUM_CHARACTER
On entry, iscale=value.
Constraint: if orig=Nag_EstimatesStand, iscale=Nag_PredNoScale, Nag_PredStdScale or Nag_PredUserScale.
NE_INT
On entry, ip=value.
Constraint: ip>1.
On entry, my=value.
Constraint: my1.
On entry, n=value.
Constraint: n1.
On entry, pdb=value.
Constraint: pdb>0.
On entry, pdyhat=value.
Constraint: pdyhat>0.
On entry, pdz=value.
Constraint: pdz>0.
NE_INT_2
On entry, mz=value and ip=value.
Constraint: mzip.
On entry, pdb=value and ip+1=value.
Constraint: if orig=Nag_EstimatesOrig, pdb1+ip.
On entry, pdb=value and ip=value.
Constraint: if orig=Nag_EstimatesStand, pdbip.
On entry, pdb=value and my=value.
Constraint: pdbmy.
On entry, pdyhat=value and my=value.
Constraint: pdyhatmy.
On entry, pdyhat=value and n=value.
Constraint: pdyhatn.
On entry, pdz=value and mz=value.
Constraint: pdzmz.
On entry, pdz=value and n=value.
Constraint: pdzn.
NE_INT_ARG_CONS
On entry, the number of elements of isz equal to 1 is not ip.
NE_INT_ARRAY_VAL_1_OR_2
On entry, isz[j-1]=value, j=value.
Constraint: isz[j-1]=0​ or ​1.
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.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.

7  Accuracy

Not applicable.

8  Parallelism and Performance

nag_pls_orth_scores_pred (g02ldc) 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

nag_pls_orth_scores_pred (g02ldc) allocates internally 3×ip+my elements of double 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 (g02ldce.c)

10.2  Program Data

Program Data (g02ldce.d)

10.3  Program Results

Program Results (g02ldce.r)


nag_pls_orth_scores_pred (g02ldc) (PDF version)
g02 Chapter Contents
g02 Chapter Introduction
NAG Library Manual

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