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_box_whisker (g01as)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_stat_plot_box_whisker (g01as) produces a specified number of box and whisker plots on a character printing device, with a chosen number of character positions in each direction.

Syntax

[ifail, plot, work] = g01as(n, x, nstepx, nstepy, 'prt', prt, 'm', m)
[ifail, plot, work] = nag_stat_plot_box_whisker(n, x, nstepx, nstepy, 'prt', prt, 'm', m)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: prt was made optional (default 'P'); output parameters were reordered

Description

nag_stat_plot_box_whisker (g01as) produces a series of box and whisker plots representing m data batches each of size ni, for i=1,2,,m. A box and whisker plot is a diagrammatic representation of the five-point summary of a data batch. The plot consists of a box spanning the hinges with the median indicated by a third line and two whiskers to represent the extreme values. The five-point summary is calculated internally and is returned in the workspace array.
The plot is returned in the character array plot. The size of the plot may be controlled using the arguments nstepx and nstepy. Optionally the plot can be output to an external file, in which case output is directed to the current advisory message unit as defined by nag_file_set_unit_advisory (x04ab).
An axis corresponding to the y axis is drawn and annotated and data points are plotted to the nearest character position.

References

Erickson B H and Nosanchuk T A (1985) Understanding Data Open University Press, Milton Keynes
Tukey J W (1977) Exploratory Data Analysis Addison–Wesley

Parameters

Compulsory Input Parameters

1:     nm int64int32nag_int array
ni contains the number of observations in the ith batch, ni, for i=1,2,,m.
If ni<5 the ith batch is omitted from the plot.
Constraint: at least one ni must be greater than or equal to 5, for i=1,2,,m.
2:     xldxm – double array
ldx, the first dimension of the array, must satisfy the constraint ldxmaxni.
The ith column of x must contain the data for the ith batch, that is xji must contain the jth observation of the ith batch, for i=1,2,,m and j=1,2,,ni.
3:     nstepx int64int32nag_int scalar
The number of character positions to be plotted in the x-direction.
Constraint: nstepxmax19,15×m/4+9.
4:     nstepy int64int32nag_int scalar
The number of character positions to be plotted in the y-direction.
Constraint: nstepy9.

Optional Input Parameters

1:     prt – string (length ≥ 1)
Default: 'P'
Indicates whether the box and whisker plot is to be output to an external file.
prt='N'
The box and whisker plot is not output to an external file.
prt='P'
The box and whisker plot is output to the current advisory message unit as defined by nag_file_set_unit_advisory (x04ab).
Constraint: prt='P' or 'N'.
2:     m int64int32nag_int scalar
Default: the dimension of the array n and the second dimension of the array x. (An error is raised if these dimensions are not equal.)
m, the number of data batches that are to be represented.
Constraint: m>0.

Output Parameters

1:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).
2:     plotldplotnstepx – cell array of strings
Contains the box and whisker plots.
3:     work5×m – double array
workj, for j=i-1×5+1,,i-1×5+5, contains the five-point summary of the ith batch.

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry, ni<5 for some i, for i=1,2,,m. For each batch where this occurs, 5 crosses are plotted in a vertical line to indicate that insufficient data was provided to produce a five-point summary and box-plot for that particular batch.
   ifail=2
On entry, nstepx<max19,15×m/4+9. This indicates that the data region defined by nstepx is too small to produce the required plot.
   ifail=3
On entry,nstepy<9.
   ifail=4
On entry,ldplot<nstepy.
   ifail=5
On entry,prt'P' or 'N'.
   ifail=6
On entry, ldx<maxni, for i=1,2,,m.
   ifail=7
The number of observations in all batches is less than 5.
   ifail=8
On entry, the data values are all identical.
   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

If the range of observations in a particular batch is too small to allow each item of the five-point summary to be plotted separately, then a sequence of stars are plotted at the median point of the batch to indicate that the full box-plot could not be plotted.

Further Comments

The time taken by nag_stat_plot_box_whisker (g01as) increases with m and ni, for i=1,2,,m.

Example

The following program produces a box and whisker plot for each one of 5 data batches of sizes 5, 6, 8, 8 and 7 respectively and prints the 5 box and whisker plots on the current advisory message unit.
function g01as_example


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

n = int64([  5;    6;    8;   8;   7]);
x =         [ -9,   -5.6, -9,  12,  -5;
              -7.3, 12,   12,  10,   8;
              -4.9, -9,   -6,  10,   1.5;
              -2.4, -3.9, -3,   8,  -3.2;
              -0.6, -2.4,  0,   6,  -3.2;
               0,   -7.3,  3,   4,   6.2;
               0,    0,    6,   4,   6.2;
               0,    0,    9,  -9,   0];

nstepx = int64(55);
nstepy = int64(21);
[ifail, plot, work] = g01as( ...
			     n, x, nstepx, nstepy);


g01as example results

  0.1E+02+           ---      ---      ---
         :            :        :        :
         :            :        :      -----
  0.8E+01+            :        :      :   :
         :            :      -----    :   :     ---
         :            :      :   :    :---:      :
         :            :      :   :    :   :    -----
  0.4E+01+            :      :   :    :   :    :   :
         :            :      :   :    -----    :   :
         :            :      :   :      :      :   :
         :            :      :---:      :      :---:
         :            :      :   :      :      :   :
 -0.6E+00+  ---       :      :   :      :      :   :
         :   :        :      :   :      :      :   :
         : -----    -----    :   :      :      -----
         : :   :    :   :    :   :      :        :
 -0.5E+01+ :---:    :---:    -----      :       ---
         : :   :    :   :      :        :
         : -----    -----      :        :
         :   :        :        :        :
 -0.9E+01+  ---      ---      ---      ---

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