Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


  >  Docs Center  >  IDL Reference  >  Advanced Math and Stats  >  IMSL_POOLED_COV

IMSL_POOLED_COV

IMSL_POOLED_COV

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



Syntax


Result = IMSL_POOLED_COV(x, ngroups [, /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


ngroups

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

If present and nonzero, double precision is used.

GCOUNTS

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

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

MEANS

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

Named variable into which the number of rows of data containing missing values (NaN) for any of the variables used 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.

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.

Discussion


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'

Pooled Covariance Matrix
   0.708 -1.575
   -1.575 3.883

Errors


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 History


6.4
Introduced



© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us