Skip to content

Commit

Permalink
fix for negative variances in network.predictability
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexChristensen committed Mar 26, 2024
1 parent 3783f37 commit 2c0ed02
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ o FIX: update to revised network loadings signs

o FIX: bug in argument 'returnAllResults' for `EBICglasso.qgraph`

o UPDATE: `network.predictability` uses empirical inverse variances (rather than network-implied)


Changes in version 2.0.5

Expand Down
10 changes: 7 additions & 3 deletions R/network.predictability.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
#' @export
#'
# Predict new data based on network ----
# Updated 02.03.2024
# Updated 26.03.2024
network.predictability <- function(network, original.data, newdata, ordinal.categories = 7)
{

Expand Down Expand Up @@ -179,8 +179,12 @@ network.predictability <- function(network, original.data, newdata, ordinal.cate

}

# Get the inverse variances (use absolute for less than ideal matrices)
inverse_variances <- abs(diag(pcor2inv(network)))
# Get the inverse variances of original data
inverse_variances <- diag(solve(auto.correlate(original.data)))
# Although it's probably more appropriate to use the network-implied
# invariance (co)variances, there are some network estimation methods
# that result in non-positive definite or near singular matrices with
# negative inverse variances

# Get betas
betas <- network * sqrt(outer(inverse_variances, inverse_variances, FUN = "/"))
Expand Down

0 comments on commit 2c0ed02

Please sign in to comment.