NAG FL Interfaceg22ybf (lm_​describe_​data)

Note: please be advised that this routine is classed as ‘experimental’ and its interface may be developed further in the future. Please see Section 4 in How to Use the NAG Library for further information.

1Purpose

g22ybf describes a data matrix.

2Specification

Fortran Interface
 Subroutine g22ybf ( nobs, nvar,
 Integer, Intent (In) :: nobs, nvar, levels(nvar), lvnames Integer, Intent (Inout) :: ifail Character (*), Intent (In) :: vnames(lvnames) Type (c_ptr), Intent (Inout) :: hddesc
#include <nag.h>
 void g22ybf_ (void **hddesc, const Integer *nobs, const Integer *nvar, const Integer levels[], const Integer *lvnames, const char vnames[], Integer *ifail, const Charlen length_vnames)
The routine may be called by the names g22ybf or nagf_blgm_lm_describe_data.

3Description

Let $D$ denote a data matrix with $n$ observations on ${m}_{d}$ independent variables, denoted ${V}_{1},{V}_{2},\dots ,{V}_{{m}_{d}}$. The $j$th independent variable, ${V}_{j}$ can be classified as either binary, categorical, ordinal or continuous, where:
Binary
${V}_{j}$ can take the value $1$ or $0$.
Categorical
${V}_{j}$ can take one of ${L}_{j}$ distinct values or levels. Each level represents a discrete category but does not necessarily imply an ordering. The value used to represent each level is therefore arbitrary and, by convention and for convenience, is taken to be the integers from $1$ to ${L}_{j}$.
Ordinal
As with a categorical variable ${V}_{j}$ can take one of ${L}_{j}$ distinct values or levels. However, unlike a categorical variable, the levels of an ordinal variable imply an ordering and hence the value used to represent each level is not arbitrary. For example, ${V}_{j}=4$ implies a value that is twice as large as ${V}_{j}=2$.
Continuous
${V}_{j}$ can take any real value.
g22ybf returns a G22 handle containing a description of a data matrix, $D$. The data matrix makes no distinction between binary, ordinal or continuous variables.
A name can also be assigned to each variable. If names are not supplied then the default vector of names, $\left\{\text{'}\text{V1}\text{'},\text{'}\text{V2}\text{'},\dots \right\}$ is used.

None.

5Arguments

1: $\mathbf{hddesc}$Type (c_ptr) Input/Output
On entry: must be set to c_null_ptr, alternatively an existing G22 handle may be supplied in which case this routine will destroy the supplied G22 handle as if g22zaf had been called.
On exit: holds a G22 handle to the internal data structure containing a description of the data matrix, $D$. You must not change the G22 handle other than through the routines in Chapter G22.
2: $\mathbf{nobs}$Integer Input
On entry: $n$, the number of observations in the data matrix, $D$.
Constraint: ${\mathbf{nobs}}\ge 0$.
3: $\mathbf{nvar}$Integer Input
On entry: ${m}_{d}$, the number of variables in the data matrix, $D$.
Constraint: ${\mathbf{nvar}}\ge 0$.
4: $\mathbf{levels}\left({\mathbf{nvar}}\right)$Integer array Input
On entry: ${\mathbf{levels}}\left(\mathit{j}\right)$ contains the number of levels associated with the $\mathit{j}$th variable of the data matrix, for $\mathit{j}=1,2,\dots ,{\mathbf{nvar}}$.
If the $j$th variable is binary, ordinal or continuous, ${\mathbf{levels}}\left(j\right)$ should be set to $1$; otherwise ${\mathbf{levels}}\left(j\right)$ should be set to the number of levels associated with the $j$th variable and the corresponding column of the data matrix is assumed to take the value $1$ to ${\mathbf{levels}}\left(j\right)$.
Constraint: ${\mathbf{levels}}\left(\mathit{i}\right)\ge 1$, for $\mathit{i}=1,2,\dots ,{\mathbf{nvar}}$.
5: $\mathbf{lvnames}$Integer Input
On entry: the number of variable names supplied in vnames.
Constraint: ${\mathbf{lvnames}}=0$ or ${\mathbf{nvar}}$.
6: $\mathbf{vnames}\left({\mathbf{lvnames}}\right)$Character(*) array Input
On entry: if ${\mathbf{lvnames}}\ne 0$, ${\mathbf{vnames}}\left(\mathit{j}\right)$ must contain the name of the $\mathit{j}$th variable, for $\mathit{j}=1,2,\dots ,{\mathbf{nvar}}$. If ${\mathbf{lvnames}}=0$, vnames is not referenced.
The names supplied in vnames should be at most $50$ characters long and be unique. If a name longer than $50$ characters is supplied it will be truncated.
Variable names must not contain any of the characters +.*-:^()@.
7: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-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 $-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 $-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 $-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, hddesc is not c_null_ptr or a recognised G22 handle.
${\mathbf{ifail}}=21$
On entry, ${\mathbf{nobs}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nobs}}\ge 0$.
${\mathbf{ifail}}=31$
On entry, ${\mathbf{nvar}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nvar}}\ge 0$.
${\mathbf{ifail}}=41$
On entry, $j=〈\mathit{\text{value}}〉$ and ${\mathbf{levels}}\left(j\right)=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{levels}}\left(\mathit{i}\right)\ge 1$.
${\mathbf{ifail}}=51$
On entry, ${\mathbf{lvnames}}=〈\mathit{\text{value}}〉$ and ${\mathbf{nvar}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{lvnames}}=0$ or ${\mathbf{nvar}}$.
${\mathbf{ifail}}=61$
On entry, variable name $i$ contains one more invalid characters, $i=〈\mathit{\text{value}}〉$.
${\mathbf{ifail}}=62$
On entry, variable names $i$ and $j$ are not unique, $i=〈\mathit{\text{value}}〉$ and $j=〈\mathit{\text{value}}〉$.
${\mathbf{ifail}}=63$
On entry, variable names $i$ and $j$ are not unique (possibly due to truncation), $i=〈\mathit{\text{value}}〉$ and $j=〈\mathit{\text{value}}〉$.
Maximum variable name length is $50$.
${\mathbf{ifail}}=64$
At least one variable name was truncated to $50$ characters. Each truncated name is unique and will be used in all output.
${\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.

Not applicable.

8Parallelism and Performance

g22ybf is not threaded in any implementation.

9.1Internal Changes

Internal changes have been made to this routine as follows:
• At Mark 27: Functionality has been expanded allowing the routine to be used with g02jhf. An additional argument has been added to the interface and some of the error exits have been renumbered.
For details of all known issues which have been reported for the NAG Library please refer to the Known Issues.

10Example

This example performs a linear regression using g02daf. The linear regression model is defined via a text string which is parsed using g22yaf. The corresponding design matrix associated with the model and the dataset described via a call to g22ybf is generated using g22ycf.
Verbose labels for the parameters of the model are constructed using information returned in vinfo by g22ydf.
See also the examples in g22yaf, g22ycf and g22ydf.

10.1Program Text

Program Text (g22ybfe.f90)

10.2Program Data

Program Data (g22ybfe.d)

10.3Program Results

Program Results (g22ybfe.r)

11Optional Parameters

As well as the optional parameters common to all G22 handles described in g22zmf and g22znf, a number of additional optional parameters can be specified for a G22 handle holding the description of a data matrix as returned by g22ybf in hddesc.
Each writeable optional parameter has an associated default value; to set any of them to a non-default value, use g22zmf. The value of an optional parameter can be queried using g22znf.
The remainder of this section can be skipped if you wish to use the default values for all optional parameters.
The following is a list of the optional parameters available. A full description of each optional parameter is provided in Section 11.1.

11.1Description of the Optional Parameters

For each option, we give a summary line, a description of the optional parameter and details of constraints.
The summary line contains:
• a parameter value, where the letters $a$, $i$ and $r$ denote options that take character, integer and real values respectively;
• the default value.
Keywords and character values are case and white space insensitive.
 Number of Observations $i$ Read Only
If queried, this optional parameter will return $n$, the number of observations in the data matrix.
 Number of Variables $i$ Read Only
If queried, this optional parameter will return ${m}_{d}$, the number of variables in the data matrix.
 Storage Order $a$ Default $\text{}=\mathrm{OBSVAR}$
This optional parameter states how the data matrix, $D$, will be stored in its input array.
If ${\mathbf{Storage Order}}=\mathrm{OBSVAR}$, ${D}_{ij}$, the value for the $j$th variable of the $i$th observation of the data matrix is stored in ${\mathbf{dat}}\left(i,j\right)$.
If ${\mathbf{Storage Order}}=\mathrm{VAROBS}$, ${D}_{ij}$, the value for the $j$th variable of the $i$th observation of the data matrix is stored in ${\mathbf{dat}}\left(j,i\right)$.
Where dat is the input parameter of the same name in g22ycf.
Constraint: ${\mathbf{Storage Order}}=\mathrm{OBSVAR}$ or $\mathrm{VAROBS}$.