Computes the Jensen-Shannon Distance between two networks
Usage
jsd(network1, network2, method = c("kld", "spectral"), signed = TRUE)
Arguments
- network1
Matrix or data frame. Network to be compared
- network2
Matrix or data frame. Second network to be compared
- method
Character (length = 1). Method to compute Jensen-Shannon Distance. Defaults to
"spectral"
. Available options:"kld"
— Uses Kullback-Leibler Divergence"spectral"
— Uses eigenvalues of combinatorial Laplacian matrix to compute Von Neumann entropy
- signed
Boolean. (length = 1). Should networks be remain signed? Defaults to
TRUE
Author
Hudson Golino <hfg9s at virginia.edu> & Alexander P. Christensen <alexander.christensen at Vanderbilt.Edu>
Examples
# Obtain wmt2 data
wmt <- wmt2[,7:24]
# Set seed (for reproducibility)
set.seed(1234)
# Split data
split1 <- sample(
1:nrow(wmt), floor(nrow(wmt) / 2)
)
split2 <- setdiff(1:nrow(wmt), split1)
# Obtain split data
data1 <- wmt[split1,]
data2 <- wmt[split2,]
# Perform EBICglasso
glas1 <- EBICglasso.qgraph(data1)
glas2 <- EBICglasso.qgraph(data2)
# Spectral JSD
jsd(glas1, glas2)
#> [1] 0.1595893
# 0.1595893
# Spectral JSS (similarity)
1 - jsd(glas1, glas2)
#> [1] 0.8404107
# 0.8404107
# Jensen-Shannon Divergence
jsd(glas1, glas2, method = "kld")
#> [1] 0.1393621
# 0.1393621