The function may be called by the names: g05pwc or nag_rand_subsamp_xyw.
3Description
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.
g05pwc 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 functions g05kfc (for a repeatable sequence if computed sequentially) or g05kgc (for a non-repeatable sequence) must be called prior to the first call to g05pwc.
4References
None.
5Arguments
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: – Nag_DataByObsOrVarInput
On entry: determines how variables are stored in x.
Constraint:
or .
5: – doubleInput/Output
Note: the dimension, dim, of the array x
must be at least
when
;
when
.
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 updated by a previous call to g05pwc.
On exit: values of for the training and validation datasets, with held in observations to and in observations to .
6: – IntegerInput
On entry: the stride separating row elements in the two-dimensional data stored in the array x.
Constraints:
if , ;
otherwise .
7: – doubleInput/Output
Note: the dimension, dim, of the array y
must be at least
, when ;
otherwise is not referenced and may be NULL.
If the original dataset does not include then y must be set to NULL.
On entry: y must hold , the values of for the original dataset. This may be the same y as updated by a previous call to g05pwc.
On exit: values of for the training and validation datasets, with held in elements to and in elements to .
8: – doubleInput/Output
Note: the dimension, dim, of the array w
must be at least
, when ;
otherwise is not referenced and may be NULL.
If the original dataset does not include then w must be set to NULL.
On entry: w must hold , the values of for the original dataset. This may be the same w as updated by a previous call to g05pwc.
On exit: values of for the training and validation datasets, with held in elements to and in elements to .
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
10: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_ARRAY_SIZE
On entry, and . Constraint: if , .
On entry, and . Constraint: if , .
NE_BAD_PARAM
On entry, argument had an illegal value.
NE_INT
On entry, . Constraint: .
On entry, . Constraint: .
NE_INT_2
On entry, and . Constraint: .
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_INVALID_STATE
On entry, state vector has been corrupted or not initialized.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
7Accuracy
Not applicable.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g05pwc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g05pwc 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.
9Further Comments
g05pwc will be computationality more efficient if each observation in x is contiguous, that is .
10Example
This example uses g05pwc to facilitate repeated random sub-sampling cross-validation.
A set of simulated data is randomly split into a training and validation datasets. g02gbc is used to fit a logistic regression model to each training dataset and then g02gpc 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.