NAG CL Interface
g10zac (data_​order)

Settings help

CL Name Style:


1 Purpose

g10zac orders and weights data which is entered unsequentially, weighted or unweighted.

2 Specification

#include <nag.h>
void  g10zac (Integer n, const double x[], const double y[], const double weights[], Integer *nord, double xord[], double yord[], double wwt[], double *rss, NagError *fail)
The function may be called by the names: g10zac, nag_smooth_data_order or nag_order_data.

3 Description

Given a set of observations ( x i , y i ) for i = 1 , 2 , , n , with corresponding weights w i , g10zac rearranges the observations so that the x i are in ascending order.
For any equal x i in the ordered set, say x j = x j+1 = = x j+k , a single observation x j is returned with a corresponding y and w , calculated as:
w = l=0 k w i+l  
and
y = l=0 k w i+l y i+l w .  
Observations with zero weight are ignored. If no weights are supplied by you, then unit weights are assumed; that is w i = 1 , for i = 1 , 2 , , n .
In addition, the within group sum of squares is computed for the tied observations using West's algorithm (see West (1979)).

4 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

5 Arguments

1: n Integer Input
On entry: the number of observations, n .
Constraint: n1 .
2: x[n] const double Input
On entry: the values x i , for i=1,2,,n.
3: y[n] const double Input
On entry: the values y i , for i=1,2,,n.
4: weights[n] const double Input
On entry: weights must contain the n weights, if they are required. Otherwise, weights must be set to NULL.
Constraints:
  • if weights are required, then weights[i-1] 0.0 , for i=1,2,,n;
  • at least one weights[i-1] > 0.0 , for some i .
5: nord Integer * Output
On exit: the number of distinct observations.
6: xord[n] double Output
On exit: the first nord elements contain the ordered and distinct x i .
7: yord[n] double Output
On exit: the first nord elements contain the values y corresponding to the values in xord.
8: wwt[n] double Output
On exit: the first nord elements contain the values w corresponding to the values of xord and yord.
9: rss double * Output
On exit: the within group sum of squares for tied observations.
10: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_ARRAY_CONS
The contents of array weights are not valid.
Constraint: at least one element of weights must be > 0 .
NE_INT_ARG_LT
On entry, n=value.
Constraint: n1.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_REAL_ARRAY_CONS
On entry, weights[value] = value.
Constraint: weights[i] 0 , for i=0,1,,n - 1.

7 Accuracy

For a discussion on the accuracy of the algorithm for computing mean and variance see West (1979).

8 Parallelism and Performance

g10zac is not threaded in any implementation.

9 Further Comments

g10zac may be used to compute the pure error sum of squares in simple linear regression along with g02dac, see Draper and Smith (1985).

10 Example

A set of unweighted observations are input and g10zac used to produce a set of strictly increasing weighted observations.

10.1 Program Text

Program Text (g10zace.c)

10.2 Program Data

Program Data (g10zace.d)

10.3 Program Results

Program Results (g10zace.r)