cov2pcov.Rd
Compute a matrix of partial (co)variances for a group of variables with respect to another.
Take \(\Sigma\) as the covariance matrix of dimension p. Now consider dividing \(\Sigma\) into two groups of variables. The partial covariance matrices are calculate by: $$ \Sigma_{11.2} = \Sigma_{11} - \Sigma_{12} \Sigma_{22}^{-1} \Sigma_{21} $$ $$ \Sigma_{22.1} = \Sigma_{22} - \Sigma_{21} \Sigma_{11}^{-1} \Sigma_{12} $$
cov2pcov(m, vars1, vars2 = seq(1, ncol(m))[-vars1])
m | a square numeric matrix. |
---|---|
vars1 | a numeric vector indicating the position (rows or columns in |
vars2 | a numeric vector indicating the position (rows or columns in |
A square numeric matrix.
Anderson Rodrigo da Silva <anderson.agro at hotmail.com>
#> GNP.deflator GNP Unemployed Armed.Forces Population #> GNP.deflator 116.45763 1063.6041 625.8666 349.0254 73.50300 #> GNP 1063.60412 9879.3537 5612.4370 3088.0428 685.24094 #> Unemployed 625.86663 5612.4370 8732.2343 -1153.7876 446.27415 #> Armed.Forces 349.02537 3088.0428 -1153.7876 4843.0410 176.40981 #> Population 73.50300 685.2409 446.2742 176.4098 48.38735 #> Year 50.92333 470.9779 297.3033 138.2433 32.91740 #> Employed 36.79666 343.3302 164.9103 111.7681 23.46197 #> Year Employed #> GNP.deflator 50.92333 36.79666 #> GNP 470.97790 343.33021 #> Unemployed 297.30333 164.91027 #> Armed.Forces 138.24333 111.76811 #> Population 32.91740 23.46197 #> Year 22.66667 16.24093 #> Employed 16.24093 12.33392cov2pcov(Cl, 1:2)#> GNP.deflator GNP #> GNP.deflator 1.421147 2.143536 #> GNP 2.143536 8.134020# End (Not run)