Inverts the covariance matrix (or takes the precision matrix as given) and standardizes its negative off-diagonal elements. Applied to the innovation covariance of the VAR(1), the result is the contemporaneous network: the partial correlations of the states at the same prompt given the previous prompt and the other states.
Arguments
- S
A covariance (or precision, with
precision = TRUE) matrix.- precision
Logical; is
Salready a precision matrix?
Value
The matrix of partial correlations (the contemporaneous network
when S is an innovation covariance) with unit diagonal.
Examples
round(partial_cors(default_params()$Psi), 2)
#> NegA PosA Stress Fatigue
#> NegA 1.0 -0.3 0.3 0.0
#> PosA -0.3 1.0 0.0 0.0
#> Stress 0.3 0.0 1.0 0.2
#> Fatigue 0.0 0.0 0.2 1.0
# from a precision matrix directly
K <- solve(default_params()$Psi)
all.equal(partial_cors(K, precision = TRUE), partial_cors(default_params()$Psi))
#> [1] TRUE