NAG Library Routine Document
G05PWF
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 denote a matrix of observations on variables and and each denote a vector of length . For example, might represent a matrix of independent variables, the dependent variable and the associated weights in a weighted regression.
G05PWF generates a series of training datasets, denoted by the matrix, vector, vector triplet of observations, and validation datasets, denoted with 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: – INTEGERInput
-
On entry: , the number of observations in the training dataset.
Constraint:
.
- 2: – INTEGERInput
-
On entry: , the number of observations.
Constraint:
.
- 3: – INTEGERInput
-
On entry: , the number of variables.
Constraint:
.
- 4: – INTEGERInput
-
On entry: determines how variables are stored in
X.
Constraint:
or .
- 5: – REAL (KIND=nag_wp) arrayInput/Output
-
Note: the second dimension of the array
X
must be at least
if
and at least
if
.
The way the data is stored in
X is defined by
SORDX.
If , contains the th observation for the th variable, for and .
If , contains the th observation for the th variable, for and .
On entry:
X must hold
, the values of
for the original dataset. This may be the same
X as returned by a previous call to G05PWF.
On exit: values of for the training and validation datasets, with held in observations to and in observations to .
- 6: – INTEGERInput
-
On entry: the first dimension of the array
X as declared in the (sub)program from which G05PWF is called.
Constraints:
- if , ;
- otherwise .
- 7: – INTEGERInput
-
On entry: if , the original dataset includes and will be processed alongside .
Constraint:
or .
- 8: – REAL (KIND=nag_wp) arrayInput/Output
-
Note: the dimension of the array
Y
must be at least
if
.
If
,
Y is not referenced on entry and will not be modified on exit.
On entry:
Y must hold
, the values of
for the original dataset. This may be the same
Y as returned by a previous call to G05PWF.
On exit: values of for the training and validation datasets, with held in elements to and in elements to .
- 9: – INTEGERInput
-
On entry: if , the original dataset includes and will be processed alongside .
Constraint:
or .
- 10: – REAL (KIND=nag_wp) arrayInput/Output
-
Note: the dimension of the array
W
must be at least
if
.
If
,
W is not referenced on entry or and will not be modified on exit.
On entry:
W must hold
, the values of
for the original dataset. This may be the same
W as returned by a previous call to G05PWF.
On exit: values of for the training and validation datasets, with held in elements to and in elements to .
- 11: – 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: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
-
On entry, and .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, .
Constraint: or .
-
On entry, and .
Constraint: if , .
-
On entry, and .
Constraint: if , .
-
Constraint: or .
-
Constraint: or .
-
On entry,
STATE vector has been corrupted or not initialized.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
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.
G05PWF will be computationality more efficient if each observation in
X is contiguous, that is
.
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
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)