Two-Mode Effects

Effects on a two-mode (bipartite) dependent network, where senders and receivers are drawn from different node sets.

See the Effects API Reference for the type hierarchy and the effect interface these all implement.

Two-Mode Network Effects

TwoModeEffect

Siena.TwoModeEffect — Type
TwoModeEffect <: NetworkEffect

Abstract type for two-mode network effects.

Example

using Siena
FourCyclesEffect(:attends) isa TwoModeEffect      # true
source

TwoModeOutdegreeEffect

Siena.TwoModeOutdegreeEffect — Type
TwoModeOutdegreeEffect <: TwoModeEffect

Outdegree (number of events attended): $s_i = x_{i+}$.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModeOutdegreeEffect(:attends), state, data)
source

TwoModeIndegreeEffect

Siena.TwoModeIndegreeEffect — Type
TwoModeIndegreeEffect <: TwoModeEffect

Event popularity: $s_i = \sum_e x_{ie} f(x_{+e})$ with $f$ identity or sqrt.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModeIndegreeEffect(:attends), state, data)
source

FourCyclesEffect

Siena.FourCyclesEffect — Type
FourCyclesEffect <: TwoModeEffect

Four-cycles of a two-mode network: $s_i = \sum_{o \ne i} \binom{s_{io}}{2}$ where $s_{io}$ is the number of shared events of actors $i$ and $o$; the change statistic of a tie is the number of four-cycles it closes. RSiena: cycle4 (internal parameter 1) for bipartite networks; the target statistic is the number of four-cycles (half the actor sum), as RSiena's. Its short name was fourCycles before 0.2 (still accepted by include_effects!).

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(FourCyclesEffect(:attends), state, data)
source

SharedEventsEffect

Siena.SharedEventsEffect — Type
SharedEventsEffect <: TwoModeEffect

Total shared events with other actors: $s_i = \sum_{o \ne i} f(s_{io})$ with $f$ identity or sqrt.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(SharedEventsEffect(:attends), state, data)
source

GWESPTwoModeEffect

Siena.GWESPTwoModeEffect — Type
GWESPTwoModeEffect <: TwoModeEffect

Geometrically weighted shared events: $s_i = \sum_{o \ne i} (1 - (1 - e^{-\alpha})^{s_{io}})$.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(GWESPTwoModeEffect(:attends), state, data)
source

TwoModeEgoEffect

Siena.TwoModeEgoEffect — Type
TwoModeEgoEffect <: TwoModeEffect

Actor covariate effect on event attendance: $s_i = v_i x_{i+}$.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModeEgoEffect(:attends, :age), state, data)
source

TwoModeEventEffect

Siena.TwoModeEventEffect — Type
TwoModeEventEffect <: TwoModeEffect

Event attribute effect: $s_i = \sum_e x_{ie} w_{ie}$ using a dyadic covariate whose rows are actors and columns are events.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModeEventEffect(:attends, :fee), state, data)
source

TwoModeSameEffect

Siena.TwoModeSameEffect — Type
TwoModeSameEffect <: TwoModeEffect

Attendance with same-covariate others: $s_i = \sum_e x_{ie} \#\{o \ne i : x_{oe} = 1, |v_i - v_o| < 0.5\}$.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModeSameEffect(:attends, :age), state, data)
source

TwoModeSimilarityEffect

Siena.TwoModeSimilarityEffect — Type
TwoModeSimilarityEffect <: TwoModeEffect

Covariate similarity with co-attendees: $s_i = \sum_e x_{ie} \sum_{o \ne i} x_{oe} \, \text{sim}_{io}$.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModeSimilarityEffect(:attends, :age), state, data)
source

TwoModeActivityEffect

Siena.TwoModeActivityEffect — Type
TwoModeActivityEffect <: TwoModeEffect

Co-attendee activity: $s_i = \sum_e x_{ie} \sum_{o \ne i} x_{oe} f(x_{o+})$.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModeActivityEffect(:attends), state, data)
source

TwoModePopularityAltEffect

Siena.TwoModePopularityAltEffect — Type
TwoModePopularityAltEffect <: TwoModeEffect

Actors with high outdegree attend popular events: $s_i = x_{i+} \sum_e x_{ie} (x_{+e} - 1)$.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModePopularityAltEffect(:attends), state, data)
source

TwoModeTransitiveClosureEffect

Siena.TwoModeTransitiveClosureEffect — Type
TwoModeTransitiveClosureEffect <: TwoModeEffect

Closure of four-paths: $s_i = \sum_{o \ne i} s_{io} (s_{io} - 1)$ (twice the four-cycle count).

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModeTransitiveClosureEffect(:attends), state, data)
source

TwoModeActorAssortativityEffect

Siena.TwoModeActorAssortativityEffect — Type
TwoModeActorAssortativityEffect <: TwoModeEffect

Outdegree assortativity with co-attendees: $s_i = \sum_e x_{ie} \sum_{o \ne i} x_{oe} \, x_{i+} x_{o+}$.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModeActorAssortativityEffect(:attends), state, data)
source

TwoModeWithinEffect

Siena.TwoModeWithinEffect — Type
TwoModeWithinEffect <: TwoModeEffect

Attendance of events within the actor's own setting: $s_i = \sum_e x_{ie} I(|v_i - w_{ie}| < 0.5)$ where $v$ is the actor setting covariate and $w$ is a dyadic covariate whose $(i, e)$ entry gives the setting of event $e$ (typically constant across rows). Both are compared as given: the covariates' centring is undone, so actor and event settings use the same codes. A Siena.jl effect with no RSiena counterpart.

Example

using Siena
x1 = [1 0 1 0; 0 1 1 0; 1 1 0 0; 0 0 1 1; 1 0 0 1]
x2 = [1 1 1 0; 0 1 1 0; 1 1 0 1; 0 0 1 1; 0 0 1 1]
data = siena_data()
add_nodeset!(data, NodeSet(5))
add_nodeset!(data, NodeSet(4; id=:events))
add_dependent!(data, DependentNetwork(:attends, [x1, x2]; type=:twomode, nodeset2=:events))
add_covariate!(data, ConstantCovariate(:age, [20, 30, 40, 50, 60]))
add_covariate!(data, ConstantCovariate(:club, [1, 1, 2, 2, 1]))
add_covariate!(data, ConstantDyadCovariate(:fee, [Float64(e) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
add_covariate!(data, ConstantDyadCovariate(:eventclub, [Float64(1 + (e > 2)) for i in 1:5, e in 1:4];
                                           nodeset2=:events))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(TwoModeWithinEffect(:attends, :club, :eventclub), state, data)
source