library(mFLICA)

Section 4.1. Inferring following relations

leader<-mFLICA::TS[1,1:100,] #index2
follower<-mFLICA::TS[2,1:100,] #index1
obj<-dtw(x=follower,y=leader,k=TRUE)

Figure 2: (a)

ref <- leader[,1] #window(aami3a, start = 0, end = 2)
query <- follower[,1] #window(aami3a, start = 2.7, end = 5)
plot(dtw(query, ref, k = TRUE), type = "two", off = 1, match.lty = 2, match.indices = 100, xlab= "Time",  ylab= "Follower: x-axis positions")
mtext("Leader: x-axis positions", side = 4)
legend("left", c("follower", "leader"),
       col = c("black", "red"), lty = c(1, 2))

Figure 2: (b)

lcm <- obj$localCostMatrix
image(x = 1:nrow(lcm), y = 1:ncol(lcm), lcm, ylab = "Leader Time", xlab = "Follower Time")
#text(row(lcm), col(lcm), label = lcm)
lines(obj$index1, obj$index2)
lines(1:100,col="blue")

Example 4.1

obj$index1 - obj$index2
mean( obj$index1 - obj$index2) # out: 8.238462
mean(sign( obj$index1 - obj$index2) ) # out: 0.9846154
mFLICA::followingRelation(Y=follower,X=leader,lagWindow=0.1)$follVal

Section 4.2. Inferring following networks

Example 4.2

library("mFLICA")
mat1<-followingNetwork(TS=TS[,1:60,],sigma=0.5)$adjWeightedMat
mat2<-followingNetwork(TS=TS[,61:120,],sigma=0.5)$adjWeightedMat
getADJNetDen(mat1)
getADJNetDen(mat2)

Figure 3

library("lattice")
rownames(mat1) <- paste(  c(1:30) , sep=" ")
colnames(mat1) <- paste(  c(1:30) , sep=" ")
rownames(mat2) <- paste(  c(1:30) , sep=" ")
colnames(mat2) <- paste(  c(1:30) , sep=" ")

levelplot(mat1,xlab="Follower IDs", ylab="Leader IDs",
         # col.regions=heat.colors(100),
          main = "Time interval [1,60]"
          )
levelplot(mat2,xlab="Follower IDs", ylab="Leader IDs",
         # col.regions=heat.colors(100),
          main = "Time interval [61,120]"
          )

Example 4.3: Dynamic following network

library(mFLICA)
obj1<-getDynamicFollNet(TS=mFLICA::TS[,1:800,],timeWindow=60,timeShift = 6,sigma=0.5)
obj1$dyNetWeightedMat[19,1,150]
obj1$dyNetWeightedDensityVec[150]

Figure 4:plot network density

 plotMultipleTimeSeries(TS=obj1$dyNetWeightedDensityVec, strTitle="Network Dnesity")

Section 4.3.: Inferring leadership dynamics

Example 4.4

library(mFLICA)
mat1 <-followingNetwork(TS=TS[,25:45,], sigma =0.95)$adjBinMat
out<-getFactions(adjMat=mat1)
out$leaders

Leader

L1<-out$leaders[1] # leader ID1
out$factionMembers[[1]]
out$factionSizeRatio[L1]
L2<-out$leaders[2] # leader ID11
out$factionMembers[[2]]
out$factionSizeRatio[L2]

Example 4.5

Inferring faction dynamics

library(mFLICA)
obj1<-mFLICA(TS=mFLICA::TS[,1:800,],timeWindow=60,timeShift = 6,sigma=0.5)

Visualizing result

plotMultipleTimeSeries(TS=obj1$factionSizeRatioTimeSeries, strTitle="Faction Size Ratios")


DarkEyes/mFLICA documentation built on June 11, 2025, 6:02 p.m.