Nächste: , Vorige: , Nach oben: Package descriptive   [Inhalt][Index]

39.4 Functions and Variables for specific multivariate descriptive statistics

Function: cov (matrix)

The covariance matrix of the multivariate sample, defined as

              n
             ====
          1  \           _        _
      S = -   >    (X  - X) (X  - X)'
          n  /       j        j
             ====
             j = 1

where \(X_j\) is the \(j\)-th row of the sample matrix.

Example:

(%i1) load ("descriptive")$
(%i2) s2 : read_matrix (file_search ("wind.data"))$
(%i3) fpprintprec : 7$  /* change precision for pretty output */
(%i4) cov (s2);
      [ 17.22191  13.61811  14.37217  19.39624  15.42162 ]
      [                                                  ]
      [ 13.61811  14.98774  13.30448  15.15834  14.9711  ]
      [                                                  ]
(%o4) [ 14.37217  13.30448  15.47573  17.32544  16.18171 ]
      [                                                  ]
      [ 19.39624  15.15834  17.32544  32.17651  20.44685 ]
      [                                                  ]
      [ 15.42162  14.9711   16.18171  20.44685  24.42308 ]

See also function cov1.

Function: cov1 (matrix)

The covariance matrix of the multivariate sample, defined as

              n
             ====
         1   \           _        _
   S  = ---   >    (X  - X) (X  - X)'
    1   n-1  /       j        j
             ====
             j = 1

where \(X_j\) is the \(j\)-th row of the sample matrix.

Example:

(%i1) load ("descriptive")$
(%i2) s2 : read_matrix (file_search ("wind.data"))$
(%i3) fpprintprec : 7$ /* change precision for pretty output */
(%i4) cov1 (s2);
      [ 17.39587  13.75567  14.51734  19.59216  15.5774  ]
      [                                                  ]
      [ 13.75567  15.13913  13.43887  15.31145  15.12232 ]
      [                                                  ]
(%o4) [ 14.51734  13.43887  15.63205  17.50044  16.34516 ]
      [                                                  ]
      [ 19.59216  15.31145  17.50044  32.50153  20.65338 ]
      [                                                  ]
      [ 15.5774   15.12232  16.34516  20.65338  24.66977 ]

See also function cov.

Function: global_variances (matrix)
Function: global_variances (matrix, logical_value)

Function global_variances returns a list of global variance measures:

  • total variance: trace(S_1),
  • mean variance: trace(S_1)/p,
  • generalized variance: determinant(S_1),
  • generalized standard deviation: sqrt(determinant(S_1)),
  • efective variance determinant(S_1)^(1/p), (defined in: Peña, D. (2002) Análisis de datos multivariantes; McGraw-Hill, Madrid.)
  • efective standard deviation: determinant(S_1)^(1/(2*p)).

where p is the dimension of the multivariate random variable and \(S_1\) the covariance matrix returned by cov1.

Example:

(%i1) load ("descriptive")$
(%i2) s2 : read_matrix (file_search ("wind.data"))$
(%i3) global_variances (s2);
(%o3) [105.338342060606, 21.06766841212119, 12874.34690469686, 
         113.4651792608501, 6.636590811800795, 2.576158149609762]

Function global_variances has an optional logical argument: global_variances (x, true) tells Maxima that x is the data matrix, making the same as global_variances(x). On the other hand, global_variances(x, false) means that x is not the data matrix, but the covariance matrix, avoiding its recalculation,

(%i1) load ("descriptive")$
(%i2) s2 : read_matrix (file_search ("wind.data"))$
(%i3) s : cov1 (s2)$
(%i4) global_variances (s, false);
(%o4) [105.338342060606, 21.06766841212119, 12874.34690469686, 
         113.4651792608501, 6.636590811800795, 2.576158149609762]

See also cov and cov1.

Function: cor (matrix)
Function: cor (matrix, logical_value)

The correlation matrix of the multivariate sample.

Example:

