Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_stat_plot_scatter_normal (g01ah)

## Purpose

nag_stat_plot_scatter_normal (g01ah) performs a Normal probability plot on a character printing device, with a chosen number of character positions in each direction.

## Syntax

[ifail, xbar, xstd, work, xsort] = g01ah(x, nstepx, nstepy, 'nobs', nobs, 'istand', istand)
[ifail, xbar, xstd, work, xsort] = nag_stat_plot_scatter_normal(x, nstepx, nstepy, 'nobs', nobs, 'istand', istand)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: only the first nobs elements of work are returned, istand now optional (default 1), lwork no longer an input parameter, output parameters have been reordered
.

## Description

In a Normal probability plot, the data (x)$\left(x\right)$ are plotted against Normal scores (y)$\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. This number may be changed by an appropriate call to nag_file_set_unit_advisory (x04ab) before calling nag_stat_plot_scatter_normal (g01ah).
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
• (0.1,0.15,0.2,0.25,0.4,0.5,0.6,0.75,0.8) × $\left(0.1,0.15,0.2,0.25,0.4,0.5,0.6,0.75,0.8\right)×\text{}$ power of 10$10$.
Points are plotted using the digits 1$1$ to 9$9$ to indicate the equivalent number of observations at a particular character position, a letter A–Z for 1035$10–35$ occurrences, or * if there are 36$36$ or more coincident occurrences. Zero axes are marked if included in the plotting area.

None.

## Parameters

### Compulsory Input Parameters

1:     x(nobs) – double array
nobs, the dimension of the array, must satisfy the constraint nobs2${\mathbf{nobs}}\ge 2$.
The vector of data values.
Constraint: all data values must not be equal.
2:     nstepx – int64int32nag_int scalar
The number of steps (character positions) to be plotted in the x$x$-direction. If the supplied value of nstepx is less than 10$10$, the value 10$10$ will be used by nag_stat_plot_scatter_normal (g01ah). The maximum value for nstepx is the number of character positions available on the chosen output device less 15$15$, up to a maximum of 133$133$. If nstepx exceeds 133$133$ on input, the value 133$133$ will be used by the function.
3:     nstepy – int64int32nag_int scalar
The number of steps (character positions) to be plotted in the y$y$-direction. If the supplied value of nstepy is less than 10$10$, the value 10$10$ will be used by nag_stat_plot_scatter_normal (g01ah). There is no maximum value for nstepy, but you should bear in mind that (nstepy + 5${\mathbf{nstepy}}+5$) records (lines) of output are generated by the function.

### Optional Input Parameters

1:     nobs – int64int32nag_int scalar
Default: The dimension of the array x.
The number of data values.
Constraint: nobs2${\mathbf{nobs}}\ge 2$.
2:     istand – int64int32nag_int scalar
Indicates whether the residuals are to be standardized prior to plotting.
If istand > 0${\mathbf{istand}}>0$, the elements of x are standardized to zero mean and unit standard deviation.
Default: 1$1$

iwork lwork

### Output Parameters

1:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).
2:     xbar – double scalar
The mean of the data values.
3:     xstd – double scalar
The standard deviation of the data values.
4:     work(lwork) – double array
lwork(5 × nobs) / 2$\mathit{lwork}\ge \left(5×{\mathbf{nobs}}\right)/2$.
the Normal scores in ascending magnitude.
5:     xsort(nobs) – double array
The data values, sorted into descending order, and standardized if istand was positive on entry.

## Error Indicators and Warnings

Errors or warnings detected by the function:
ifail = 1${\mathbf{ifail}}=1$
 On entry, nobs < 2${\mathbf{nobs}}<2$.
ifail = 2${\mathbf{ifail}}=2$
All the supplied data values are equal.
ifail = 3${\mathbf{ifail}}=3$
 On entry, lwork < (5 × nobs) / 2$\mathit{lwork}<\left(5×{\mathbf{nobs}}\right)/2$, i.e., the array work is too small.

## Accuracy

Accuracy is limited by the number of plotting positions available.

For details of timing see nag_stat_plot_scatter_2var (g01ag) and nag_stat_normal_scores_exact (g01da).
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.

## Example

