G05PWF (PDF version)
G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G05PWF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

G05PWF generates a dataset suitable for use with repeated random sub-sampling validation.

2  Specification

SUBROUTINE G05PWF ( NT, N, M, SORDX, X, LDX, USEY, Y, USEW, W, STATE, IFAIL)
INTEGER  NT, N, M, SORDX, LDX, USEY, USEW, STATE(*), IFAIL
REAL (KIND=nag_wp)  X(LDX,*), Y(*), W(*)

3  Description

Let Xo denote a matrix of n observations on m variables and yo and wo each denote a vector of length n. For example, Xo might represent a matrix of independent variables, yo the dependent variable and wo the associated weights in a weighted regression.
G05PWF generates a series of training datasets, denoted by the matrix, vector, vector triplet Xt,yt,wt of nt observations, and validation datasets, denoted Xv,yv,wv with nv observations. These training and validation datasets are generated by randomly assigning each observation to either the training dataset or the validation dataset.
The resulting datasets are suitable for use with repeated random sub-sampling validation.
One of the initialization routines G05KFF (for a repeatable sequence if computed sequentially) or G05KGF (for a non-repeatable sequence) must be called prior to the first call to G05PWF.

4  References

None.

5  Parameters

1:     NT – INTEGERInput
On entry: nt, the number of observations in the training dataset.
Constraint: 1NTN.
2:     N – INTEGERInput
On entry: n, the number of observations.
Constraint: N1.
3:     M – INTEGERInput
On entry: m, the number of variables.
Constraint: M1.
4:     SORDX – INTEGERInput
On entry: determines how variables are stored in X.
Constraint: SORDX=1 or 2.
5:     XLDX* – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array X must be at least M if SORDX=1 and at least N if SORDX=2.
The way the data is stored in X is defined by SORDX.
If SORDX=1, Xij contains the ith observation for the jth variable, for i=1,2,,N and j=1,2,,M.
If SORDX=2, Xji contains the ith observation for the jth variable, for i=1,2,,N and j=1,2,,M.
On entry: X must hold Xo, the values of X for the original dataset. This may be the same X as returned by a previous call to G05PWF.
On exit: values of X for the training and validation datasets, with Xt held in observations 1 to NT and Xv in observations NT+1 to N.
6:     LDX – INTEGERInput
On entry: the first dimension of the array X as declared in the (sub)program from which G05PWF is called.
Constraints:
  • if SORDX=2, LDXM;
  • otherwise LDXN.
7:     USEY – INTEGERInput
On entry: if USEY=1, the original dataset includes yo and yo will be processed alongside Xo.
Constraint: USEY=0 or 1.
8:     Y* – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array Y must be at least N if USEY=1.
If USEY=0, Y is not referenced on entry and will not be modified on exit.
On entry: Y must hold yo, the values of y for the original dataset. This may be the same Y as returned by a previous call to G05PWF.
On exit: values of y for the training and validation datasets, with yt held in elements 1 to NT and yv in elements NT+1 to N.
9:     USEW – INTEGERInput
On entry: if USEW=1, the original dataset includes wo and wo will be processed alongside Xo.
Constraint: USEW=0 or 1.
10:   W* – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array W must be at least N if USEW=1.
If USEW=0, W is not referenced on entry or and will not be modified on exit.
On entry: W must hold wo, the values of w for the original dataset. This may be the same W as returned by a previous call to G05PWF.
On exit: values of w for the training and validation datasets, with wt held in elements 1 to NT and wv in elements NT+1 to N.
11:   STATE* – INTEGER arrayCommunication Array
Note: the actual argument supplied must be the array STATE supplied to the initialization routines G05KFF or G05KGF.
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
12:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction 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 parameter, 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=11
On entry, NT=value and N=value.
Constraint: 1NTN.
IFAIL=21
On entry, N=value.
Constraint: N1.
IFAIL=31
On entry, M=value.
Constraint: M1.
IFAIL=41
On entry, SORDX=value.
Constraint: SORDX=1 or 2.
IFAIL=61
On entry, LDX=value and N=value.
Constraint: if SORDX=1, LDXN.
IFAIL=62
On entry, LDX=value and M=value.
Constraint: if SORDX=2, LDXM.
IFAIL=71
Constraint: USEY=0 or 1.
IFAIL=91
Constraint: USEW=0 or 1.
IFAIL=111
On entry, STATE vector has been corrupted or not initialized.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

Not applicable.

8  Parallelism and Performance

G05PWF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
G05PWF 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

G05PWF will be computationality more efficient if each observation in X is contiguous, that is SORDX=2.

10  Example

This example uses G05PWF to facilitate repeated random sub-sampling cross-validation.
A set of simulated data is randomly split into a training and validation datasets. G02GBF is used to fit a logistic regression model to each training dataset and then G02GPF is used to predict the response for the observations in the validation dataset. This process is repeated 10 times.
The counts of true and false positives and negatives along with the sensitivity and specificity is then reported.

10.1  Program Text

Program Text (g05pwfe.f90)

10.2  Program Data

Program Data (g05pwfe.d)

10.3  Program Results

Program Results (g05pwfe.r)


G05PWF (PDF version)
G05 Chapter Contents
G05 Chapter Introduction
NAG Library Manual

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