Effects API Reference

This page documents the SAOM effect type hierarchy, the effect interface every effect implements, and the functions for managing an effects set.

The effects are documented by family:

  • Network Effects – structural (basic, triadic, degree-based, isolate, GWESP), covariate, endowment/creation and multiplex effects on a dependent network.
  • Behavior Effects – shape, network influence, degree-based, covariate, interaction and threshold effects on a dependent behavior.
  • Rate Effects – the effects entering the rate function.
  • Two-Mode Effects – effects on a two-mode (bipartite) dependent network.

Effect Type Hierarchy

AbstractEffect

Siena.AbstractEffect — Type
AbstractEffect

Abstract base type for all SAOM effects.

Example

using Siena
ReciprocityEffect(:friendship) isa AbstractEffect      # true
source

NetworkEffect

Siena.NetworkEffect — Type
NetworkEffect <: AbstractEffect

Effect on network dynamics (evaluation or endowment).

Example

using Siena
TransitiveTripletsEffect(:friendship) isa NetworkEffect     # true
source

BehaviorEffect

Siena.BehaviorEffect — Type
BehaviorEffect <: AbstractEffect

Effect on behavior dynamics.

Example

using Siena
LinearShapeEffect(:alcohol) isa BehaviorEffect      # true
source

RateEffect

Siena.RateEffect — Type
RateEffect <: AbstractEffect

Effect on the rate function.

Example

using Siena
BasicRateEffect(:friendship, 1) isa RateEffect      # true
source

Effect Interface

effect_name

Siena.effect_name — Function
effect_name(e::AbstractEffect)

Return the canonical name of the effect.

Example

using Siena
effect_name(OutdegreeEffect(:advice))         # :density (RSiena short name)
source

effect_type

Siena.effect_type — Function
effect_type(e::AbstractEffect)

Return the type of effect (:eval, :endow, :creation, :rate).

Example

using Siena
effect_type(EndowmentEffect(ReciprocityEffect(:advice)))      # :endow
source

target_variable

Siena.target_variable — Function
target_variable(e::AbstractEffect)

Return the name of the variable this effect applies to.

Example

using Siena
target_variable(AverageAlterEffect(:alcohol, :friendship))      # :alcohol
source

interaction_with

Siena.interaction_with — Function
interaction_with(e::AbstractEffect)

Return the name of the covariate/variable this effect interacts with, or nothing.

Example

using Siena
interaction_with(EgoEffect(:friendship, :smoke1))       # :smoke1
source

evaluate_actor

Siena.evaluate_actor — Function
evaluate_actor(effect::AbstractEffect, state::NetworkState, data::SienaData, actor::Int)

Actor actor's evaluation-function component $s_{ki}(x)$ for this effect (RSiena's $s_{ki}$). This is the primitive from which everything else derives:

  • compute_statistic sums it over all actors (the Method-of-Moments target statistic);
  • the generic compute_contribution fallback differences it across a tie toggle (networks) or a behavior step (behavior).

Every concrete effect must implement this method.

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]
w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
state = initialize!(NetworkState(), data, 1)
evaluate_actor(OutdegreeEffect(:advice), state, data, 1)     # actor 1 has 1 tie
source

compute_contribution

Siena.compute_contribution — Function
compute_contribution(effect::AbstractEffect, state::NetworkState,
                    data::SienaData, actor::Int, alter::Int)

Change statistic of the effect for actor actor.

For network effects this is the add-direction change $s_{ki}(x \text{ with tie } i \to j) - s_{ki}(x \text{ without tie})$, independent of whether the tie currently exists (the simulation applies the sign flip for deletions). For behavior effects, alter encodes the direction (±1) and the value is $s_{ki}(z_i + d) - s_{ki}(z_i)$.

A generic fallback based on evaluate_actor is provided; effects may add a closed-form method for speed (verified against the fallback in the test suite).

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]
w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
state = initialize!(NetworkState(), data, 1)
compute_contribution(ReciprocityEffect(:advice), state, data, 2, 1)   # 1.0: 1 -> 2 exists
source

compute_statistic

Siena.compute_statistic — Function
compute_statistic(effect::AbstractEffect, state::NetworkState, data::SienaData)

Compute the network statistic associated with this effect: $s_k(x) = \sum_i s_{ki}(x)$ (see evaluate_actor).

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]
w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(OutdegreeEffect(:advice), state, data)     # 3.0 ties at wave 2
source

rate_score

Siena.rate_score — Function
rate_score(e::RateEffect, state::NetworkState, data::SienaData, actor::Int)

