Title: | Multiple Allocation Model for Actor-Event Networks |
---|---|
Description: | Mixture model with overlapping clusters for binary actor-event data. Parameters are estimated in a Bayesian framework. Model and inference are described in Ranciati, Vinciotti, Wit (2017) Modelling actor-event network data via a mixture model under overlapping clusters. Submitted. |
Authors: | Saverio Ranciati [aut], Veronica Vinciotti [cre], Ernst Wit [aut] |
Maintainer: | Veronica Vinciotti <[email protected]> |
License: | GPL-2 |
Version: | 2.0 |
Built: | 2024-12-11 07:23:45 UTC |
Source: | CRAN |
Synthetic data matrix of dimension n x d, recording attendances of n=500 people to d=14 concerts from 14 different artists. There are three clusters in the data, each one corresponding to a community of fans of a specific musical genre. Overlaps of these fandoms point towards attendances dictated by artists playing music from sub-genres - such as electropop.
concerts
concerts
A data frame with 500 rows and 14 variables
14 concerts attendended: "Blondie", "Fleetwood Mac", "Paramore", "Queen", "St.Vincent", "The Queen", "Pet Shop Boys", "M83", "Daft Punk", "Goldfrapp", "Chvrches", "LaRoux", "Robyn", "BANKS"
500 attendees
#DATA GENERATION z_ext <-function(x,nfac){ nq <- length(x) zx <- hcube(rep(nq,nfac)) zx <- zx[,dim(zx)[2]:1] z2 <- matrix(x[zx],dim(zx)[1],dim(zx)[2]) return(z2) } K=3 # main clusters: Rock (cluster h=5), Pop (cluster h=3), Electronic (cluster h=2) K_star=2^K n=500 #attendees set.seed(777) u=z_ext(0:1,K) alpha_star=rep(0,K_star) alpha_star=c(0.05,0.10,0.35,0.15,0.25,0.00,0.10,0.00) index=rep(0,n) for(i in 1:n) index[i]=sample(1:K_star,1,prob=alpha_star) d=14 #concerts/artists y<-matrix(0,n,d) colnames(y)=c("Blondie", "Fleetwood Mac", "Paramore","Queen","St.Vincent", "The Queen", "Pet Shop Boys","M83","Daft Punk", "Goldfrapp", "Chvrches", "LaRoux", "Robyn","BANKS") pi.greco=matrix(0,K,d) rownames(pi.greco)=c("Rock","Pop","Electronic") colnames(pi.greco)=colnames(y) pi.greco[1,]=c(0.80,0.80,0.80,0.70,0.90,0.80,0.10,0.10,0.05,0.05,0.10,0.05,0.05,0.10) pi.greco[2,]=c(0.10,0.10,0.90,0.80,0.90,0.80,0.05,0.10,0.05,0.70,0.70,0.05,0.80,0.05) pi.greco[3,]=c(0.05,0.05,0.05,0.10,0.05,0.05,0.80,0.90,0.90,0.80,0.70,0.80,0.90,0.90) for (i in 1:n) for(j in 1:d) y[i,j]<-rbinom(1,1,prob=ifelse(sum(u[index[i],])==0,0.00000001,min(pi.greco[,j]^u[index[i],]))) #y is the 500x14 matrix of data #RUNNING MANET ## Not run: data(concerts) start=Sys.time() crt<-manet(concerts,K=3,maxT=5000) finish=Sys.time() finish-start #Time difference of 11.58112 mins plot(crt) summary(crt) alloc<-summary(crt)$actor.allocations[,2] adjustedRandIndex(index,alloc) #0.8420733 classError(alloc,index)$errorRate #0.07 ## End(Not run)
#DATA GENERATION z_ext <-function(x,nfac){ nq <- length(x) zx <- hcube(rep(nq,nfac)) zx <- zx[,dim(zx)[2]:1] z2 <- matrix(x[zx],dim(zx)[1],dim(zx)[2]) return(z2) } K=3 # main clusters: Rock (cluster h=5), Pop (cluster h=3), Electronic (cluster h=2) K_star=2^K n=500 #attendees set.seed(777) u=z_ext(0:1,K) alpha_star=rep(0,K_star) alpha_star=c(0.05,0.10,0.35,0.15,0.25,0.00,0.10,0.00) index=rep(0,n) for(i in 1:n) index[i]=sample(1:K_star,1,prob=alpha_star) d=14 #concerts/artists y<-matrix(0,n,d) colnames(y)=c("Blondie", "Fleetwood Mac", "Paramore","Queen","St.Vincent", "The Queen", "Pet Shop Boys","M83","Daft Punk", "Goldfrapp", "Chvrches", "LaRoux", "Robyn","BANKS") pi.greco=matrix(0,K,d) rownames(pi.greco)=c("Rock","Pop","Electronic") colnames(pi.greco)=colnames(y) pi.greco[1,]=c(0.80,0.80,0.80,0.70,0.90,0.80,0.10,0.10,0.05,0.05,0.10,0.05,0.05,0.10) pi.greco[2,]=c(0.10,0.10,0.90,0.80,0.90,0.80,0.05,0.10,0.05,0.70,0.70,0.05,0.80,0.05) pi.greco[3,]=c(0.05,0.05,0.05,0.10,0.05,0.05,0.80,0.90,0.90,0.80,0.70,0.80,0.90,0.90) for (i in 1:n) for(j in 1:d) y[i,j]<-rbinom(1,1,prob=ifelse(sum(u[index[i],])==0,0.00000001,min(pi.greco[,j]^u[index[i],]))) #y is the 500x14 matrix of data #RUNNING MANET ## Not run: data(concerts) start=Sys.time() crt<-manet(concerts,K=3,maxT=5000) finish=Sys.time() finish-start #Time difference of 11.58112 mins plot(crt) summary(crt) alloc<-summary(crt)$actor.allocations[,2] adjustedRandIndex(index,alloc) #0.8420733 classError(alloc,index)$errorRate #0.07 ## End(Not run)
This is a data set of 18 women observed over a nine-month period. During that period, various subsets of these women met in a series of 14 informal social events. The data recored which women met for which events.
deepsouth
deepsouth
A data frame with 18 rows and 14 variables
Davies et al (1941) Deep South: A sociological anthropological study of caste and class. University of Chicago Press.
This function infers K multiple allocation cluster for actor-event network data.
manet(y, K = 2, maxT = 5000, seed = 1, link = "min", verbose = FALSE)
manet(y, K = 2, maxT = 5000, seed = 1, link = "min", verbose = FALSE)
y |
A n x d actor-event adjacency matrix, whereby y_ij is 1 if actor i attended event j – 0 otherwise. |
K |
Number of multiple clusters. Default is set to 2. |
maxT |
Number of MCMC iterations. Default is set to 5000. |
seed |
Random seed. Default is 1. |
link |
Method to combine the parameters of the parent clusters into the parameter for the heir cluster. Default is "min". The alternative is "max". |
verbose |
Set to TRUE if you want to see the steps of the MCMC iterations. Defaults is FALSE. |
A manet object consisting of a list with five outputs:
p.allocation.chain A maxT x n x 2^K array with the posterior probabilities of allocation to the heir clusters.
p.event.chain A maxT x K x d array with the cluster - posterior probabilities of attendance to events.
p.community.chain A maxT x 2^K matrix with the heir cluster proportions.
parent.heir.cluster A 2^K x K matrix, which indicates the relationship between parent and heir clusters.
adj The original adjacency matrix.
proc.time The computational time.
data(deepsouth) ds<-manet(deepsouth,K=2,maxT=100) plot(ds) summary(ds)
data(deepsouth) ds<-manet(deepsouth,K=2,maxT=100) plot(ds) summary(ds)
This function infers K single allocation cluster for actor-event network data.
mixtbern(y, K = 4, maxT = 5000, seed = 1, verbose = FALSE)
mixtbern(y, K = 4, maxT = 5000, seed = 1, verbose = FALSE)
y |
A n x d actor-event adjacency matrix, whereby y_ij is 1 if actor i attended event j – 0 otherwise. |
K |
Number of single clusters. Default is set to 4. |
maxT |
Number of MCMC iterations. Default is set to 5000. |
seed |
Random seed. Default is 1. |
verbose |
Set to TRUE if you want to see the steps of the MCMC iterations. Defaults is FALSE. |
A manet object consisting of a list with five outputs:
p.allocation.chain A maxT x n x K array with the posterior probabilities of allocation to the heir clusters.
p.event.chain A maxT x K x d array with the cluster - posterior probabilities of attendance to events.
p.community.chain A maxT x K matrix with the heir cluster proportions.
adj The original adjacency matrix.
proc.time The computational time.
data(deepsouth) ds<-mixtbern(deepsouth,K=2,maxT=100) plot(ds) summary(ds)
data(deepsouth) ds<-mixtbern(deepsouth,K=2,maxT=100) plot(ds) summary(ds)
The Noordin Top Terrorist Network Data were drawn primarily from "Terrorism in Indonesia: Noordin's Networks," a publication of the International Crisis Group, and include relational data on 79 individuals discussed in that publication. The dataset includes information on these individuals' affiliations with terrorist/insurgent organizations, educational institutions, businesses, and religious institutions.
noordin
noordin
A data frame with 79 rows and 45 variables
45 events attendended: eight organizations, five operations (bombings), eleven training events, two financial meetings, seven logistic meetings, twelve general meetings
79 terrorists, as documented in Everton (2012) but including also the five "lone wolves" (last five rows)
Everton (2012) Disrupting dark networks 34. Cambridge University Press.
This function plots the output of the manet function.
## S3 method for class 'manet' plot(x, seed = 1, layout = layout_nicely, ...)
## S3 method for class 'manet' plot(x, seed = 1, layout = layout_nicely, ...)
x |
A manet object. |
seed |
Random seed. Default is 1. |
layout |
Layout of the network from the igraph package. Default is layout_nicely. |
... |
Additional inputs to the igraph function. |
An actor-event network with events as round circles and actors as squared circles with the different colours corresponding to the identified communities.
data(deepsouth) ds<-manet(deepsouth,K=2,maxT=100) plot(ds)
data(deepsouth) ds<-manet(deepsouth,K=2,maxT=100) plot(ds)
This function prints the output of the manet function
## S3 method for class 'manet' print(x, digits = 3, ...)
## S3 method for class 'manet' print(x, digits = 3, ...)
x |
A manet object. |
digits |
Number of digits. Default is 3. |
... |
Additional arguments to the print function. |
data(deepsouth) ds<-manet(deepsouth,K=2,maxT=100) print(ds)
data(deepsouth) ds<-manet(deepsouth,K=2,maxT=100) print(ds)
This function summarises the output of the manet function
## S3 method for class 'manet' summary(object, digits = 3, ...)
## S3 method for class 'manet' summary(object, digits = 3, ...)
object |
A manet object. |
digits |
Number of digits. Default is 3. |
... |
Additional arguments to the summary function. |
data(deepsouth) ds<-manet(deepsouth,K=2,maxT=100) summary(ds)
data(deepsouth) ds<-manet(deepsouth,K=2,maxT=100) summary(ds)