hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_stat_plot_scatter_normal (g01ah)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

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:
At Mark 23: only the first nobs elements of work are returned; istand was made optional (default 1); lwork is no longer an input parameter; output parameters were reordered

Description

In a Normal probability plot, the data x are plotted against Normal scores y. 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
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 1035 occurrences, or * if there are 36 or more coincident occurrences. Zero axes are marked if included in the plotting area.

References

None.

Parameters

Compulsory Input Parameters

1:     xnobs – double array
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-direction. If the supplied value of nstepx is less than 10, the value 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, up to a maximum of 133. If nstepx exceeds 133 on input, the value 133 will be used by the function.
3:     nstepy int64int32nag_int scalar
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 nag_stat_plot_scatter_normal (g01ah). There is no maximum value for nstepy, but you should bear in mind that (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.
2:     istand int64int32nag_int scalar
Default: 1 
Indicates whether the residuals are to be standardized prior to plotting.
If istand>0, the elements of x are standardized to zero mean and unit standard deviation.

Output Parameters

1:     ifail int64int32nag_int scalar
ifail=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:     worknobs – double array
The dimension of the array work will be nobs
lwork=5×nobs/2.
the Normal scores in ascending magnitude.
5:     xsortnobs – 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
On entry,nobs<2.
   ifail=2
All the supplied data values are equal.
   ifail=3
On entry,lwork<5×nobs/2, i.e., the array work is too small.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Accuracy is limited by the number of plotting positions available.

Further Comments

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

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.
function g01ah_example


fprintf('g01ah example results\n\n');

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);

fprintf('Plot of normal scores (Y) against standardised residuals (X)\n\n');

[ifail, xbar, xstd, work, xsort] = g01ah( ...
					  x, nstepx, nstepy);



g01ah example results

Plot of normal scores (Y) against standardised residuals (X)

            +....+....+....+....+....+....+....+....+....+....+.
       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

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015