PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_smooth_data_order (g10za)
Purpose
nag_smooth_data_order (g10za) orders and weights data which is entered unsequentially, weighted or unweighted.
Syntax
[
nord,
xord,
yord,
wtord,
rss,
ifail] = g10za(
x,
y, 'n',
n, 'wt',
wt)
[
nord,
xord,
yord,
wtord,
rss,
ifail] = nag_smooth_data_order(
x,
y, 'n',
n, 'wt',
wt)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 24: |
weight was removed from the interface; wt was made optional |
Description
Given a set of observations , for , with corresponding weights , nag_smooth_data_order (g10za) rearranges the observations so that the are in ascending order.
For any equal
in the ordered set, say
, a single observation
is returned with a corresponding
and
, calculated as
and
Observations with zero weight are ignored. If no weights are supplied by you, then unit weights are assumed; that is
, for
.
In addition, the within group sum of squares is computed for the tied observations using West's algorithm (see
West (1979)).
References
Draper N R and Smith H (1985) Applied Regression Analysis (2nd Edition) Wiley
West D H D (1979) Updating mean and variance estimates: An improved method Comm. ACM 22 532–555
Parameters
Compulsory Input Parameters
- 1:
– double array
-
The values,
, for .
- 2:
– double array
-
The values
, for .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the arrays
x,
y. (An error is raised if these dimensions are not equal.)
, the number of observations.
Constraint:
.
- 2:
– double array
-
The dimension of the array
wt
must be at least
if
If
,
wt must contain the
weights. Otherwise
wt is not referenced and unit weights are assumed.
Constraints:
- if , , for ;
- if , .
Output Parameters
- 1:
– int64int32nag_int scalar
-
The number of distinct observations.
- 2:
– double array
-
The first
nord elements contain the ordered and distinct
.
- 3:
– double array
-
The first
nord elements contain the values
corresponding to the values in
xord.
- 4:
– double array
-
The first
nord elements contain the values
corresponding to the values of
xord and
yord.
-
The within group sum of squares for tied observations.
- 6:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | or , |
or | . |
-
-
On entry, | and at least one element of wt is , or all elements of wt are . |
-
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
For a discussion on the accuracy of the algorithm for computing mean and variance see
West (1979).
Further Comments
nag_smooth_data_order (g10za) may be used to compute the pure error sum of squares in simple linear regression along with
nag_correg_linregm_fit (g02da); see
Draper and Smith (1985).
Example
A set of unweighted observations are input and nag_smooth_data_order (g10za) used to produce a set of strictly increasing weighted observations.
Open in the MATLAB editor:
g10za_example
function g10za_example
fprintf('g10za example results\n\n');
x = [1; 3; 5; 5; 3; 4; 9; 6; 9; 9];
y = [4; 4; 1; 2; 5; 3; 4; 9; 7; 4];
[nord, xord, yord, wtord, rss, ifail] = ...
g10za(x, y);
fprintf('Number of distinct observations = %7d\n', nord);
fprintf('Residual sum of squares = %13.5f\n\n', rss);
fprintf('%16s%18s%19s\n', 'x', 'y', 'wt');
results = [xord(1:nord) yord(1:nord) wtord(1:nord)];
fprintf('%17.1f%18.1f%18.1f\n', results');
g10za example results
Number of distinct observations = 6
Residual sum of squares = 7.00000
x y wt
1.0 4.0 1.0
3.0 4.5 2.0
4.0 3.0 1.0
5.0 1.5 2.0
6.0 9.0 1.0
9.0 5.0 3.0
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015