# mFLICA_demo

## C. Amornbunchornvej

### 2025-05-28

# EXAMPLE: Simple Simulation

In the first step, we have a build-in dataset of 30-individual time series where ID1, ID2, ID3 are leaders at coordination intervals: [1,200], [201,400], and [401,600] respectively. These individuals move within two-dimensional space. Time series of each individual represents a sequence of coordinate (x,y) at each time step. A leader is an initiator who initiates coordinated movement that everyone in a faction follows.

    library(mFLICA)

    # mFLICA::TS[i,t,d] is an element of ith time series at time t in the dimension d. Here, we have only two dimensions: x and y. The time series length is 800, so, t is in the range [1,800]. There are 30 individuals, so, i is in the range [1,30].
    plotMultipleTimeSeries(TS=mFLICA::TS[,,1],strTitle="x axis")

    plotMultipleTimeSeries(TS=mFLICA::TS[,,2],strTitle="y axis")

    ?followingRelation

To make it short, we choose only the interval [1,200] that ID1 is a leader. The framework is used to analyze the data below.

    obj1<-mFLICA(TS=mFLICA::TS[,1:200,],timeWindow=60,sigma=0.5)

    ## [1] "TW60 shift-6 - t1"
    ## [1] "TW60 shift-6 - t7"
    ## [1] "TW60 shift-6 - t13"
    ## [1] "TW60 shift-6 - t19"
    ## [1] "TW60 shift-6 - t25"
    ## [1] "TW60 shift-6 - t31"
    ## [1] "TW60 shift-6 - t37"
    ## [1] "TW60 shift-6 - t43"
    ## [1] "TW60 shift-6 - t49"
    ## [1] "TW60 shift-6 - t55"
    ## [1] "TW60 shift-6 - t61"
    ## [1] "TW60 shift-6 - t67"
    ## [1] "TW60 shift-6 - t73"
    ## [1] "TW60 shift-6 - t79"
    ## [1] "TW60 shift-6 - t85"
    ## [1] "TW60 shift-6 - t91"
    ## [1] "TW60 shift-6 - t97"
    ## [1] "TW60 shift-6 - t103"
    ## [1] "TW60 shift-6 - t109"
    ## [1] "TW60 shift-6 - t115"
    ## [1] "TW60 shift-6 - t121"
    ## [1] "TW60 shift-6 - t127"
    ## [1] "TW60 shift-6 - t133"
    ## [1] "TW60 shift-6 - t139"
    ## [1] "Finding factions:t1"
    ## [1] "Finding factions:t61"
    ## [1] "Finding factions:t121"
    ## [1] "Finding factions:t181"

The network densities of a dynamic following network is shown below.

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

We plot time series of faction size ratios of all leaders

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