Home   >   User Resources   >   Online Help   >   apaMatrix.Averages.Categories.Weighted
 

 

Function index Version 3.0.0

apaMatrix.Averages.Categories.Weighted(DataMatrix, CategoryLabels, Weights)

Excel=apaMatrix.Averages.Categories.Weighted(DataMatrix, CategoryLabels, Weights)

Result

Returns the weighted arithmetic category means of a data matrix. The columns are grouped by category label and the weighted mean within each category is computed using the weights. The input data can be jagged.

Syntax

DataMatrix: jagged data matrix, each column containing a time series

CategoryLabels: 1 x c vector of category labels

Weights: 1 x c vector of weights, one per column of DataMatrix; within each category and row, the weights are rescaled to the series with numeric values

Algorithm

Each column of DataMatrix is treated as one series and assigned to the category given in CategoryLabels.

For each category and each row, the weighted arithmetic mean across all columns of that category is computed using the weights:

xˉw=∑iwixi∑iwi.{\overset{ˉ}{x}}_{w} = \frac{\sum_{i}^{}w_{i}x_{i}}{\sum_{i}^{}w_{i}}.

Missing observations or uneven column lengths of the jagged input are excluded from the calculation: empty cells, text, logical values and error values are skipped, and the weights of each category are rescaled to the series available in that row. A category without numeric values in a row returns #N/A. CategoryLabels may be a row or a column vector with one label per column of DataMatrix.

The result is the category mean matrix, with one column per category.