MEclustnet {MEclustnet} | R Documentation |
MEclustnet: A package for model-based clustering of nodes in a network, accounting for covariates.
Description
The main function of interest is MEclustnet which will fit a mixture of experts latent position cluster model to a binary network.
MEclustnet will fit a mixture of experts latent position cluster model to a binary network.
Usage
MEclustnet(Y, covars, link.vars = c(1:ncol(covars)),
mix.vars = c(1:ncol(covars)), G = 2, d = 2, itermax = 10000,
uphill = 100, burnin = 1000, thin = 10, rho.input = 1,
verbose = TRUE, ...)
Arguments
Y |
An n x n binary matrix of links between n nodes, with 0 on the diagonal and 1 indicating a link. |
covars |
An n x p data frame of node specific covariates. Categorical variables should be factors. First column should be a column of 1s, and should always be passed in. |
link.vars |
A vector of the column numbers of the data frame |
mix.vars |
A vector of the column numbers of the data frame |
G |
The number of clusters in the model to be fitted. |
d |
The dimension of the latent space. |
itermax |
Maximum number of iterations in the MCMC chain. |
uphill |
Number of iterations for which uphill only steps in the MCMC chain should be run to find maximum a posteriori estimates. |
burnin |
Number of burnin iterations in the MCMC chain. |
thin |
The degree of thinning to be applied to the MCMC chain. |
rho.input |
Scaling factor to achieve desirable acceptance rates in Metropolis-Hastings steps. |
verbose |
Print progress updates to screen? Recommended as the models are slow to run. |
... |
Additional arguments. |
Details
This function fits the mixture of experts latent position cluster model to a binary network via a Metropolis-within-Gibbs sampler. Covariates can influence either the link probabilities between nodes and/or the cluster memberships of nodes.
Value
An object of class MEclustnet
, which is a list containing:
- zstore
An n x d x store.dim array of sampled latent location matrices, where store.dim is the number of post burnin thinned iterations.
- betastore
A store.dim x p matrix of sampled beta vectors, the logistic regression parameters of the link probabilities model.
- Kstore
A store.dim x n matrix of sampled cluster membership vectors.
- mustore
A G x d x store.dim array of sampled cluster mean latent location matrices.
- sigma2store
A store.dim x G matrix of sampled cluster variances.
- lambdastore
An n x G x store.dim array of sampled mixing proportion matrices.
- taustore
A G x s x store.dim array of sampled tau vectors, the logistic regression parameters of the mixing proportions model, where s is the length of tau.
- LLstore
A vector of length store.dim storing the loglikelihood from each stored iteration.
- G
The number of clusters fitted
- d
The dimension of the latent space
- countbeta
Count of accepted beta values
- counttau
Count of accepted tau values
MEclustnet functions
MEclustnet
References
Isobel Claire Gormley and Thomas Brendan Murphy. (2010) A Mixture of Experts Latent Position Cluster Model for Social Network Data. Statistical Methodology, 7 (3), pp.385-405.
See Also
Examples
#################################################################
# An example from the Gormley and Murphy (2010) paper, using the Lazega lawyers friendship network.
#################################################################
# Number of iterations etc. are set to low values for illustrative purposes.
# Longer run times are likely to be required to achieve sufficient mixing.
library(latentnet)
data(lawyers.adjacency.friends)
data(lawyers.covariates)
link.vars = c(1)
mix.vars = c(1,4,5)
fit = MEclustnet(lawyers.adjacency.friends, lawyers.covariates,
link.vars, mix.vars, G=2, d=2, itermax = 500, burnin = 50, uphill = 1, thin=10)
# Plot the trace plot of the mean of dimension 1 for each cluster.
matplot(t(fit$mustore[,1,]), type="l", xlab="Iteration", ylab="Parameter")
# Compute posterior summaries
summ = summaryMEclustnet(fit, lawyers.adjacency.friends)
plot(summ$zmean, col=summ$Kmode, xlab="Dimension 1", ylab="Dimension 2", pch=summ$Kmode,
main = "Posterior mean latent location for each node.")
# Plot the resulting latent space, with uncertainties
plotMEclustnet(fit, lawyers.adjacency.friends, link.vars, mix.vars)
#################################################################
# An example analysing a 2016 Twitter network of US politicians.
#################################################################
# Number of iterations etc. are set to low values for illustrative purposes.
# Longer run times are likely to be required to achieve sufficient mixing.
library(latentnet)
data(us.twitter.adjacency)
data(us.twitter.covariates)
link.vars = c(1)
mix.vars = c(1,5,7,8)
fit = MEclustnet(us.twitter.adjacency, us.twitter.covariates,
link.vars, mix.vars, G=4, d=2, itermax = 500, burnin = 50, uphill = 1, thin=10)
# Plot the trace plot of the mean of dimension 1 for each cluster.
matplot(t(fit$mustore[,1,]), type="l", xlab="Iteration", ylab="Parameter")
# Compute posterior summaries
summ = summaryMEclustnet(fit, us.twitter.adjacency)
plot(summ$zmean, col=summ$Kmode, xlab="Dimension 1", ylab="Dimension 2", pch=summ$Kmode,
main = "Posterior mean latent location for each node.")
# Plot the resulting latent space, with uncertainties
plotMEclustnet(fit, us.twitter.adjacency, link.vars, mix.vars)
# Examine which politicians are in which clusters...
clusters = list()
for(g in 1:fit$G)
{
clusters[[g]] = us.twitter.covariates[summ$Kmode==g,c("name", "party")]
}
clusters