The R package “multiness” implements model fitting and simulation for Gaussian and logistic inner product MultiNeSS models for multiplex networks. The package uses a convex fitting algorithm with fully adaptive parameter tuning, including options for edge cross-validation. For more details see MacDonald et al., (2020).
You can install the development version of “multiness” from GitHub using
::install_github("peterwmacd/multiness") devtools
“multiness” includes an example multiplex network of agricultural trade which is studied in MacDonald et al., (2020). It is easy to import and to fit a Gaussian MultiNeSS model with adaptive tuning.
library(multiness)
# import data
data(agri_trade)
dim(agri_trade)
#> [1] 145 145 13
# log transformation for edge weights
<- log(1+agri_trade)
A
# model fit
<- multiness_fit(A,model="gaussian",self_loops=FALSE,
fit tuning="adaptive",tuning_opts=list(penalty_const=3),
optim_opts=list(max_rank=100,return_posns=TRUE))
# inspect fitted latent space dimensions
# common latent space
$d1
fit#> [1] 30
# individual latent spaces
$d2
fit#> [1] 2 4 4 3 4 8 5 5 16 11 4 12 6
# plot first two common latent dimensions
plot(fit$V_hat[,1:2],main="Common latent dimensions",
xlab="v1",ylab="v2",xlim=c(0,4.5))
# label a subset of the points
<- dimnames(A)[[1]]
countries <- c(4,5,8,10,11,14,17,19,20,24,25,28,33,34,35,37,39,41,54,61,75)
do_label text(fit$V_hat[do_label,1],fit$V_hat[do_label,2],
labels=countries[do_label],pos=4,cex=.8)