Title: | Fit the Mixture of Experts Latent Position Cluster Model to Network Data |
---|---|
Description: | Functions to facilitate model-based clustering of nodes in a network in a mixture of experts setting, which incorporates covariate information on the nodes in the modelling process. Isobel Claire Gormley and Thomas Brendan Murphy (2010) <doi:10.1016/j.stamet.2010.01.002>. |
Authors: | Isobel Claire Gormley [aut, cre], Thomas Brendan Murphy [aut] |
Maintainer: | Isobel Claire Gormley <[email protected]> |
License: | GPL-2 |
Version: | 1.2.2 |
Built: | 2025-03-12 05:17:02 UTC |
Source: | https://github.com/cran/MEclustnet |
Function to compute the each observation's mixing proportions which are modeled as a logistic function of their covariates.
calclambda(tau, x.mix)
calclambda(tau, x.mix)
tau |
A matrix of logistic regression coefficients, with G rows and number of columns equal to the number of covariates in the mixing proportions model plus 1, for the intercept. |
x.mix |
A matrix of covariates in the mixing proportions model (including dummy variables for any factor covariates), with a column of 1's appended at the front. |
An n x G matrix of mixing proportions.
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.
This function calculates the log likelihood function of the data.
calcloglikelihood(pis, y)
calcloglikelihood(pis, y)
pis |
Vector of link probabilities. |
y |
Vector version of the adjacency matrix, with the diagonal removed. |
The value of the log likelihood function.
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.
Update the count of the number of observations in each cluster.
calcm(m, G, K)
calcm(m, G, K)
m |
Vector of length G containing the number of nodes in each cluster. |
G |
The number of clusters in the model being fitted. |
K |
Vector of length n detailing the number of the cluster to which each node belongs. |
Vector of length G containing the number of nodes in each cluster.
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.
Function calculates link probabilities between nodes.
calcpis(beta, x.link, delta, n.tilde)
calcpis(beta, x.link, delta, n.tilde)
beta |
Vector of regression coefficients in the link probabilities. |
x.link |
Matrix, with |
delta |
Vector of Euclidean distances between locations in the latent space of all pairs of nodes. |
n.tilde |
Length of the vector version of the adjacency matrix, with the diagonal removed i.e. |
A vector of length providing the link probabilities between all pairs of nodes.
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.
This function reformats the matrix of input covariates into the required format for the link probabilities and for the mixing proportions.
formatting.covars(covars, link.vars, mix.vars, n)
formatting.covars(covars, link.vars, mix.vars, n)
covars |
The n x p data frame of node specific covariates passed in to the overall |
link.vars |
A vector detailing the column numbers of the matrix covars that should be included in the link probabilities model. |
mix.vars |
A vector detailing the column numbers of the matrix covars that should be included in the mixing proportions probabilities model. |
n |
The number of nodes in the network. |
For the link regression model, the difference in the link.vars covariates, for all pairs of nodes is calculated. For the mixing proportions model, the required representation of the mix.vars required is formed, where for categorical/factor variables a dummy value representation is used.
A list with
A matrix with rows and length(link.vars) columns, detailing the differences in covariates for all pairs of nodes.
A matrix with n rows and number of columns equal to the number of variables detailed in mix.vars, where dummy variable representations will be used for categorical.factor covariates.
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.
data(us.twitter.covariates) link.vars = c(1) mix.vars = c(1,5,7,8) res = formatting.covars(us.twitter.covariates, link.vars, mix.vars, nrow(us.twitter.covariates)) dim(res$x.link) dim(res$x.mix)
data(us.twitter.covariates) link.vars = c(1) mix.vars = c(1,5,7,8) res = formatting.covars(us.twitter.covariates, link.vars, mix.vars, nrow(us.twitter.covariates)) dim(res$x.link) dim(res$x.mix)
This function accounts for the fact that configurations in the latent space are invariant to rotations, reflections and translations.
invariant(z, zMAP)
invariant(z, zMAP)
z |
An n x d matrix of latent locations in the d dimensional space for each of n nodes. |
zMAP |
The maximum a posteriori configuration of latent locations used as the template to which all sampled configurations are mapped. |
Procrustean rotations, reflections and translations (note: NOT dilations) are employed to best match z to zMAP.
The transformed version of the input configuration z that best matches zMAP.
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.
This function corrects for the issue of label switching when fitting mixture models in a Bayesian setting.
labelswitch(mu, sigma2, lambda, tau, K, G, d, perms, muMAP, iter, uphill, burnin, thin, s, x.mix)
labelswitch(mu, sigma2, lambda, tau, K, G, d, perms, muMAP, iter, uphill, burnin, thin, s, x.mix)
mu |
A G x d matrix of mean latent locations. |
sigma2 |
A vector of length G containing the covariance of the latent locations within each cluster. |
lambda |
An n x G matrix of mixing proportions. |
tau |
A matrix of logistic regression coefficients, with G rows and number of columns equal to the number of covariates in the mixing proportions model plus 1, for the intercept. |
K |
Vector of length n detailing the number of the cluster to which each node belongs. |
G |
The number of clusters in the model being fitted. |
d |
The dimension of the latent space. |
perms |
A G! x G matrix of all possible permutations of 1:G (output by permutations(G), say). |
muMAP |
A G x d matrix of maximum a posteriori latent location means, obtained at the end of the uphill only section of the MCMC chain. Used as the template to correct for label switching. |
iter |
Iteration number. |
uphill |
Number of iterations for which uphill only steps in the MCMC chain should be run. |
burnin |
Number of iterations of the MCMC chain which should not be included in a posteriori summaries. |
thin |
Thinning frequency of the MCMC chain to ensure independent samples. |
s |
Number of columns in the reformatted covariates matrix for the mixing proportions model, output by |
x.mix |
The reformatted covariates matrix for the mixing proportions model, output by |
The muMAP matrix is used as the reference to which each new estimate the cluster means is matched to correct for any label switching which may have occurred during sampling. A sum of squares function is employed as the loss function.
A list containing:list(mu, sigma2, lambda, tau, K)
The label-corrected matrix of cluster means.
The label-corrected vector of cluster covariances.
The label-corrected matrix of mixing proportions.
The label-corrected matrix of logistic regression coefficients for the mixing proportions model.
The label-corrected vector of length n detailing the number of the cluster to which each node belongs.
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.
Data on whether or not 71 lawyers in a northeastern American law firm asked each other for advice.
lawyers.adjacency.advice
lawyers.adjacency.advice
A 71 x 71 binary matrix, with 0 down the diagonal.
E. Lazega, The Collegial Phenomenon: The Social Mechanisms of Cooperation Among Peers in a Corporate Law Partnership, Oxford University Press, Oxford, England, 2001.
Data on whether or not 71 lawyers in a northeastern American law firm work with each other.
lawyers.adjacency.coworkers
lawyers.adjacency.coworkers
A 71 x 71 binary matrix, with 0 down the diagonal.
E. Lazega, The Collegial Phenomenon: The Social Mechanisms of Cooperation Among Peers in a Corporate Law Partnership, Oxford University Press, Oxford, England, 2001.
Data on whether or not 71 lawyers in a northeastern American law firm are friends outside of work.
lawyers.adjacency.friends
lawyers.adjacency.friends
A 71 x 71 binary matrix, with 0 down the diagonal.
E. Lazega, The Collegial Phenomenon: The Social Mechanisms of Cooperation Among Peers in a Corporate Law Partnership, Oxford University Press, Oxford, England, 2001.
Covariates on each of 71 lawyers in a northeastern American law firm. Note the first column is a column of 1's.
lawyers.covariates
lawyers.covariates
A data frame with 71 observations on the following 8 variables.
Intercept
a column of 1s should always be the first column.
Seniority
a factor with levels 1
= partner, 2
= associate.
Gender
a factor with 1
= male, 2
= female.
Office
a factor with levels 1
= Boston, 2
= Hartford and 3
= Providence
Years
a numeric vector detailing years with the firm.
Age
a numeric vector detailing the age of each lawyer.
Practice
a factor with levels 1
= litigation and 2
= corporate.
School
a factor with levels 1
= Harvard or Yale, 2
= University of Connecticut and 3
= Other.
E. Lazega, The Collegial Phenomenon: The Social Mechanisms of Cooperation Among Peers in a Corporate Law Partnership, Oxford University Press, Oxford, England, 2001.
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.
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, ...)
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, ...)
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. |
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.
An object of class MEclustnet
, which is a list containing:
An n x d x store.dim array of sampled latent location matrices, where store.dim is the number of post burnin thinned iterations.
A store.dim x p matrix of sampled beta vectors, the logistic regression parameters of the link probabilities model.
A store.dim x n matrix of sampled cluster membership vectors.
A G x d x store.dim array of sampled cluster mean latent location matrices.
A store.dim x G matrix of sampled cluster variances.
An n x G x store.dim array of sampled mixing proportion matrices.
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.
A vector of length store.dim storing the loglikelihood from each stored iteration.
The number of clusters fitted
The dimension of the latent space
Count of accepted beta values
Count of accepted tau values
MEclustnet
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.
################################################################# # 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
################################################################# # 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
Function to plot the resulting fitted network, using first two dimensions only.
plotMEclustnet(fit, Y, link.vars, mix.vars)
plotMEclustnet(fit, Y, link.vars, mix.vars)
fit |
An object storing the output of the function |
Y |
The n x n binary adjacency matrix, with 0 down the diagonal, that was passed to |
link.vars |
A vector of the column numbers of the data frame |
mix.vars |
A vector of the column numbers of the data frame |
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.
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.
################################################################# # 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
################################################################# # 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
Summary of the output of the function MEclustnet which fits a mixture of experts latent position cluster model.
summaryMEclustnet(fit, Y)
summaryMEclustnet(fit, Y)
fit |
An object storing the output of the function |
Y |
The n x n binary adjacency matrix, with 0 down the diagonal, that was passed to |
A list with:
The value of the AICM criterion for the fitted model.
The value of the BICM criterion for the fitted model.
The value of the BICMCMC criterion for the fitted model.
The posterior mean vector of the regression coefficients for the link probabilities model.
The standard deviation of the posterior distribution of beta.
A matrix with G rows, detailing the posterior mean of the regression coefficients for the mixing proportions model.
The standard deviation of the posterior distribution of tau.
A G x d matrix containing the posterior mean of the latent locations' mean.
The standard deviation of the posterior distribution of mu.
A vector of length G containing the posterior mean of the latent locations' covariance.
The standard deviation of the posterior distribution of the latent locations' covariance.
A vector of length n detailing the posterior modal cluster membership for each node.
An n x d matrix containing the posterior mean latent location for each node.
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.
################################################################# # 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
################################################################# # 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
The Metropolis-Hastings update step for the logistic regression parameters in the link probabilities model, using a surrogate proposal distribution.
updatebeta(beta, p, x.link, delta, y, epsilon, psi, psi.inv, pis, countbeta, rho, n.tilde)
updatebeta(beta, p, x.link, delta, y, epsilon, psi, psi.inv, pis, countbeta, rho, n.tilde)
beta |
Vector of regression coefficients in the link probabilities. |
p |
Length of beta. |
x.link |
Matrix, with |
delta |
Vector of Euclidean distances between locations in the latent space of all pairs of nodes. |
y |
Vector version of the adjacency matrix, with the diagonal removed. |
epsilon |
Mean of the multivariate normal prior on beta. |
psi |
Covariance of the multivariate normal prior on beta. |
psi.inv |
Inverse covariance of the multivariate normal prior on beta. |
pis |
Vector of length |
countbeta |
Counter for number of steps for which the proposed beta value was accepted. |
rho |
Scaling factor to be used to adjust the acceptance rate. |
n.tilde |
Length of the vector version of the adjacency matrix, with the diagonal removed i.e. |
See appendix of the paper detailed below for details.
A list:
The returned version of the beta parameter vector.
The count of the number of acceptances of beta to that point in the MCMC chain.
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.
A Gibbs update step for K, the cluster membership vector.
updateK(G, K, z, mu, sigma2, Id, lambda)
updateK(G, K, z, mu, sigma2, Id, lambda)
G |
The number of clusters being fitted. |
K |
The cluster membership vector. |
z |
The n x d matrix of latent locations. |
mu |
The G x d matrix of cluster means. |
sigma2 |
The G vector of cluster covariances. |
Id |
An identity matrix of dimension d. |
lambda |
The n x G matrix of mixing proportions. |
The cluster membership vector.
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.
A Gibbs step to update the mean of each cluster.
updatemu(G, z, K, m, sigma2, omega2, Id, mu, d)
updatemu(G, z, K, m, sigma2, omega2, Id, mu, d)
G |
The number of clusters being fitted. |
z |
The n x d matrix of latent locations. |
K |
The cluster membership vector. |
m |
Vector of length G containing the number of nodes in each cluster. |
sigma2 |
The covariance of each cluster. |
omega2 |
Covariance of the multivariate normal prior distribution on the means. Note this is a scalar value, as the prior covariance is diagonal. |
Id |
A d x d identity matrix. |
mu |
The G x d matrix of cluster means. |
d |
The dimension of the latent space. |
The G x d matrix of cluster means.
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.
A Gibbs step to update variances in each cluster.
updatesigma2(G, alpha, m, d, sigma02, z, K, mu, sigma2)
updatesigma2(G, alpha, m, d, sigma02, z, K, mu, sigma2)
G |
The number of clusters being fitted. |
alpha |
Degrees of freedom of the scaled inverse Chi squared prior distribution on the cluster variances. |
m |
Vector of length G containing the number of nodes in each cluster. |
d |
Dimension of the latent space. |
sigma02 |
Scaled factor of the scaled inverse Chi squared prior distribution on the cluster variances. |
z |
The n x d matrix of latent locations. |
K |
The cluster membership vector. |
mu |
The G x d matrix of cluster means. |
sigma2 |
The G vector of cluster variances. |
The G vector of cluster variances.
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.
The Metropolis-Hastings update step for the logistic regression parameters in the mixing proportions model, using a surrogate proposal distribution.
updatetau(G, x.mix, lambda, Sigmag, Sigmag.inv, K, gammag, tau, counttau, rho)
updatetau(G, x.mix, lambda, Sigmag, Sigmag.inv, K, gammag, tau, counttau, rho)
G |
The number of clusters being fitted. |
x.mix |
A matrix of covariates in the mixing proportions model (including dummy variables for any factor covariates), with a column of 1's appended at the front. |
lambda |
An n x G matrix of mixing proportions. |
Sigmag |
Covariance matrix of the multivariate normal prior for tau. |
Sigmag.inv |
The inverse of Sigmag. |
K |
The cluster membership vector. |
gammag |
Mean vector of the multivariate normal prior for tau. |
tau |
A matrix of logistic regression coefficients, with G rows and number of columns equal to the number of covariates in the mixing proportions model plus 1, for the intercept. |
counttau |
Counter for number of steps for which the proposed tau value was accepted. |
rho |
Scaling factor to be used to adjust the acceptance rate. |
A list:
The returned version of the tau parameter vector.
The returned version of the lambda matrix.
The count of the number of acceptances of tau to that point in the MCMC chain.
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.
A Metropolis-Hastings update step for the latent locations.
updatez(n, z, x.link, delta, beta, y, mu, K, sigma2, Id, pis, iter, uphill, countz, delete, d, n.tilde)
updatez(n, z, x.link, delta, beta, y, mu, K, sigma2, Id, pis, iter, uphill, countz, delete, d, n.tilde)
n |
The number of nodes. |
z |
The n x d matrix of latent locations. |
x.link |
Matrix, with |
delta |
Vector of Euclidean distances between locations in the latent space of all pairs of nodes. |
beta |
Vector of regression coefficients in the link probabilities. |
y |
Vector version of the adjacency matrix, with the diagonal removed. |
mu |
The G x d matrix of cluster means. |
K |
The cluster membership vector |
sigma2 |
The covariance of each cluster. |
Id |
A d dimensional identity matrix. |
pis |
A vector of length |
iter |
Iteration number. |
uphill |
Number of iterations for which uphill only steps in the MCMC chain should be run. |
countz |
Counter for number of steps for which the proposed z value was accepted. |
delete |
Index of the terms to be deleted in order to delete the diagonal terms from the vector version of the adjacency matrix. |
d |
The dimension of the latent space. |
n.tilde |
Length of the vector version of the adjacency matrix, with the diagonal removed i.e. |
A list:
The returned matrix of latent locations.
Vector of Euclidean distances between locations in the latent space of all pairs of nodes.
A vector of length providing the link probabilities between all pairs of nodes.
Counter for z acceptance rate.
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.
Network data on whether or not 69 US politicians are friends/followers on Twitter.
us.twitter.adjacency
us.twitter.adjacency
A 69 x 69 binary matrix, with 0 down the diagonal.
With thanks to Dr. Derek Greene. School of Computer Science, University College Dublin.
Covariates on each of 69 US politicians. Note the first column is a column of 1's.
us.twitter.covariates
us.twitter.covariates
A data frame with 69 observations on the following 8 variables.
a column of 1s should always be the first column.
twitter_id
Twitter number.
twitter_name
Twitter name.
name
Actual name.
party
a factor with levels Democrat
Republican
location
a factor with levels detailing location.
role
a factor with levels Candidate
, Representative
and Senator
gender
a factor with levels Female
and Male
E. Lazega, The Collegial Phenomenon: The Social Mechanisms of Cooperation Among Peers in a Corporate Law Partnership, Oxford University Press, Oxford, England, 2001.