plotMEclustnet: Plot latent position network.

Description Usage Arguments Details References See Also Examples

View source: R/plotMEclustnet.R

Description

Function to plot the resulting fitted network, using first two dimensions only.

Usage

1
plotMEclustnet(fit, Y, link.vars, mix.vars)

Arguments

fit

An object storing the output of the function MEclustnet.

Y

The n x n binary adjacency matrix, with 0 down the diagonal, that was passed to MEclustnet.

link.vars

A vector of the column numbers of the data frame covars to be included in link probability model. If none are to be included, this argument should be 1.

mix.vars

A vector of the column numbers of the data frame covars to be included in mixing proportions model. If none are to be included, argument should be 1.

Details

This function will plot the posterior mean latent location for each node in the network. The colour of each node reflects the posterior modal cluster membership, and the ellipses are 50% posterior sets illustrating the uncertainty in the latent locations. The grey lines illustrate the observed links between the nodes.

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

MEclustnet

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#################################################################
# 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

MEclustnet documentation built on Oct. 10, 2019, 5:04 p.m.