PDF version (NAG web site
, 64-bit version, 64-bit version)
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:
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 are plotted against Normal scores . 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
- power of .
Points are plotted using the digits to to indicate the equivalent number of observations at a particular character position, a letter A–Z for occurrences, or * if there are or more coincident occurrences. Zero axes are marked if included in the plotting area.
References
None.
Parameters
Compulsory Input Parameters
- 1:
– double array
-
The vector of data values.
Constraint:
all data values must not be equal.
- 2:
– int64int32nag_int scalar
-
The number of steps (character positions) to be plotted in the
-direction. If the supplied value of
nstepx is less than
, the value
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
, up to a maximum of
. If
nstepx exceeds
on input, the value
will be used by the function.
- 3:
– int64int32nag_int scalar
-
The number of steps (character positions) to be plotted in the
-direction. If the supplied value of
nstepy is less than
, the value
will be used by
nag_stat_plot_scatter_normal (g01ah). There is no maximum value for
nstepy, but you should bear in mind that (
) records (lines) of output are generated by the function.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
x.
The number of data values.
Constraint:
.
- 2:
– int64int32nag_int scalar
Default:
Indicates whether the residuals are to be standardized prior to plotting.
If
, the elements of
x are standardized to zero mean and unit standard deviation.
Output Parameters
- 1:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
- 2:
– double scalar
-
The mean of the data values.
- 3:
– double scalar
-
The standard deviation of the data values.
- 4:
– double array
-
The dimension of the array
work will be
.
the Normal scores in ascending magnitude.
- 5:
– 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:
-
-
-
-
All the supplied data values are equal.
-
-
On entry, | , i.e., the array work is too small. |
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Accuracy is limited by the number of plotting positions available.
Further Comments
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 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.
Open in the MATLAB editor:
g01ah_example
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)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015