Weighted Aggregation


When ViewHAR aggregates a matrix, it merely adds together input values which belong to the same output groups. AggHAR is additionally able to perform weighted aggregation. In that case, the output value is a weighted average (instead of sum) of the corresponding input values. Elasticities and ratios need to be averaged in this way.

You must specify a list of headers to be aggregated together with a list of the corresponding weight matrices. The lists must be contained in a special string (1C) header "WAGG" on the supplementary input file used by AggHAR. Each string in WAGG consists of two 4-letter headers, separated by a space (or by "@@@@"). The first header is the matrix on the main input file which is to be averaged. If there is no such header the instruction is ignored. The second header must refer to a matrix on the supplementary file which contains weights for averaging. The two matrices must have the same dimensions. If the input matrix exists but the weight matrix does not, a fatal error will occur.

The weight matrices would often be created by a TABLO program, or might simply be copied from the input file. The weights do not have to be in share form. AggHAR automatically normalizes them.

The supplementary file supplied as part of the AggHAR example contains a WAGG header that you can study.

AggHAR ignores blank items in the WAGG list, or items beginning with '?'.

AggHAR is not able to conserve memory when performing weighted aggregation on a particular header.

Creating the WAGG header in a TABLO program

You could create the WAGG header manually or in a TABLO program, as shown in the example below. There is however a gotcha. The only way for a TABLO program to create and write strings is if the strings are set elements -- which must be 12 letters max and must NOT begin with a digit. Headers, on the other hand, may begin with a digit. If the header to be aggregated begins with a digit, you should prefix it with 'xx' in the WAGG header (to make a legal set element).

Set WAGGSET # Instructions to AGGHAR for weighted aggregation of parameters # (

SCET@@@@1TOT,

P018@@@@4PUR,

ITEX@@@@4PUR,

XPEL@@@@3PUR,

P028@@@@VLAD,

SLAB@@@@LAB1,

xx1ARM@@1PUR, ! leading "xx" is ignored by AGGHAR !

xx2ARM@@2PUR,

xx3ARM@@3PUR);

Write (Set) WAGGSET to file SUMMARY header "WAGG";



URL of this topic: www.copsmodels.com/webhelp/viewhar/hc_weightagg.htm

Link to full GEMPACK Manual

Link to GEMPACK homepage