The IMSL_POOLED_COV function computes a pooled variance-covariance from the observations.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

The IMSL_POOLED_COV function 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. The IMSL_POOLED_COV function should be used whenever you suspect 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)) ( 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 j-th observation in the i-th 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	=	IMSL_POOLED_COV(x, ngroups)
PM, cov, FORMAT = '(2F10.3)', Title = 'Pooled Covariance Matrix'

Result:

Pooled Covariance Matrix
 0.708   -1.575
-1.575    3.883

Errors


Warning Errors

STAT_OBSERVATION_IGNORED: In 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.

Syntax


Result = IMSL_POOLED_COV(X, N_Groups [, DOUBLE] [, GCOUNTS=variable] [, IDX_COLS=array] [, IDX_VARS=array] [, MEANS=variable] [, NMISSING=variable] [, SUM_WEIGHTS=variable] [, U=variable])

Return Value


Two-dimensional array containing the matrix of covariances.

Arguments


N_Groups

Number of groups in the data.

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.

Keywords


DOUBLE (optional)

If present and nonzero, double precision is used.

GCOUNTS (optional)

Named variable into which the array of length N_Groups containing the number of observations in each group is stored.

IDX_COLS (optional)

One-dimensional array containing the indices of the variables to be used in the analysis.

IDX_VARS (optional)

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

MEANS (optional)

Named variable into which the array of size N_Groups by n_variables in which the i- th row of Means contains the group i variable means is stored.

NMISSING (optional)

Named variable into which the number of rows of data containing missing values (NaN) for any of the variables used is stored.

SUM_WEIGHTS (optional)

Named variable into which the array of length N_Groups containing the sum of the weights times the frequencies in the groups is stored.

U (optional)

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 description at the beginning of this topic ), as S = UTU.

Version History


6.4

Introduced