The routine may be called by the names g05pwf or nagf_rand_subsamp_xyw.
3Description
Let ${X}_{o}$ denote a matrix of $n$ observations on $m$ variables and ${y}_{o}$ and ${w}_{o}$ each denote a vector of length $n$. For example, ${X}_{o}$ might represent a matrix of independent variables, ${y}_{o}$ the dependent variable and ${w}_{o}$ the associated weights in a weighted regression.
g05pwf generates a series of training datasets, denoted by the matrix, vector, vector triplet $({X}_{t},{y}_{t},{w}_{t})$ of ${n}_{t}$ observations, and validation datasets, denoted $({X}_{v},{y}_{v},{w}_{v})$ with ${n}_{v}$ 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.
4References
None.
5Arguments
1: $\mathbf{nt}$ – IntegerInput
On entry: ${n}_{t}$, the number of observations in the training dataset.
Constraint:
$1\le {\mathbf{nt}}\le {\mathbf{n}}$.
2: $\mathbf{n}$ – IntegerInput
On entry: $n$, the number of observations.
Constraint:
${\mathbf{n}}\ge 1$.
3: $\mathbf{m}$ – IntegerInput
On entry: $m$, the number of variables.
Constraint:
${\mathbf{m}}\ge 1$.
4: $\mathbf{sordx}$ – IntegerInput
On entry: determines how variables are stored in x.
Constraint:
${\mathbf{sordx}}=1$ or $2$.
5: $\mathbf{x}({\mathbf{ldx}},*)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array x
must be at least
${\mathbf{m}}$ if ${\mathbf{sordx}}=1$ and at least ${\mathbf{n}}$ if ${\mathbf{sordx}}=2$.
The way the data is stored in x is defined by sordx.
If ${\mathbf{sordx}}=1$, ${\mathbf{x}}(\mathit{i},\mathit{j})$ contains the $\mathit{i}$th observation for the $\mathit{j}$th variable, for $i=1,2,\dots ,{\mathbf{n}}$ and $j=1,2,\dots ,{\mathbf{m}}$.
If ${\mathbf{sordx}}=2$, ${\mathbf{x}}(\mathit{j},\mathit{i})$ contains the $\mathit{i}$th observation for the $\mathit{j}$th variable, for $i=1,2,\dots ,{\mathbf{n}}$ and $j=1,2,\dots ,{\mathbf{m}}$.
On entry: x must hold ${X}_{o}$, the values of $X$ for the original dataset. This may be the same x as updated by a previous call to g05pwf.
On exit: values of $X$ for the training and validation datasets, with ${X}_{t}$ held in observations $1$ to ${\mathbf{nt}}$ and ${X}_{v}$ in observations ${\mathbf{nt}}+1$ to ${\mathbf{n}}$.
6: $\mathbf{ldx}$ – IntegerInput
On entry: the first dimension of the array x as declared in the (sub)program from which g05pwf is called.
Constraints:
if ${\mathbf{sordx}}=2$, ${\mathbf{ldx}}\ge {\mathbf{m}}$;
otherwise ${\mathbf{ldx}}\ge {\mathbf{n}}$.
7: $\mathbf{usey}$ – IntegerInput
On entry: if ${\mathbf{usey}}=1$, the original dataset includes ${y}_{o}$ and ${y}_{o}$ will be processed alongside ${X}_{o}$.
Constraint:
${\mathbf{usey}}=0$ or $1$.
8: $\mathbf{y}(*)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the dimension of the array y
must be at least
${\mathbf{n}}$ if ${\mathbf{usey}}=1$.
If ${\mathbf{usey}}=0$, y is not referenced on entry and will not be modified on exit.
On entry: y must hold ${y}_{o}$, the values of $y$ for the original dataset. This may be the same y as updated by a previous call to g05pwf.
On exit: values of $y$ for the training and validation datasets, with ${y}_{t}$ held in elements $1$ to ${\mathbf{nt}}$ and ${y}_{v}$ in elements ${\mathbf{nt}}+1$ to ${\mathbf{n}}$.
9: $\mathbf{usew}$ – IntegerInput
On entry: if ${\mathbf{usew}}=1$, the original dataset includes ${w}_{o}$ and ${w}_{o}$ will be processed alongside ${X}_{o}$.
Constraint:
${\mathbf{usew}}=0$ or $1$.
10: $\mathbf{w}(*)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the dimension of the array w
must be at least
${\mathbf{n}}$ if ${\mathbf{usew}}=1$.
If ${\mathbf{usew}}=0$, w is not referenced on entry or and will not be modified on exit.
On entry: w must hold ${w}_{o}$, the values of $w$ for the original dataset. This may be the same w as updated by a previous call to g05pwf.
On exit: values of $w$ for the training and validation datasets, with ${w}_{t}$ held in elements $1$ to ${\mathbf{nt}}$ and ${w}_{v}$ in elements ${\mathbf{nt}}+1$ to ${\mathbf{n}}$.
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: $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $\mathrm{-1}$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $\mathrm{-1}$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $\mathrm{-1}$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry ${\mathbf{ifail}}=0$ or $\mathrm{-1}$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=11$
On entry, ${\mathbf{nt}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{n}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: $1\le {\mathbf{nt}}\le {\mathbf{n}}$.
${\mathbf{ifail}}=21$
On entry, ${\mathbf{n}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{n}}\ge 1$.
${\mathbf{ifail}}=31$
On entry, ${\mathbf{m}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{m}}\ge 1$.
${\mathbf{ifail}}=41$
On entry, ${\mathbf{sordx}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{sordx}}=1$ or $2$.
${\mathbf{ifail}}=61$
On entry, ${\mathbf{ldx}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{n}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: if ${\mathbf{sordx}}=1$, ${\mathbf{ldx}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=62$
On entry, ${\mathbf{ldx}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{m}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: if ${\mathbf{sordx}}=2$, ${\mathbf{ldx}}\ge {\mathbf{m}}$.
${\mathbf{ifail}}=71$
Constraint: ${\mathbf{usey}}=0$ or $1$.
${\mathbf{ifail}}=91$
Constraint: ${\mathbf{usew}}=0$ or $1$.
${\mathbf{ifail}}=111$
On entry, state vector has been corrupted or not initialized.
${\mathbf{ifail}}=-99$
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.
${\mathbf{ifail}}=-399$
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.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
Not applicable.
8Parallelism 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.
9Further Comments
g05pwf will be computationality more efficient if each observation in x is contiguous, that is ${\mathbf{sordx}}=2$.
10Example
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.