Skip to contents

The Trial class and run helpers

The run_trial() and run_trials() functions use the specified partner_selection, interaction, and iterate_model functions to specify these dynamics and iterate the model (an instance of socmod::AgentBasedModel). fixated helps us tell when all agents are performing the same behavior, i.e., the population has fixated.

run_trial()
Trial runner helper function
run_trials()
Run a grid of trial ensembles with parameter metadata
Trial
Trial class for running a single simulation
fixated()
Predicate function: has the model fixated on a single behavior?

Summarise a collection of trial outcomes or prevalence dynamics over model parameters

summarise_prevalence()
Summarize behavior prevalence over time within or across trials
summarise_outcomes()
Summarize outcomes across trials by input parameters

Visualizations

Tools to plot networks, outcomes, and time series

plot_prevalence()
Plot adoption counts of selected behaviors over time Plot adoption counts of selected behaviors (tracked_behaviors) over time.
plot_homophilynet()
Plot homophily network where groups color nodes.
plot_friendship_paradox()
Plot Friendship Paradox Comparison
ggnetplot()
Command that operates like ggplot
SOCMOD_PLOT_PALETTE
Custom color palette for scientific plots

Examples with real-world data

Simple examples of real-world data in socmod.

simulate_feld_1991()
Simulate Feld's 1991 Marketville Network
get_feld_1991_network()
Load Feld's 1991 data.

AgentBasedModel and ModelParameters

Create agent-based models and specify model configuration parameters

make_abm()
Create an AgentBasedModel instance
initialize_agents()
Initialize agents with adaptive and legacy behaviors
make_model_parameters()
Wrapper for initializing new ModelParameters instance.
AgentBasedModel
Agent-based model class
ModelParameters
Overwrite existing auxiliary parameters.
DEFAULT_PARAMETERS
Default parameters to create an agent-based model.

Learning strategy class, make_learning_strategy, and other tools

Functions to pass to run for model iteration in a learning model, and for either success-biased or frequency-biased adaptive learning.

iterate_learning_model()
A generic method for iterating a learning model, setting the current behavior and fitness to be whatever was identified as the next behavior and fitness.
LearningStrategy
LearningStrategy
success_bias_interact()
Success-biased interaction function
success_bias_learning_strategy
Define success-biased learning strategy.
success_bias_select_teacher()
Success-biased teacher selection
frequency_bias_interact()
Interaction function for frequency-biased adaptive learning.
frequency_bias_learning_strategy
Define frequency-biased learning strategy.
frequency_bias_select_teacher()
Frequency biased teacher selection does nothing
contagion_interaction()
Contagion-based interaction
contagion_learning_strategy
Define contagion learning "strategy".
contagion_model_step()
Contagion model step
contagion_partner_selection()
Contagion-based partner selection
dummy_learning_strategy()
Make a dummy learning strategy for mockups and testing.
make_learning_strategy()
Factory function for creating a LearningStrategy
learning_model_step()
More modern v0.1 alias for iterate_learning_model.

Agents and their neighbors

Agents in the model are represented by a number of attributes, with select class methods to track lists of their neighbors.

Agent
Agent class for socmod
Neighbors
Neighbors class

Networks

Create networks, including a growing suite of network construction routines.

make_homophily_network()
Create an undirected asymmetric homophily network.
make_small_world()
Make a small world network.
make_preferential_attachment()
Make a preferential attachment network.
G_NM()
Erdős-Rényi random graph G(N, M).
make_regular_lattice()
Create a regular lattice graph.
plot_homophilynet()
Plot homophily network where groups color nodes.
ggnetplot()
Command that operates like ggplot
add_unique_edge()
Add an undirected edge from v1 to v2 to graph g if it does not already exist.
get_all_possible_edges()
Get all possible edges between node indices 1 to N for either directed or undirected networks.
not_adjacent()
Check two vertices are not adjacent.
compare_friendship_paradox()
Compare Friendship Paradox in a Network
load_igraph_from_csv()
Load an Undirected igraph Object from a CSV Edge List
plot_friendship_paradox()
Plot Friendship Paradox Comparison