(%i1) load ("descriptive")$
(%i2) fpprintprec : 7 $
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) cor (s2);
      [   1.0     .8476339  .8803515  .8239624  .7519506 ]
      [                                                  ]
      [ .8476339    1.0     .8735834  .6902622  0.782502 ]
      [                                                  ]
(%o4) [ .8803515  .8735834    1.0     .7764065  .8323358 ]
      [                                                  ]
      [ .8239624  .6902622  .7764065    1.0     .7293848 ]
      [                                                  ]
      [ .7519506  0.782502  .8323358  .7293848    1.0    ]

Function cor has an optional logical argument: cor(x,true) tells Maxima that x is the data matrix, making the same as cor(x). On the other hand, cor(x,false) means that x is not the data matrix, but the covariance matrix, avoiding its recalculation,

(%i1) load ("descriptive")$
(%i2) fpprintprec : 7 $
(%i3) s2 : read_matrix (file_search ("wind.data"))$
(%i4) s : cov1 (s2)$
(%i5) cor (s, false); /* this is faster */
      [   1.0     .8476339  .8803515  .8239624  .7519506 ]
      [                                                  ]
      [ .8476339    1.0     .8735834  .6902622  0.782502 ]
      [                                                  ]
(%o5) [ .8803515  .8735834    1.0     .7764065  .8323358 ]
      [                                                  ]
      [ .8239624  .6902622  .7764065    1.0     .7293848 ]
      [                                                  ]
      [ .7519506  0.782502  .8323358  .7293848    1.0    ]

See also cov and cov1.

Function: list_correlations (matrix)
Function: list_correlations (matrix, logical_value)

Function list_correlations returns a list of correlation measures:

  • precision matrix: the inverse of the covariance matrix \(S_1\),
           -1     ij
          S   = (s  )             
           1         i,j = 1,2,...,p
    
  • multiple correlation vector: \((R_1^2, R_2^2, ..., R_p^2)\), with
           2          1
          R  = 1 - -------
           i        ii
                   s   s
                        ii
    

    being an indicator of the goodness of fit of the linear multivariate regression model on \(X_i\) when the rest of variables are used as regressors.

  • partial correlation matrix: with element \((i, j)\) being
                             ij
                            s
          r        = - ------------
           ij.rest     / ii  jj\ 1/2
                       |s   s  |
                       \       /
    

Example:

(%i1) load ("descriptive")$
(%i2) s2 : read_matrix (file_search ("wind.data"))$
(%i3) z : list_correlations (s2)$
(%i4) fpprintprec : 5$ /* for pretty output */
(%i5) z[1];  /* precision matrix */
      [  .38486   - .13856   - .15626   - .10239    .031179  ]
      [                                                      ]
      [ - .13856   .34107    - .15233    .038447   - .052842 ]
      [                                                      ]
(%o5) [ - .15626  - .15233    .47296    - .024816  - .10054  ]
      [                                                      ]
      [ - .10239   .038447   - .024816   .10937    - .034033 ]
      [                                                      ]
      [ .031179   - .052842  - .10054   - .034033   .14834   ]
(%i6) z[2];  /* multiple correlation vector */
(%o6)      [.85063, .80634, .86474, .71867, .72675]
(%i7) z[3];  /* partial correlation matrix */
      [  - 1.0     .38244   .36627   .49908   - .13049 ]
      [                                                ]
      [  .38244    - 1.0    .37927  - .19907   .23492  ]
      [                                                ]
(%o7) [  .36627    .37927   - 1.0    .10911    .37956  ]
      [                                                ]
      [  .49908   - .19907  .10911   - 1.0     .26719  ]
      [                                                ]
      [ - .13049   .23492   .37956   .26719    - 1.0   ]

Function list_correlations also has an optional logical argument: list_correlations(x,true) tells Maxima that x is the data matrix, making the same as list_correlations(x). On the other hand, list_correlations(x,false) means that x is not the data matrix, but the covariance matrix, avoiding its recalculation.

See also cov and cov1.


Nächste: , Vorige: , Nach oben: Package descriptive   [Inhalt][Index]

JavaScript license information