```function nag_stat_plot_scatter_normal_example
x = [0.35;
0.1;
0.95;
-0.53;
0.33;
0.3;
0.39;
0.26;
-0.45;
0.12;
-1.58;
0.9;
0.53;
-0.58;
0.54;
-0.09;
0.79;
-0.41;
0.54;
0.48;
-0.28;
-0.71;
-1.1;
-0.41;
-0.44];
nstepx = int64(50);
nstepy = int64(40);
[ifail, xbar, xstd, work, xsort] = nag_stat_plot_scatter_normal(x, nstepx, nstepy)
```
```
+....+....+....+....+....+....+....+....+....+....+.
2.000+                             +              1     +
.                             .                    .
.                             .                    .
.                             .                    .
.                             .                    .
1.500+                             +             1      +
.                             .                    .
.                             .           1        .
.                             .                    .
.                             .        1           .
1.000+                             +                    +
.                             .        1           .
.                             .       1            .
.                             .                    .
.                             .       1            .
0.500+                             +     1              +
.                             .     1              .
.                             .    1               .
.                             .    1               .
.                             .   1                .
0.000+....+....+....+....+....+....+.1..+....+....+....++
.                             . 1                  .
.                            1.                    .
.                         1   .                    .
.                       1     .                    .
-0.500+                       1     +                    +
.                      1      .                    .
.                             .                    .
.                      1      .                    .
.                     1       .                    .
-1.000+                             +                    +
.                    1        .                    .
.                             .                    .
.                  1          .                    .
.                             .                    .
-1.500+            1                +                    +
.                             .                    .
.                             .                    .
.                             .                    .
.                             .                    .
-2.000+    1                        +                    +
+....+....+....+....+....+....+....+....+....+....+.
-3.000    -2.000    -1.000     0.000     1.000     2.000
-2.500    -1.500    -0.500     0.500     1.500

ifail =

0

xbar =

1.7347e-17

xstd =

0.6339

work =

1.9653
1.5243
1.2628
1.0668
0.9050
0.7641
0.6369
0.5193
0.4086
0.3027
0.2001
0.0995
0
-0.0995
-0.2001
-0.3027
-0.4086
-0.5193
-0.6369
-0.7641
-0.9050
-1.0668
-1.2628
-1.5243
-1.9653

xsort =

1.4987
1.4198
1.2463
0.8519
0.8519
0.8361
0.7572
0.6153
0.5522
0.5206
0.4733
0.4102
0.1893
0.1578
-0.1420
-0.4417
-0.6468
-0.6468
-0.6941
-0.7099
-0.8361
-0.9150
-1.1201
-1.7354
-2.4926

```
```function g01ah_example
x = [0.35;
0.1;
0.95;
-0.53;
0.33;
0.3;
0.39;
0.26;
-0.45;
0.12;
-1.58;
0.9;
0.53;
-0.58;
0.54;
-0.09;
0.79;
-0.41;
0.54;
0.48;
-0.28;
-0.71;
-1.1;
-0.41;
-0.44];
nstepx = int64(50);
nstepy = int64(40);
[ifail, xbar, xstd, work, xsort] = g01ah(x, nstepx, nstepy)
```
```
+....+....+....+....+....+....+....+....+....+....+.
2.000+                             +              1     +
.                             .                    .
.                             .                    .
.                             .                    .
.                             .                    .
1.500+                             +             1      +
.                             .                    .
.                             .           1        .
.                             .                    .
.                             .        1           .
1.000+                             +                    +
.                             .        1           .
.                             .       1            .
.                             .                    .
.                             .       1            .
0.500+                             +     1              +
.                             .     1              .
.                             .    1               .
.                             .    1               .
.                             .   1                .
0.000+....+....+....+....+....+....+.1..+....+....+....++
.                             . 1                  .
.                            1.                    .
.                         1   .                    .
.                       1     .                    .
-0.500+                       1     +                    +
.                      1      .                    .
.                             .                    .
.                      1      .                    .
.                     1       .                    .
-1.000+                             +                    +
.                    1        .                    .
.                             .                    .
.                  1          .                    .
.                             .                    .
-1.500+            1                +                    +
.                             .                    .
.                             .                    .
.                             .                    .
.                             .                    .
-2.000+    1                        +                    +
+....+....+....+....+....+....+....+....+....+....+.
-3.000    -2.000    -1.000     0.000     1.000     2.000
-2.500    -1.500    -0.500     0.500     1.500

ifail =

0

xbar =

1.7347e-17

xstd =

0.6339

work =

1.9653
1.5243
1.2628
1.0668
0.9050
0.7641
0.6369
0.5193
0.4086
0.3027
0.2001
0.0995
0
-0.0995
-0.2001
-0.3027
-0.4086
-0.5193
-0.6369
-0.7641
-0.9050
-1.0668
-1.2628
-1.5243
-1.9653

xsort =

1.4987
1.4198
1.2463
0.8519
0.8519
0.8361
0.7572
0.6153
0.5522
0.5206
0.4733
0.4102
0.1893
0.1578
-0.1420
-0.4417
-0.6468
-0.6468
-0.6941
-0.7099
-0.8361
-0.9150
-1.1201
-1.7354
-2.4926

```