NAG FL Interface
g05pwf (subsamp_xyw)
1
Purpose
g05pwf generates a dataset suitable for use with repeated random sub-sampling validation.
2
Specification
Fortran Interface
Subroutine g05pwf ( |
nt, n, m, sordx, x, ldx, usey, y, usew, w, state, ifail) |
Integer, Intent (In) |
:: |
nt, n, m, sordx, ldx, usey, usew |
Integer, Intent (Inout) |
:: |
state(*), ifail |
Real (Kind=nag_wp), Intent (Inout) |
:: |
x(ldx,*), y(*), w(*) |
|
C Header Interface
#include <nag.h>
void |
g05pwf_ (const Integer *nt, const Integer *n, const Integer *m, const Integer *sordx, double x[], const Integer *ldx, const Integer *usey, double y[], const Integer *usew, double w[], Integer state[], Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g05pwf_ (const Integer &nt, const Integer &n, const Integer &m, const Integer &sordx, double x[], const Integer &ldx, const Integer &usey, double y[], const Integer &usew, double w[], Integer state[], Integer &ifail) |
}
|
The routine may be called by the names g05pwf or nagf_rand_subsamp_xyw.
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
Arguments
-
1:
– Integer
Input
-
On entry: , the number of observations in the training dataset.
Constraint:
.
-
2:
– Integer
Input
-
On entry: , the number of observations.
Constraint:
.
-
3:
– Integer
Input
-
On entry: , the number of variables.
Constraint:
.
-
4:
– Integer
Input
-
On entry: determines how variables are stored in
x.
Constraint:
or .
-
5:
– Real (Kind=nag_wp) array
Input/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:
– Integer
Input
-
On entry: the first dimension of the array
x as declared in the (sub)program from which
g05pwf is called.
Constraints:
- if , ;
- otherwise .
-
7:
– Integer
Input
-
On entry: if , the original dataset includes and will be processed alongside .
Constraint:
or .
-
8:
– Real (Kind=nag_wp) array
Input/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:
– Integer
Input
-
On entry: if , the original dataset includes and will be processed alongside .
Constraint:
or .
-
10:
– Real (Kind=nag_wp) array
Input/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 array
Communication 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:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 4 in the Introduction to the NAG Library FL Interface 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 argument, 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 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface 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
10.2
Program Data
10.3
Program Results