Type: Package
Title: Exponential-Family Random Graph Models for Network Clustering
Version: 1.0.1
Date: 2026-3-10
Description: Implements clustering and estimates parameters in Exponential-Family Random Graph Models for static undirected and directed networks, developed in Vu et al. (2013) https://projecteuclid.org/euclid.aoas/1372338477.
Encoding: UTF-8
License: GPL-2
Imports: Rcpp (≥ 1.0.1), MASS, lda, quadprog, igraph, viridis, locfit
LinkingTo: Rcpp, RcppArmadillo
Depends: R (≥ 2.10)
URL: https://sites.psu.edu/sldm/netclust/
NeedsCompilation: yes
Packaged: 2026-03-10 18:20:04 UTC; azjmk
Author: Amal Agarwal [aut], Kevin H. Lee [aut], Lingzhou Xue [aut, ths, cre], Anna Yinqi Zhang [com]
Maintainer: Lingzhou Xue <lzxue@psu.edu>
RoxygenNote: 7.3.3
Repository: CRAN
Date/Publication: 2026-03-16 16:40:20 UTC

ERGM-based network clustering

Description

Clustering and estimation of parameters in ERGMs for static undirected and directed networks with inference based on VEM algorithm.

Details

The ergmclust package is an R implementation that serves as an estimation framework for static binary networks, in both undirected and directed cases. Its main functions include ergmclust for clustering and parameter estimation, ergmclust.ICL for model selection, and ergmclust.plot for visualizing the clustered network. The package is based on VEM algorithm (Vu et. al., 2013) and works well with both simulated and real-world data.

Author(s)

Authors: Amal Agarwal [aut], Kevin Lee [aut], Lingzhou Xue [aut, ths, cre], Anna Yinqi Zhang [cre]

Maintainer: Lingzhou Xue <lzxue@psu.edu>

References

Agarwal, A. and Xue, L. (2019) Model-Based Clustering of Nonparametric Weighted Networks With Application to Water Pollution Analysis, Technometrics, to appear doi:10.1080/00401706.2019.1623076

Biernacki, C., Celeux, G., and Govaert, G. (2000) Assessing a mixture model for clustering with the integrated completed likelihood, IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 22(7), 719-725

https://ieeexplore.ieee.org/document/865189

Blei, D. M. , Kucukelbir, A., and McAuliffe, J. D. (2017), Variational Inference: A Review for Statisticians, Journal of the American Statistical Association, Vol. 112(518), 859-877

https://www.tandfonline.com/doi/full/10.1080/01621459.2017.1285773

Daudin, J. J., Picard, F., and Robin, S. (2008) A Mixture Model for Random Graphs, Statistics and Computing, Vol. 18(2), 173–183

https://link.springer.com/article/10.1007/s11222-007-9046-7

Lee, K. H., Xue, L, and Hunter, D. R. (2017) Model-Based Clustering of Time-Evolving Networks through Temporal Exponential-Family Random Graph Models, Journal of Multivariate Analysis, to appear

https://arxiv.org/abs/1712.07325

Vu D. Q., Hunter, D. R., and Schweinberger, M. (2013) Model-based Clustering of Large Networks, The Annals of Applied Statistics, Vol. 7(2), 1010-1039

https://projecteuclid.org/euclid.aoas/1372338477


C++ function for updating the ELBO convergence function in a static binary directed network.

Description

The C++ function ELBO_conv_HMM_stat_dir() updates the ELBO convergence function when the number of clusters is greater than or equal to 2 in a static binary directed network.

Usage

ELBO_conv_HMM_stat_dir(gamma, alpha, theta, network, N, K)

Arguments

gamma

Vector of current gamma (variational parameters) values.

alpha

Vector of current alpha values.

theta