Score $r_{ki}(x)$ of the rate effect for a given actor. The effect's multiplicative contribution to the actor's rate is $\exp(\alpha_k r_{ki})$; the same score defines the effect's Method-of-Moments statistic $\sum_i r_{ki} d_i$ (with $d_i$ the amount of change by actor $i$).

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]
w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
state = initialize!(NetworkState(), data, 1)
rate_score(OutdegreeRateEffect(:advice, :advice, 1), state, data, 1)    # 1.0
source

compute_rate

Siena.compute_rate — Function
compute_rate(e::RateEffect, θ::Float64, state::NetworkState,
            data::SienaData, actor::Int)

Multiplicative rate factor $\exp(\theta \cdot r_{ki})$ of a (non-basic) rate effect for a given actor.

source

Effects Management Functions

get_effects

Siena.get_effects — Function
get_effects(data::SienaData)

Create the effects table for the data — the counterpart of RSiena's getEffects().

Every effect Siena.jl implements that is defined for a dependent variable is registered for it, under its RSiena short name where it has one. Which effects are included follows RSiena's getEffects(), so the default model is RSiena's:

Dependent variableIncluded by default
directed one-mode networkbasic rate of every period, outdegree (RSiena density), recip
undirected networkbasic rates, outdegree (density)
two-mode networkbasic rates, outdegree (density)
behaviourbasic rates, linear, and quad when the observed range (maximum minus minimum over all waves) is at least 2

As in RSiena, a network whose every period only adds ties (or only drops them) gets no outdegree effect at all, and a behaviour whose every period only rises (or only falls) gets no linear effect; see DependentNetwork and DependentBehavior on up-only and down-only periods. Every other effect is registered but excluded. Including a default effect again with include_effects! changes nothing, and include_effects!(...; include=false) removes one from the model (RSiena's includeEffects(..., include = FALSE)).

Which effects exist depends on the kind of variable, following RSiena's effect groups:

  • directed one-mode networks: outdegree (RSiena density), recip, transTrip, transMedTrip, transRecTrip, cycle3, transTies, between, nbrDist2, denseTriads, gwespFF/gwespBB/gwespFB/gwdspFF, inPop, inPopSqrt, outPop, outPopSqrt, inAct, inActSqrt, outAct, outActSqrt, outTrunc, isolateNet, outIso, …;
  • undirected (symmetric) networks (DependentNetwork(...; directed=false)): outdegree (degree), transTriads, transTies, between, nbrDist2, gwesp, inPop, inPopSqrt, outAct, outActSqrt, degPlus, outTrunc, isolateNet, outIso;
  • two-mode networks: the TwoModeEffects (outdegree2, fourCycles, …), never a one-mode effect;
  • behaviour: linear, quad, the influence effects (avAlt, avSim, totAlt, …) for each network, effFrom for each actor covariate;
  • rate: one basic rate per period, plus outRate, inRate, RateX, ….

Effects that condition on an attribute come once per actor covariate and once per co-evolving dependent behaviour (network selection on the behaviour), with the attribute's name in the short name: egosmoke1, altalcohol, simalcohol, … (RSiena's egoX/altX/simX with interaction1; include_effects! also accepts the RSiena spelling with interaction1=). Effects without an RSiena counterpart are marked "(Siena.jl)" in their display name; the effects guide has the full concordance table.

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]; w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
add_covariate!(data, ConstantCovariate(:age, [30, 40, 50]))
effects = get_effects(data)
"transTrip" in [e.shortname for e in effects]      # true
"egoage" in [e.shortname for e in effects]         # true
[e.shortname for e in get_included_effects(effects)]   # ["rate1", "outdegree", "recip"]
source

include_effects!

Siena.include_effects! — Function
include_effects!(effects::SienaEffects, variable::Symbol, effect_names::Vector{Symbol};
                interaction1=nothing, initial_value=nothing, fix::Bool=false,
                test::Bool=false, strict::Bool=true, include::Bool=true)

Include effects in the model by short name. Counterpart of R's includeEffects().

get_effects already includes RSiena's default effects (outdegree and recip for a directed network, linear and quad for a behaviour, …); naming one of them again changes nothing. include=false removes the named effects from the model instead, as RSiena's includeEffects(..., include = FALSE) does.

An effect is selected by its Siena.jl short name as listed by get_effects (:outdegree, :transTrip, :egosmoke1, :avAltfriendship, …) or by its RSiena short name together with RSiena's interaction1 ([:egoX, :altX, :simX]; interaction1=:smoke1, [:avAlt]; interaction1=:friendship, :density for :outdegree).

An effect name that matches no entry for variable is an error: a model that silently drops an effect the analyst asked for is not reproducible. The error lists the names that are available for the variable, which also catches typos and effects that do not exist for the kind of variable (e.g. recip on an undirected network). Pass strict=false to warn and skip unmatched names instead.

