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)

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)(x) are plotted against Normal scores (y)(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 11 to 99 to indicate the equivalent number of observations at a particular character position, a letter A–Z for 10351035 occurrences, or * if there are 3636 or more coincident occurrences. Zero axes are marked if included in the plotting area.

References

None.

Parameters

Compulsory Input Parameters

1:     x(nobs) – double array
nobs, the dimension of the array, must satisfy the constraint nobs2nobs2.
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 xx-direction. If the supplied value of nstepx is less than 1010, the value 1010 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 1515, up to a maximum of 133133. If nstepx exceeds 133133 on input, the value 133133 will be used by the function.
3:     nstepy – int64int32nag_int scalar
The number of steps (character positions) to be plotted in the yy-direction. If the supplied value of nstepy is less than 1010, the value 1010 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 + 5nstepy+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: nobs2nobs2.
2:     istand – int64int32nag_int scalar
Indicates whether the residuals are to be standardized prior to plotting.
If istand > 0istand>0, the elements of x are standardized to zero mean and unit standard deviation.
Default: 11 

Input Parameters Omitted from the MATLAB Interface

iwork lwork

Output Parameters

1:     ifail – int64int32nag_int scalar
ifail = 0ifail=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) / 2lwork(5×nobs)/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 = 1ifail=1
On entry,nobs < 2nobs<2.
  ifail = 2ifail=2
All the supplied data values are equal.
  ifail = 3ifail=3
On entry,lwork < (5 × nobs) / 2lwork<(5×nobs)/2, i.e., the array work is too small.

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

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



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–2013