IMSL Statistics Reference Guide > Correlation and Covariance > POOLED_COV Function (PV-WAVE Advantage)
  

POOLED_COV Function (PV-WAVE Advantage)
Compute a pooled variance-covariance from the observations.
Usage
result = POOLED_COV(x, ngroups)
Input Parameters
x—Two-dimensional array containing the data. The first n_variables = (N_ELEMENTS(x(0,*)) – 1) columns correspond to the variables, and the last column must contain the group numbers.
ngroups—Number of groups in the data.
Returned Value
result—Two-dimensional array containing the matrix of covariances.
Input Keywords
Double—If present and nonzero, double precision is used.
Idx_Cols—One-dimensional array containing the indices of the variables to be used in the analysis.
Idx_Vars—Three element array indicating the column numbers of x in which particular types of data are stored. Columns are numbered 0 ... N_ELEMENTS(Idx_Cols) 1.
*Idx_Vars(0) contains the index for the column of x in which the group numbers are stored.
*Idx_Vars(1) and Idx_Vars(2) contain column numbers of x in which the frequencies and weights, respectively, are stored. Set Idx_Vars(1) = –1 if there will be no column for frequencies. Set Idx_Vars(2) = –1 if there will be no column for weights. Weights are rounded to the nearest integer. Negative weights are not allowed.
*Defaults: Idx_Cols = 0, 1, ..., n_variables – 1,
Idx_Vars(0) = n_variables,
Idx_Vars(1) = 1, and
Idx_Vars(2) = 1
Output Keywords
Gcounts—Named variable into which the array of length n_groups containing the number of observations in each group is stored.
Sum_Weights—Named variable into which the array of length n_groups containing the sum of the weights times the frequencies in the groups is stored.
Means—Named variable into which the array of size n_groups by n_variables in which the ith row of Means contains the group i variable means is stored.
U—Named variable into which the array of size n_variables by n_variables containing the lower matrix U, the lower triangular for the pooled sample cross-products matrix is stored. U is computed from the pooled sample covariance matrix, S (See the Discussion section), as S = UTU.
Nmissing—Named variable into which the number of rows of data containing missing values (NaN) for any of the variables used is stored.
Discussion
Function POOLED_COV computes the pooled variance-covariance matrix from a matrix of observations. The within-groups means are also computed. Listwise deletion of missing values is assumed so that all observations used are complete; in any row of x, if any element of the observation is missing, the row is not used. Function POOLED_COV should be used whenever the user suspects that the data has been sampled from populations with different means but identical variance-covariance matrices. If these assumptions cannot be made, a different variance-covariance matrix should be estimated within each group.
If N_ELEMENTS(x(*,0)), the group observation totals, Ti, for i = 1, ..., g, where g is the number of groups, are updated for the N_ELEMENTS(x(*,0)) observations in x. The group totals are computed as:
where wij is the observation weight, xij is the jth observation in the ith group, and fij is the observation frequency.
Modified Givens rotations are used in computed the Cholesky decomposition of the pooled sums of squares and crossproducts matrix. (Golub and Van Loan 1983).
The group means and the pooled sample covariance matrix S are computed from the intermediate results. These quantities are defined by:
Example
The following example computes a pooled variance-covariance matrix. The last column of the data set is the group indicator.
ngroups  =  2
x  =  TRANSPOSE([[2.2, 5.6, 1], [3.4, 2.3, 1], [1.2, 7.8, 1], $
   [3.2, 2.1, 2], [4.1, 1.6, 2], [3.7, 2.2, 2]])
   cov  =  POOLED_COV(x, ngroups)
PM, cov, Format = '(2F10.3)', Title = 'Pooled Covariance Matrix'
 
; This results in the following output:
 
; Pooled Covariance Matrix
;    0.708    -1.575
;   -1.575     3.883
Warning Errors
STAT_OBSERVATION_IGNOREDIn call #, row # of the matrix “x” has group number = #. The group number must be between 1 and #, the number of groups. This observation will be ignored.

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.