Arguments

  • effects: The effects object
  • variable: Name of the dependent variable
  • effect_names: Vector of effect short names to include
  • interaction1: RSiena's interaction1 (the covariate, behaviour or network the effect refers to) when selecting by RSiena short name
  • initial_value: Initial parameter value (nothing keeps the entry's current value)
  • fix: Hold the parameter fixed at its initial value instead of estimating it
  • test: Request a score-type test of the fixed value (RSiena's test=TRUE, Schweinberger 2012). Requires fix=true; the fit then reports the test in result.score_test (see SienaScoreTest)
  • strict: Throw (default) rather than warn when a requested effect does not exist
  • include: false excludes the named effects (their fix/test flags are cleared) instead of including them

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]; w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
add_covariate!(data, ConstantCovariate(:age, [30, 40, 50]))
effects = get_effects(data)
include_effects!(effects, :advice, [:egoX, :altX]; interaction1=:age)  # RSiena spelling
include_effects!(effects, :advice, [:transTrip]; fix=true, test=true)  # score test
length(get_included_effects(effects))      # 6: a rate, outdegree, recip and 3 added
include_effects!(effects, :advice, [:recip]; include=false)            # opt out
length(get_included_effects(effects))      # 5
source

Interactions

Siena.InteractionEffect — Type
InteractionEffect(variable, components) <: NetworkEffect

Interaction of two or three network effects of the same dependent network — RSiena's user-defined interaction (includeInteraction, short name unspInt). Create it with include_interaction!.

As in RSiena it is an elementary effect: the change statistic of the tie $i \to j$ is the product of the components' change statistics. The target statistic is RSiena's: with all components but one of type ego, the product of the ego components' tie statistics and the remaining component's actor statistic; otherwise $\sum_j x_{ij} \prod_k t_k(i, j)$ with $t_k$ the components' tie statistics.

RSiena's rules decide which effects may interact. Each effect is of interaction type ego (egoX, egoSqX, inAct, inActSqrt; density on an undirected network), dyadic (density, recip, inPop, outPop, the GWESP effects, altX, simX, sameX, diffX, higher, egoXaltX, X, …) or neither (transTrip, cycle3, outAct, …). A two-way interaction needs at least one ego effect, or two dyadic effects; a three-way interaction needs at least two ego effects, or three ego/dyadic effects.

Example

using Siena, NetworkCore
s50 = load_dataset(:s50)
data = siena_data()
add_dependent!(data, DependentNetwork(:friendship, s50.friendship))
add_covariate!(data, ConstantCovariate(:smoke1, s50.smoke[:, 1]))
effects = get_effects(data)
include_interaction!(effects, :friendship, :egosmoke1, :recip)
entry = only(e for e in effects if e.effect isa InteractionEffect)
entry.shortname                       # "egosmoke1_x_recip"
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(entry.effect, state, data)
source
Siena.BehaviorProductEffect — Type
BehaviorProductEffect(variable, components) <: BehaviorEffect

Interaction of two or three behaviour effects of the same dependent behaviour — RSiena's user-defined behaviour interaction (includeInteraction, short name behUnspInt). Create it with include_interaction!.

Following RSiena, with $\tilde z_i$ the centred behaviour: the change statistic for a step $d$ is $\prod_k \Delta_k / d^{K-1}$ ($\Delta_k$ the components' change statistics) and the actor statistic is $\prod_k s_{ki} / \tilde z_i^{K-1}$ (0 where $\tilde z_i = 0$). At most one component may be of an interaction type other than RSiena's OK (OK: linear, avAlt, totAlt, avInAlt, avRecAlt, totInAlt, avAltDist2, indeg, outdeg, recipDeg, effFrom; not OK: quad, avSim, totSim, threshold).

Example

using Siena, NetworkCore
s50 = load_dataset(:s50)
data = siena_data()
add_dependent!(data, DependentNetwork(:friendship, s50.friendship))
add_dependent!(data, DependentBehavior(:alcohol, [s50.alcohol[:, w] for w in 1:3]))
add_covariate!(data, ConstantCovariate(:smoke1, s50.smoke[:, 1]))
effects = get_effects(data)
include_interaction!(effects, :alcohol, :avAltfriendship, :effFromsmoke1)
entry = only(e for e in effects if e.effect isa BehaviorProductEffect)
state = initialize!(NetworkState(), data, 2; period=1)
compute_statistic(entry.effect, state, data)
source

include_interaction!

Siena.include_interaction! — Function
include_interaction!(effects::SienaEffects, variable::Symbol,
                     effect1::Symbol, effect2::Symbol[, effect3::Symbol];
                     interaction1=nothing, initial_value=0.0, fix=false,
                     test=false)

Add (and include) a user-defined interaction of two or three effects of variable — RSiena's includeInteraction(). The components are named like in include_effects!: by Siena.jl short name (:egosmoke1, :recip), or by RSiena short name with interaction1 given as a tuple aligned with the effects (:egoX, :recip; interaction1=(:smoke1, nothing)). The components themselves need not be included in the model (as in RSiena, though including the main effects is usually advisable).

For a network the result is an InteractionEffect, for a behaviour a BehaviorProductEffect; both follow RSiena's definitions (product of the change statistics) and RSiena's rules for which effects may interact — a combination RSiena refuses is an ArgumentError here too. The new entry's short name joins the components' with _x_ and is returned in the effects object.

Example

using Siena, NetworkCore
s50 = load_dataset(:s50)
data = siena_data()
add_dependent!(data, DependentNetwork(:friendship, s50.friendship))
add_covariate!(data, ConstantCovariate(:smoke1, s50.smoke[:, 1]))
effects = get_effects(data)
include_effects!(effects, :friendship, [:outdegree, :recip, :egosmoke1])
include_interaction!(effects, :friendship, :egosmoke1, :recip)
include_interaction!(effects, :friendship, :egoX, :transTrip;
                     interaction1=(:smoke1, nothing))        # RSiena spelling
[e.shortname for e in get_objective_effects(effects)]
source

getincludedeffects

Siena.get_included_effects — Function
get_included_effects(effects::SienaEffects)

Return vector of included effect entries.

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]
w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
effects = get_effects(data)
include_effects!(effects, :advice, [:outdegree, :recip])
[e.shortname for e in get_included_effects(effects)]   # ["rate1", "outdegree", "recip"]
source

getrateeffects

Siena.get_rate_effects — Function
get_rate_effects(effects::SienaEffects)

Return vector of rate effect entries.

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]
w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
effects = get_effects(data)
include_effects!(effects, :advice, [:outdegree, :recip])
[e.shortname for e in get_rate_effects(effects)]   # ["rate1"]
source

