Functions to navigate between \(R\) and \(\Theta\) for given clusters
theta-r.Rd
The block matrix models is defined from two elements : the cluster's partition \(\{C_1, \dots, C_K\}\), included in \(V\) and the \(R\) matrix which belongs to \(\mathcal S_K(\mathbb R)\), the set of symmetric \(K \times K\) matrix. The expression of the precision \(\Theta\) which statisfies the block matrix model is $$ \Theta = U R U^t + A $$ where \(U\) is the cluster matrix and \(A\) a diagonal matrix such that the rows of theta sum to zero : \( a_{ii} = - \sum_l p_l r_{kl} \) for \(i\) in cluster \(C_k\).
Value
For extract_R_matrix()
, a matrix on size the number of clusters (i.e. \(K\))
corresponding to the reduced matrix \(R\) of the original matrix \(\Theta\).
For build_theta()
, a matrix on size the number of variables (i.e. \(d\))
corresponding to the precision matrix \(\Theta\) induced by \(R\).
Examples
##############################################################
# FROM THETA TO R
##############################################################
Theta <- matrix(
c(4.5, .5, .5, .5, -2, -2, -2,
.5, 4.5, .5, .5, -2, -2, -2,
.5, .5, 4.5, .5, -2, -2, -2,
.5, .5, .5, 4.5, -2, -2, -2,
-2, -2, -2, -2, 6, 1, 1,
-2, -2, -2, -2, 1, 6, 1,
-2, -2, -2, -2, 1, 1, 6),
nc = 7
)
clusters <- list(c(1,2,3,4), c(5,6,7))
extract_R_matrix(Theta, clusters)
#> [,1] [,2]
#> [1,] 0.5 -2
#> [2,] -2.0 1
##############################################################
# FROM R TO THETA
##############################################################
R <- matrix(c(1, -3, 0,
-3, 2, -2,
0, -2, 1), nc = 3)
clusters <- list(1:4, 5:8, 9:12)
build_theta(R, clusters)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
#> [1,] 9 1 1 1 -3 -3 -3 -3 0 0 0 0
#> [2,] 1 9 1 1 -3 -3 -3 -3 0 0 0 0
#> [3,] 1 1 9 1 -3 -3 -3 -3 0 0 0 0
#> [4,] 1 1 1 9 -3 -3 -3 -3 0 0 0 0
#> [5,] -3 -3 -3 -3 14 2 2 2 -2 -2 -2 -2
#> [6,] -3 -3 -3 -3 2 14 2 2 -2 -2 -2 -2
#> [7,] -3 -3 -3 -3 2 2 14 2 -2 -2 -2 -2
#> [8,] -3 -3 -3 -3 2 2 2 14 -2 -2 -2 -2
#> [9,] 0 0 0 0 -2 -2 -2 -2 5 1 1 1
#> [10,] 0 0 0 0 -2 -2 -2 -2 1 5 1 1
#> [11,] 0 0 0 0 -2 -2 -2 -2 1 1 5 1
#> [12,] 0 0 0 0 -2 -2 -2 -2 1 1 1 5