Vector of current theta (network canonical parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns the value of ELBO for calculating relative error from the previous iterate that is subsequently used in the stopping criteria of the algorithm.


C++ function for updating the ELBO convergence function in a static binary directed network.

Description

The C++ function ELBO_conv_HMM_stat_undir() updates the ELBO convergence function when the number of cluster is equal to 1 in a static binary directed network.

Usage

ELBO_conv_HMM_stat_dir_K1(theta, network, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

Value

Returns the value of ELBO for calculating relative error from the previous iterate that is subsequently used in the stopping criteria of the algorithm.


C++ function for updating the ELBO convergence function in a static binary undirected network.

Description

The C++ function ELBO_conv_HMM_stat_undir() updates the ELBO convergence function when the number of clusters is greater than or equal to 2 in a static binary undirected network.

Usage

ELBO_conv_HMM_stat_undir(gamma, pi, theta, network, N, K)

Arguments

gamma

Vector of current gamma (variational parameters) values.

pi

Vector of current pi (mixture proportions) values.

theta

Vector of current theta (network canonical parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns the value of ELBO for calculating relative error from the previous iterate that is subsequently used in the stopping criteria of the algorithm.


C++ function for updating the ELBO convergence function.

Description

The C++ function ELBO_conv_HMM_stat_undir() updates the ELBO convergence function when the number of cluster is equal to 1 in a static binary undirected network.

Usage

ELBO_conv_HMM_stat_undir_K1(theta, network, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

Value

Returns the value of ELBO for calculating relative error from the previous iterate that is subsequently used in the stopping criteria of the algorithm.


C++ function for updating the ELBO convergence function in a weighted static binary undirected network.

Description

The C++ function ELBO_conv_weighted_stat_undir() updates the ELBO convergence function when the number of clusters is greater than or equal to 2 in a weighted static binary undirected network.

Usage

ELBO_conv_weighted_stat_undir(gamma, pi, theta, block_dens_mat, adjmat, N, K)

Arguments

gamma

Vector of current gamma (variational parameters) values.

pi

Vector of current pi (mixture proportions) values.

theta

Vector of current theta (network canonical parameters) values.

block_dens_mat

Array of a network block density matrices.

adjmat

Array of a network adjacency matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns the value of ELBO for calculating relative error from the previous iterate that is subsequently used in the stopping criteria of the algorithm.


C++ function for updating the ELBO convergence function in a weighted static binary undirected network.

Description

The C++ function ELBO_conv_weighted_stat_undir() updates the ELBO convergence function when the number of clusters is 1 in a weighted static binary undirected network.

Usage

ELBO_conv_weighted_stat_undir_K1(theta, block_dens_mat, adjmat, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

block_dens_mat

Array of a network block density matrices.

adjmat

Array of a network adjacency matrices.

N

Number of nodes.

Value

Returns the value of ELBO for calculating relative error from the previous iterate that is subsequently used in the stopping criteria of the algorithm.


Arms Trade Network Data in 2003.

Description

The directed network on all transfers of major conventional weapons internationally. We define the edges as y_{ij}=1, if the volume of international transfers of arms, measured by Trend Indicator Value (TIV) from country i to country j exceeds 1 million dollars, and y_{ij}=0 otherwise.

Usage

data(armsnet)

Format

The format is a 69 \times 69 network adjacency matrix.

Source

https://www.sipri.org/databases/armstransfers

References

Akerman, A., & Seim, A. L. (2014) The global arms trade network 1950–2007, Journal of Comparative Economics, Vol. 42(3), 535-551

https://www.sciencedirect.com/journal/journal-of-comparative-economics/vol/42/issue/3

Examples

data(armsnet)

C++ function for column-wise numeric calculation in a matrix for a static binary undirected network.

Description

The C++ function colsum_Mat() calculates the sum of each column in a matrix in a static binary undirected network.

Usage

colsum_Mat(M)

Arguments

M

A matrix of numeric type.

Value

Returns a vector as the sum of each column in the input matrix.


C++ function for column-wise numeric calculation in a matrix for a weighted static binary undirected network.

Description

The C++ function colsum_Mat_new() calculates the sum of each column in a matrix in a weighted static binary undirected network.

Usage

colsum_Mat_new(M)

Arguments

M

A matrix of numeric type.

Value

Returns a vector as the sum of each column in the input matrix.


C++ function for column-wise numeric calculation in a matrix for a static binary directed network.

Description

The C++ function colsum_dir_Mat() calculates the sum of each column in a matrix in a static binary undirected network.

Usage

colsum_dir_Mat(M)

Arguments

M

A matrix of numeric type.

Value

Returns a vector as the sum of each column in the input matrix.


A C++ function for numeric calculation of float format.

Description

The C++ function epan() does numeric calculation depending on the absolute value of the input. If the absolute value of the input is less than or equal to 1, a numeric output is returned. Otherwise, 0 is returned.

Usage

epan(input)

Arguments

input

A numeric input of float type.

Value

Returns a float output vector as 0.75*(1-input^2) if the absolute value of the input is less than or equal to 1; 0 otherwise.


Model-Based Clustering of Large Networks Through ERGMs.

Description

Model-based clustering and cluster-specific parameter estimation through the mixed membership Exponential-Family Random Graph Models (ERGMs) using Variational Expectation-Maximization algorithm.

Usage

ergmclust(adjmat, K, directed = FALSE, weighted = FALSE, thresh = 1e-06, 
iter.max = 200, coef.init = NULL, wtmat = NULL)

Arguments

adjmat

An object of class matrix of dimension (N x N) containing the adjacency matrix, where N is the number of nodes in the network.

K

Number of clusters in the mixed membership Exponential-Family Random Graph Models (ERGMs).

directed

If TRUE, the network is supposed to be directed (and therefore adjmat is must be asymmetric in general). By default, this is set as FALSE.

weighted

If TRUE, the network is supposed to be weighted. By default, this is set as FALSE.

thresh

Optional user-supplied convergence threshold for relative error in the objective in Variational Expectation-Maximization (VEM) algorithm. The default value is set as 1e-06.

iter.max

The maximum number of iterations after which the algorithm is terminated. The default value is set as 200.

coef.init

ergmclust chooses the default value as a random perturbation around K-dim zero vector; default is NULL.

wtmat

An object of class matrix of dimension (N x N) containing the weight matrix, where N is the number of nodes in the network; default is NULL.

Details

ergmclust is an R implementation for the model-based clustering through the mixed membership Exponential-Family Random Graph Models (ERGMs) with undirected and directed network data. It uses the Variational Expectation-Maximization algorithm to solve the approximate maximum likelihood estimation.

Value

Returns a list of ergmclust object. Each object of class ergmclust is a list with the following components:

coefficients

An object of class vector of size (K x 1) containing the canonical network parameters in Exponential-Family Random Graph Models (ERGMs).

probability

An object of class matrix of size (N x K) containing the mixed membership probabilities of the model for N nodes distributed in K clusters.

clust.labels

An object of class vector of size (N x 1) containing the cluster membership labels in {1, ..., K} for N nodes.

ICL

Integrated Classification Likelihood (ICL) score calculated from completed data log-likelihood and penalty terms.

Author(s)

Authors: Amal Agarwal [aut], Kevin Lee [aut], Lingzhou Xue [aut, ths, cre], Anna Yinqi Zhang [cre]

Maintainer: Lingzhou Xue <lzxue@psu.edu>

References

Agarwal, A. and Xue, L. (2019) Model-Based Clustering of Nonparametric Weighted Networks With Application to Water Pollution Analysis, Technometrics, to appear doi:10.1080/00401706.2019.1623076

Blei, D. M. , Kucukelbir, A., and McAuliffe, J. D. (2017), Variational Inference: A Review for Statisticians, Journal of the American Statistical Association, Vol. 112(518), 859-877

https://www.tandfonline.com/doi/full/10.1080/01621459.2017.1285773

Lee, K. H., Xue, L, and Hunter, D. R. (2017) Model-Based Clustering of Time-Evolving Networks through Temporal Exponential-Family Random Graph Models, Journal of Multivariate Analysis, to appear

https://arxiv.org/abs/1712.07325

Vu D. Q., Hunter, D. R., and Schweinberger, M. (2013) Model-based Clustering of Large Networks, The Annals of Applied Statistics, Vol. 7(2), 1010-1039

https://projecteuclid.org/euclid.aoas/1372338477

Examples

## undirected network:
data(tradenet)
## clustering and estimation for K = 2 groups
ergmclust(adjmat = tradenet, K = 2, directed = FALSE, 
thresh = 1e-06, iter.max = 120, coef.init = NULL)

## directed network:
data(armsnet)
## clustering and estimation for K = 2 groups
ergmclust(adjmat = armsnet, K = 2, directed = TRUE, 
thresh = 1e-06, iter.max = 120, coef.init = NULL)

Model Selection Based On Integrated Classification Likelihood.

Description

Model-based clustering and cluster-specific parameter estimation through the mixed membership Exponential-Family Random Graph Models (ERGMs) for the different number of clusters. Model selection is based on maximum value of Integrated Classification Likelihood (ICL).

Usage

ergmclust.ICL(adjmat, Kmax = 5, directed = FALSE, weighted = FALSE, thresh = 1e-06, 
iter.max = 200, coef.init = NULL, wtmat = NULL)

Arguments

adjmat

An object of class matrix of dimension (N x N) containing the adjacency matrix, where N is the number of nodes in the network.

Kmax

Maximum number of clusters.

directed

If TRUE, the network is supposed to be directed (and therefore adjmat is must be asymmetric in general). By default, this is set as FALSE.

weighted

If TRUE, the network is supposed to be weighted. By default, this is set as FALSE.

thresh

Optional user-supplied convergence threshold for relative error in the objective in Variational Expectation-Maximization (VEM) algorithm. The default value is set as 1e-06.

iter.max

The maximum number of iterations after which the algorithm is terminated. The default value is set as 200.

coef.init

ergmclust chooses the default value as a random perturbation around K-dim zero vector; default is NULL.

wtmat

An object of class matrix of dimension (N x N) containing the weight matrix, where N is the number of nodes in the network; default is NULL.

Details

ergmclust.ICL is an R implementation for the model selection for an appropriate number of clusters in the mixed membership Exponential-Family Random Graph Models (ERGMs). The Integrated Classification Likelihood (ICL) was proposed by Biernacki et al. (2000) and Daudin, et. al. (2008) to assess the model-based clustering.

Value

Returns a list of ergmclust object. Each object of class ergmclust is a list with the following components:

Kselect

Optimum number of clusters chosen after model selection through Integrated Classification Likelihood (ICL).

coefficients

An object of class vector of size (Kselect x 1) containing the canonical network parameters of the model.

probability

An object of class matrix of size (N x Kselect) containing the mixed membership probabilities of the model for N nodes distributed in Kselect clusters.

clust.labels

An object of class vector of size (N x 1) containing the cluster membership labels in {1, ..., Kselect} for N nodes.

ICL

Integrated Classification Likelihood (ICL) score calculated from completed data log-likelihood and penalty terms.

Author(s)

Authors: Amal Agarwal [aut], Kevin Lee [aut], Lingzhou Xue [aut, ths, cre], Anna Yinqi Zhang [cre]

Maintainer: Lingzhou Xue <lzxue@psu.edu>

References

Biernacki, C., Celeux, G., and Govaert, G. (2000) Assessing a mixture model for clustering with the integrated completed likelihood, IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 22(7), 719-725

https://ieeexplore.ieee.org/document/865189

Daudin, J. J., Picard, F., and Robin, S. (2008) A Mixture Model for Random Graphs, Statistics and Computing, Vol. 18(2), 173–183

https://link.springer.com/article/10.1007/s11222-007-9046-7

Examples

## undirected network:
data(tradenet)
## Model selection for Kmax = 3
ergmclust.ICL(adjmat = tradenet, Kmax = 3, directed = FALSE, 
thresh = 1e-06, iter.max = 120, coef.init = NULL)

## directed network:
data(armsnet)
## Model selection for Kmax = 3
ergmclust.ICL(adjmat = armsnet, Kmax = 3, directed = TRUE,
thresh = 1e-06, iter.max = 60, coef.init = NULL)

Visualization For Model-Based Clustering of Large Networks.

Description

Visualization of the network data with the clusters node colors representing different clusters in the Exponential-Family Random Graph Models (ERGMs) clustered network.

Usage

ergmclust.plot(adjmat, K, directed = FALSE, thresh = 1e-06, 
iter.max = 200, coef.init = NULL, node.labels = NULL)

Arguments

adjmat

An object of class matrix of dimension (N x N) containing the adjacency matrix, where N is the number of nodes in the network.

K

Number of clusters in the mixed membership Exponential-Family Random Graph Models (ERGMs).

directed

If TRUE, the network is supposed to be directed (and therefore adjmat is must be asymmetric in general). By default, this is set as FALSE.

thresh

Optional user-supplied convergence threshold for relative error in the objective in Variational Expectation-Maximization (VEM) algorithm. The default value is set as 1e-06.

iter.max

The maximum number of iterations after which the algorithm is terminated. The default value is set as 200.

coef.init

ergmclust chooses the default value as a random perturbation around K-dim zero vector; default is NULL.

node.labels

Optional user-supplied network node names character vector (N-dimensional); default is NULL.

Details

ergmclust.plot provides the visualization tool for network data clustered through mixed membership Exponential-Family Random Graph Models (ERGMs). The optional argument node.labels could help track the cluster membership of specific nodes.

Value

Returns a plot of network object with colored nodes corresponding to K clusters.

Author(s)

Authors: Amal Agarwal [aut], Kevin Lee [aut], Lingzhou Xue [aut, ths, cre], Anna Yinqi Zhang [cre]

Maintainer: Lingzhou Xue <lzxue@psu.edu>

References

Vu D. Q., Hunter, D. R., and Schweinberger, M. (2013) Model-based Clustering of Large Networks, The Annals of Applied Statistics, Vol. 7(2), 1010-1039

https://projecteuclid.org/euclid.aoas/1372338477

Examples

## undirected network:
data(tradenet)
## Plotting clustered network
ergmclust.plot(adjmat = tradenet, K = 2, directed = FALSE, 
thresh = 1e-06)

## directed network:
data(armsnet)
## Plotting clustered network
ergmclust.plot(adjmat = armsnet, K = 2, directed = TRUE, 
thresh = 1e-06)

C++ function for updating the variable gamma (variational parameters) in a static binary directed network.

Description

The C++ function gamma_update_HMM_stat_dir() updates the value of variable gamma (variational parameters) in a static binary directed network.

Usage

gamma_update_HMM_stat_dir(gamma, pi, theta, network, N, K)

Arguments

gamma

Vector of current gamma (variational parameters) values.

pi

Vector of current pi (mixture proportions) values.

theta

Vector of current theta (network canonical parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns all quadratic and linear term coefficients for the quadratic programs corresponding to all nodes.


C++ function for updating the variable gamma (variational parameters) in a static binary undirected network.

Description

The C++ function gamma_update_HMM_stat_undir() updates the value of variable gamma (variational parameters) in a static binary undirected network.

Usage

gamma_update_HMM_stat_undir(gamma, pi, theta, network, N, K)

Arguments

gamma

Vector of current gamma (variational parameters) values.

pi

Vector of current pi (mixture proportions) values.

theta

Vector of current theta (network canonical parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns all quadratic and linear term coefficients for the quadratic programs corresponding to all nodes.


C++ function for updating the variable gamma (variational parameters) in a weighted static binary undirected network.

Description

The C++ function gamma_update_weighted_stat_undir() updates the value of variable gamma (variational parameters) in a weighted static binary undirected network.

Usage

gamma_update_weighted_stat_undir(gamma, pi, theta, block_dens_mat, adjmat, N, K)

Arguments

gamma

Vector of current gamma (variational parameters) values.

pi

Vector of current pi (mixture proportions) values.

theta

Vector of current theta (network canonical parameters) values.

block_dens_mat

Array of a network density matrices.

adjmat

Array of a network adjacency matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns all quadratic and linear term coefficients for the quadratic programs corresponding to all nodes.


C++ function for updating the gradient function in a static binary directed network.

Description

The C++ function grad_HMM_stat_dir_oe() updates the gradient function when the number of clusters is greater than or equal to 2 in a static binary directed network. (The above description may need further improvement.)

Usage

grad_HMM_stat_dir_oe(theta, gamma, network, N, K)

Arguments

theta

Vector of current theta (network canonical parameters) values.

gamma

Vector of current gamma (variational parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns the gradient vector of ELBO with respect to theta parameters for Newton-Raphson update in the M-step.


C++ function for updating the gradient function in a static binary directed network.

Description

The C++ function grad_HMM_stat_dir_oe_K1() updates the gradient function when the number of cluster is 1 in a static binary directed network. (The above description may need further improvement.)

Usage

grad_HMM_stat_dir_oe_K1(theta, network, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

Value

Returns the gradient vector of ELBO with respect to theta parameters for Newton-Raphson update in the M-step.


C++ function for updating the gradient function in a static binary directed network.

Description

The C++ function grad_HMM_stat_dir_re() updates the gradient function when the number of clusters is greater than or equal to 2 in a static binary directed network. (The above description may need further improvement.)

Usage

grad_HMM_stat_dir_re(theta, gamma, network, N, K)

Arguments

theta

Vector of current theta (network canonical parameters) values.

gamma

Vector of current gamma (variational parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns the gradient vector of ELBO with respect to theta parameters for Newton-Raphson update in the M-step.

Author(s)

Authors: Amal Agarwal, Lingzhou Xue

Maintainer: Yinqi Zhang <ybz5148@psu.edu>


C++ function for updating the gradient function in a static binary directed network.

Description

The C++ function grad_HMM_stat_dir_re() updates the gradient function when the number of cluster is 1 in a static binary directed network. (The above description may need further improvement.)

Usage

grad_HMM_stat_dir_re_K1(theta, network, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

Value

Returns the gradient vector of ELBO with respect to theta parameters for Newton-Raphson update in the M-step.

Author(s)

Authors: Amal Agarwal, Lingzhou Xue

Maintainer: Yinqi Zhang <ybz5148@psu.edu>


C++ function for updating the gradient function in a static binary undirected network.

Description

The C++ function grad_HMM_stat_undir() updates the gradient function when the number of clusters is greater than or equal to 2 in a static binary undirected network.

Usage

grad_HMM_stat_undir(theta, gamma, network, N, K)

Arguments

theta

Vector of current theta (network canonical parameters) values.

gamma

Vector of current gamma (variational parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns the gradient vector of ELBO with respect to theta parameters for Newton-Raphson update in the M-step.

Author(s)

Authors: Amal Agarwal, Lingzhou Xue

Maintainer: Yinqi Zhang <ybz5148@psu.edu>


C++ function for updating the gradient function in a static binary undirected network.

Description

The C++ function grad_HMM_stat_undir() updates the gradient function when the number of clusters is 1 in a static binary undirected network.

Usage

grad_HMM_stat_undir_K1(theta, network, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

network

Array of a network adjacency matrices.

N

Number of nodes.

Value

Returns the gradient vector of ELBO with respect to theta parameters for Newton-Raphson update in the M-step.

Author(s)

Authors: Amal Agarwal, Lingzhou Xue

Maintainer: Yinqi Zhang <ybz5148@psu.edu>


C++ function for updating the gradient function in a weighted static binary undirected network.

Description

The C++ function grad_theta_weighted_stat_undir() updates the gradient function when the number of clusters is greater than or equal to 2 in a weighted static binary undirected network.

Usage

grad_theta_weighted_stat_undir(theta, gamma, adjmat, N, K)

Arguments

theta

Vector of current theta (network canonical parameters) values.

gamma

Vector of current gamma (variational parameters) values.

adjmat

Array of a network adjacency matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns the gradient vector of ELBO with respect to theta parameters for Newton-Raphson update in the M-step.

Author(s)

Authors: Amal Agarwal, Lingzhou Xue

Maintainer: Yinqi Zhang <ybz5148@psu.edu>


C++ function for updating the gradient function in a weighted static binary undirected network.

Description

The C++ function grad_HMM_stat_undir() updates the gradient function when the number of clusters is 1 in a weighted static binary undirected network.

Usage

grad_theta_weighted_stat_undir_K1(theta, adjmat, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

adjmat

Array of a network adjacency matrices.

N

Number of nodes.

Value

Returns the gradient vector of ELBO with respect to theta parameters for Newton-Raphson update in the M-step.


C++ function for updating the Hessian matrix in a static binary directed network.

Description

The C++ function hess_HMM_stat_dir_oe() updates the Hessian matrix when the number of clusters is greater than or equal to 2 in a static binary directed network. (The above description may need further improvement.)

Usage

hess_HMM_stat_dir_oe(theta, gamma, N, K)

Arguments

theta

Vector of current theta (network canonical parameters) values.

gamma

Vector of current gamma (variational parameters) values.

N

Number of nodes.

K

Number of clusters.

Value

Returns the Hessian matrix of ELBO with respect to theta parameters for Newton-Raphson update in M-step.

Author(s)

Authors: Amal Agarwal, Lingzhou Xue

Maintainer: Yinqi Zhang <ybz5148@psu.edu>


C++ function for updating the Hessian matrix in a static binary directed network.

Description

The C++ function hess_HMM_stat_dir_oe_K1() updates the Hessian matrix when the number of cluster is 1 in a static binary directed network. (The above description may need further improvement.)

Usage

hess_HMM_stat_dir_oe_K1(theta, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

N

Number of nodes.

Value

Returns the Hessian matrix of ELBO with respect to theta parameters for Newton-Raphson update in M-step.


C++ function for updating the Hessian matrix in a static binary directed network.

Description

The C++ function hess_HMM_stat_dir_oe_re() updates the Hessian matrix when the number of clusters is greater than or equal to 2 in a static binary directed network. (The above description may need further improvement.)

Usage

hess_HMM_stat_dir_oe_re(theta, gamma, N, K)

Arguments

theta

Vector of current theta (network canonical parameters) values.

gamma

Vector of current gamma (variational parameters) values.

N

Number of nodes.

K

Number of clusters.

Value

Returns the Hessian matrix of ELBO with respect to theta parameters for Newton-Raphson update in M-step.


C++ function for updating the Hessian matrix in a static binary directed network.

Description

The C++ function hess_HMM_stat_dir_oe_re_K1() updates the Hessian matrix when the number of cluster is 1 in a static binary directed network. (The above description may need further improvement.)

Usage

hess_HMM_stat_dir_oe_re_K1(theta, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

N

Number of nodes.

Value

Returns the Hessian matrix of ELBO with respect to theta parameters for Newton-Raphson update in M-step.


C++ function for updating the Hessian matrix in a static binary directed network.

Description

The C++ function hess_HMM_stat_dir_re() updates the Hessian matrix when the number of clusters is greater than or equal to 2 in a static binary directed network. (The above description may need further improvement.)

Usage

hess_HMM_stat_dir_re(theta, gamma, N, K)

Arguments

theta

Vector of current theta (network canonical parameters) values.

gamma

Vector of current gamma (variational parameters) values.

N

Number of nodes.

K

Number of clusters.

Value

Returns the Hessian matrix of ELBO with respect to theta parameters for Newton-Raphson update in M-step.


C++ function for updating the Hessian matrix in a static binary directed network.

Description

The C++ function hess_HMM_stat_dir_re_K1() updates the Hessian matrix when the number of clusters is 1 in a static binary directed network.

Usage

hess_HMM_stat_dir_re_K1(theta, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

N

Number of nodes.

Value

Returns the Hessian matrix of ELBO with respect to theta parameters for Newton-Raphson update in M-step.


C++ function for updating the Hessian matrix in a static binary undirected network.

Description

The C++ function hess_HMM_stat_undir() updates the Hessian matrix when the number of clusters is greater than or equal to 2 in a static binary undirected network.

Usage

hess_HMM_stat_undir(theta, gamma, N, K)

Arguments

theta

Vector of current theta (network canonical parameters) values.

gamma

Vector of current gamma (variational parameters) values.

N

Number of nodes.

K

Number of clusters.

Value

Returns the Hessian matrix of ELBO with respect to theta parameters for Newton-Raphson update in M-step.


C++ function for updating the Hessian matrix in a static binary undirected network.

Description

The C++ function hess_HMM_stat_undir() updates the Hessian matrix when the number of cluster is 1 in a static binary undirected network.

Usage

hess_HMM_stat_undir_K1(theta, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

N

Number of nodes.

Value

Returns the Hessian matrix of ELBO with respect to theta parameters for Newton-Raphson update in M-step.


C++ function for updating the Hessian matrix in a weighted static binary undirected network.

Description

The C++ function hess_theta_weighted_stat_undir() updates the Hessian matrix when the number of clusters is greater than or equal to 2 in a weighted static binary undirected network.

Usage

hess_theta_weighted_stat_undir(theta, gamma, N, K)

Arguments

theta

Vector of current theta (network canonical parameters) values.

gamma

Vector of current gamma (variational parameters) values.

N

Number of nodes.

K

Number of clusters.

Value

Returns the Hessian matrix of ELBO with respect to theta parameters for Newton-Raphson update in M-step.


C++ function for updating the Hessian matrix in a weighted static binary undirected network.

Description

The C++ function hess_theta_weighted_stat_undir_K1() updates the Hessian matrix when the number of clusters is equal to 1 in a weighted static binary undirected network.

Usage

hess_theta_weighted_stat_undir_K1(theta, N)

Arguments

theta

Vector of current theta (network canonical parameters) values.

N

Number of nodes.

Value

Returns the Hessian matrix of ELBO with respect to theta parameters for Newton-Raphson update in M-step.


C++ function for row-wise numeric calculation in a matrix for a static binary undirected network.

Description

The C++ function rowsum_Mat() calculates the sum of each row in a matrix in a static binary undirected network.

Usage

rowsum_Mat(M)

Arguments

M

A matrix of numeric type.

Value

Returns a vector as the sum of each row in the input matrix.


C++ function for row-wise numeric calculation in a matrix for a weighted static binary undirected network.

Description

The C++ function rowsum_Mat_new() calculates the sum of each row in a matrix in a weighted static binary undirected network.

Usage

rowsum_Mat_new(M)

Arguments

M

A matrix of numeric type.

Value

Returns a vector as the sum of each row in the input matrix.


C++ function for row-wise numeric calculation in a matrix for a static binary directed network.

Description

The C++ function rowsum_dir_Mat() calculates the sum of each row in a matrix in a static binary directed network.

Usage

rowsum_dir_Mat(M)

Arguments

M

A matrix of numeric type.

Value

Returns a vector as the sum of each row in the input matrix.


C++ function to acquire the y_ij for all pairs of clusters.

Description

The C++ function retrieves y_ij for all pairs of clusters in a weighted static binary undirected network.

Usage

tie_clust_partition(clust_est, adjmat, wtmat, N, K)

Arguments

clust_est

A vector of estimated cluster membership.

adjmat

Array of a network adjacency matrices.

wtmat

Array of a network weight matrices.

N

Number of nodes.

K

Number of clusters.

Value

Returns y_ij (0, 1) for all pairs of clusters


International Trade Network Data in 1991.

Description

The undirected network on all trade relations internationally among 58 countries. We define the edges as y_{ij}=1, if there is a bilateral trade between country i and j, and y_{ij}=0 otherwise.

Usage

data(tradenet)

Format

The format is a 58 \times 58 network adjacency matrix.

Source

https://projecteuclid.org/euclid.aoas/1310562208#supplemental

References

Westveld, A. H. and Hoff, P. D. (2011) A mixed effects model for longitudinal relational and network data, with applications to international trade and conflict, The Annals of Applied Statistics 5(2A), 843–872

https://projecteuclid.org/euclid.aoas/1310562208

Examples

data(tradenet)

An estimation framework for static binary directed networks.

Description

The inner wrapper function wrapper_HMM_stat_dir_Dens() is an estimation framework for binary static directed network based on variational Expectation-Maximization algorithm.

Usage

wrapper_HMM_stat_dir_Dens(adjmat, K, thresh, iter.max, coef.init)

Arguments

adjmat

Array of the network adjacency matrices.

K

Number of clusers for which the estimation must be performed.

thresh

Convergence threshold for estimation, the default being 1e-6.

iter.max

The maximum number of iterations after which the algorithm is terminated. The default value is set as 200.

coef.init

The initial value of the density, stability, transitivity parameters for which clustering is desired, the default being 1e-1.

Value

Returns a list of ergmclust object. Each object of class ergmclust is a list with the following components:

Converged Parameters

The first elements of the list in sequential order are gamma, alpha, pi, tau, theta for dynamic networks. For static networks, there is no pi or tau.

Estimated Cluster IDs

The second element of the list is a vector (matrix) of estimated cluster memberships for a static (dynamic) case. This is absent for all K=1 cases.

ICL Values

The third element of the list is the Integrated Classification Likelihood value that can be used for model selection, i.e. selecting the appropriate number of clusters.


An estimation framework for static binary undirected networks.

Description

The inner wrapper function wrapper_HMM_stat_undir_Dens() is an estimation framework for binary static undirected network based on variational Expectation-Maximization algorithm.

Usage

wrapper_HMM_stat_undir_Dens(adjmat, K, thresh, iter.max, coef.init)

Arguments

adjmat

Array of the network adjacency matrices.

K

Number of clusters for which the estimation must be performed.

thresh

Convergence threshold for estimation, the default being 1e-6.

iter.max

The maximum number of iterations after which the algorithm is terminated. The default value is set as 200.

coef.init

The initial value of the density, stability, transitivity parameters for which clustering is desired, the default being 1e-1.

Value

Returns a list of ergmclust object. Each object of class ergmclust is a list with the following components:

Converged Parameters

The first elements of the list in sequential order are gamma, alpha, pi, tau, theta for dynamic networks. For static networks, there is no pi or tau.

Estimated Cluster IDs

The second element of the list is a vector (matrix) of estimated cluster memberships for a static (dynamic) case. This is absent for all K=1 cases.

ICL Values

The third element of the list is the Integrated Classification Likelihood value that can be used for model selection, i.e. selecting the appropriate number of clusters.


An estimation framework for weighted static binary undirected networks.

Description

The inner wrapper function wrapper_weighted_stat_undir() is an estimation framework for weighted binary static undirected network based on variational Expectation-Maximization algorithm.

Usage

wrapper_weighted_stat_undir(adjmat = NULL, wtmat = NULL, K, 
thresh = 10^(-6), iter.max, coef.init)

Arguments

adjmat

Array of the network adjacency matrices.

wtmat

Array of the network weight matrices.

K

Number of clusters for which the estimation must be performed.

thresh

Convergence threshold for estimation, the default being 1e-6.

iter.max

The maximum number of iterations after which the algorithm is terminated. The default value is set as 200.

coef.init

The initial value of the density, stability, transitivity parameters for which clustering is desired, the default being 1e-1.

Value

Returns a list of ergmclust object. Each object of class ergmclust is a list with the following components:

Converged Parameters

The first elements of the list in sequential order are gamma, alpha, pi, tau, theta for dynamic networks. For static networks, there is no pi or tau.

Estimated Cluster IDs

The second element of the list is a vector (matrix) of estimated cluster memberships for a static (dynamic) case. This is absent for all K=1 cases.

ICL Values

The third element of the list is the Integrated Classification Likelihood value that can be used for model selection, i.e. selecting the appropriate number of clusters.