NAG Library Routine Document
G01AHF
1 Purpose
G01AHF performs a Normal probability plot on a character printing device, with a chosen number of character positions in each direction.
2 Specification
SUBROUTINE G01AHF ( 
X, NOBS, NSTEPX, NSTEPY, ISTAND, IWORK, WORK, LWORK, XSORT, XBAR, XSTD, IFAIL) 
INTEGER 
NOBS, NSTEPX, NSTEPY, ISTAND, IWORK(NOBS), LWORK, IFAIL 
REAL (KIND=nag_wp) 
X(NOBS), WORK(LWORK), XSORT(NOBS), XBAR, XSTD 

3 Description
In a Normal probability plot, the data $\left(x\right)$ are plotted against Normal scores $\left(y\right)$. The degree of linearity in the resultant plot provides a visual indication of the Normality of distribution of a set of residuals from some fitting process, such as multiple regression.
The data values are sorted into descending order prior to plotting, and may also be standardized to zero mean and unit standard deviation, if requested.
The plot is produced on a character printing device, using a chosen number of character positions in each direction. The output is directed to the current advisory message unit number (see the
Users' Note for your implementation). This number may be changed by an appropriate call to
X04ABF before calling G01AHF.
Axes are drawn and annotated and data points are plotted on the nearest character position. An appropriate step size for each axis is computed from the list
 $\left(0.1,0.15,0.2,0.25,0.4,0.5,0.6,0.75,0.8\right)\times \text{}$ power of $10$.
Points are plotted using the digits $1$ to $9$ to indicate the equivalent number of observations at a particular character position, a letter A–Z for $10\u201335$ occurrences, or * if there are $36$ or more coincident occurrences. Zero axes are marked if included in the plotting area.
4 References
None.
5 Parameters
 1: $\mathrm{X}\left({\mathbf{NOBS}}\right)$ – REAL (KIND=nag_wp) arrayInput

On entry: the vector of data values.
Constraint:
all data values must not be equal.
 2: $\mathrm{NOBS}$ – INTEGERInput

On entry: the number of data values.
Constraint:
${\mathbf{NOBS}}\ge 2$.
 3: $\mathrm{NSTEPX}$ – INTEGERInput

On entry: the number of steps (character positions) to be plotted in the
$x$direction. If the supplied value of
NSTEPX is less than
$10$, the value
$10$ will be used by G01AHF. The maximum value for
NSTEPX is the number of character positions available on the chosen output device less
$15$, up to a maximum of
$133$. If
NSTEPX exceeds
$133$ on input, the value
$133$ will be used by the routine.
 4: $\mathrm{NSTEPY}$ – INTEGERInput

On entry: the number of steps (character positions) to be plotted in the
$y$direction. If the supplied value of
NSTEPY is less than
$10$, the value
$10$ will be used by G01AHF. There is no maximum value for
NSTEPY, but you should bear in mind that (
${\mathbf{NSTEPY}}+5$) records (lines) of output are generated by the routine.
 5: $\mathrm{ISTAND}$ – INTEGERInput

On entry: indicates whether the residuals are to be standardized prior to plotting.
If
${\mathbf{ISTAND}}>0$, the elements of
X are standardized to zero mean and unit standard deviation.
 6: $\mathrm{IWORK}\left({\mathbf{NOBS}}\right)$ – INTEGER arrayWorkspace

 7: $\mathrm{WORK}\left({\mathbf{LWORK}}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit: the first
NOBS elements of
WORK contain the Normal scores in ascending magnitude. The rest of the array is used as workspace.
 8: $\mathrm{LWORK}$ – INTEGERInput

On entry: the dimension of the array
WORK as declared in the (sub)program from which G01AHF is called.
Constraint:
${\mathbf{LWORK}}\ge \left(5\times {\mathbf{NOBS}}\right)/2$.
 9: $\mathrm{XSORT}\left({\mathbf{NOBS}}\right)$ – REAL (KIND=nag_wp) arrayOutput

On exit: the data values, sorted into descending order, and standardized if
ISTAND was positive on entry.
 10: $\mathrm{XBAR}$ – REAL (KIND=nag_wp)Output

On exit: the mean of the data values.
 11: $\mathrm{XSTD}$ – REAL (KIND=nag_wp)Output

On exit: the standard deviation of the data values.
 12: $\mathrm{IFAIL}$ – INTEGERInput/Output

On entry:
IFAIL must be set to
$0$,
$1\text{ or}1$. 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
$1\text{ or}1$ is recommended. If the output of error messages is undesirable, then the value
$1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
$0$.
When the value $\mathbf{1}\text{ 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).
6 Error Indicators and Warnings
If on entry
${\mathbf{IFAIL}}={\mathbf{0}}$ or
${{\mathbf{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}}=1$

On entry,  ${\mathbf{NOBS}}<2$. 
 ${\mathbf{IFAIL}}=2$

All the supplied data values are equal.
 ${\mathbf{IFAIL}}=3$

On entry,  ${\mathbf{LWORK}}<\left(5\times {\mathbf{NOBS}}\right)/2$, i.e., the array WORK is too small. 
 ${\mathbf{IFAIL}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
 ${\mathbf{IFAIL}}=399$
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
 ${\mathbf{IFAIL}}=999$
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
Accuracy is limited by the number of plotting positions available.
8 Parallelism and Performance
G01AHF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
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 implementationspecific information.
For details of timing see
G01AGF and
G01DAF.
No blank records are output before or after the plot.
You must make sure that it is permissible to write records containing
NSTEPX characters to the current advisory message unit.
10 Example
The data are residuals from a linear regression. The $25$ values are standardized and plotted against the Normal scores, and are seen to follow a straight line fairly closely, indicating that Normality assumptions are justified.
10.1 Program Text
Program Text (g01ahfe.f90)
10.2 Program Data
Program Data (g01ahfe.d)
10.3 Program Results
Program Results (g01ahfe.r)