getobjectiveeffects

Siena.get_objective_effects — Function
get_objective_effects(effects::SienaEffects)

Return vector of objective function effect entries (network and behavior effects).

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]
w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
effects = get_effects(data)
include_effects!(effects, :advice, [:outdegree, :recip])
[e.shortname for e in get_objective_effects(effects)]   # ["outdegree", "recip"]
source

effects_table

Siena.effects_table — Function
effects_table(effects::SienaEffects)

Return a DataFrame representation of the effects.

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]
w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
effects = get_effects(data)
include_effects!(effects, :advice, [:outdegree, :recip])
effects_table(effects)[:, [:shortname, :include]]
source

validate_effects

Siena.validate_effects — Function
validate_effects(data::SienaData, effects::SienaEffects) -> Nothing

Check that every included effect is defined for the variables it refers to, and throw an ArgumentError naming the first one that is not. fit_siena, simulate_saom and the GOF functions call it, so a model that does not make sense for its data is refused rather than computed on the wrong index set:

  • network effects must target a dependent network of a kind they are defined for (directed / undirected / two-mode, following RSiena's effect groups — e.g. recip and transTrip only exist for directed networks, transTriads only for undirected ones, and one-mode effects never apply to a two-mode network);
  • behaviour effects must target a dependent behaviour, and the network they read must be of a supported kind;
  • covariates and other dependent variables the effect reads must exist and be of the right type (actor vs dyadic covariate, matching dimensions).

Example

using Siena
u1 = [0 1 0; 1 0 1; 0 1 0]
u2 = [0 1 1; 1 0 0; 1 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:friends, [u1, u2]; directed=false))
effects = get_effects(data)                      # includes density (outdegree)
include_effects!(effects, :friends, [:density, :transTriads])
validate_effects(data, effects)          # passes: both are symmetric-network effects
source

Internal Effects Helpers

Siena.add_effect! — Function
add_effect!(effects::SienaEffects, entry::EffectEntry)

Add an effect entry to the effects table. get_effects registers every effect with its default parameters; use add_effect! for an effect with a non-default internal parameter (RSiena's setEffect(..., parameter=)) or for a user-defined effect type.

Example

using Siena
w1 = [0 1 0; 0 0 1; 1 0 0]; w2 = [0 1 1; 0 0 1; 0 0 0]
data = siena_data()
add_dependent!(data, DependentNetwork(:advice, [w1, w2]))
effects = get_effects(data)
# outTrunc with c = 2 (RSiena: setEffect(eff, outTrunc, parameter = 2))
add_effect!(effects, EffectEntry(OutdegreeTruncEffect(:advice; c=2);
                                 shortname="outTrunc2", include=true))
source