https://github.com/stocnet/goldfish
Actor-oriented and tie-based network event models in R
https://github.com/stocnet/goldfish
dynam network-modelling rem statistical-network-analysis
Last synced: 9 months ago
JSON representation
Actor-oriented and tie-based network event models in R
- Host: GitHub
- URL: https://github.com/stocnet/goldfish
- Owner: stocnet
- License: gpl-3.0
- Created: 2019-09-11T13:16:31.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2025-08-12T13:01:29.000Z (10 months ago)
- Last Synced: 2025-09-07T12:41:37.260Z (9 months ago)
- Topics: dynam, network-modelling, rem, statistical-network-analysis
- Language: R
- Homepage: https://stocnet.github.io/goldfish/
- Size: 6.03 MB
- Stars: 63
- Watchers: 10
- Forks: 13
- Open Issues: 22
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
---
output: github_document
bibliography: inst/REFERENCES.bib
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(goldfish)
```
# goldfish




[](https://github.com/stocnet/goldfish/actions/workflows/R-CMD-check.yml)
[](https://app.codecov.io/gh/stocnet/goldfish?branch=main)
[](https://www.bestpractices.dev/projects/4563)
## Description
The `{goldfish}` package offers a collection of tools designed for applying
statistical models to dynamic network data.
It primarily focus on models for relational event data, namely,
sequences of interactions between actors or entities within a network,
enriched by fine-grained time-stamps information.
Relational event data emerge in various domains,
such as automatically collected data about interactions in
communication and social media research,
social science studies using social sensors,
and archival network studies that provide in-depth details regarding
the timing or sequence of relational actions between nodes.
Currently, the package includes the following models:
- **Dynamic Network Actor Models (DyNAM)**: Investigate relational event models
as an actor-oriented decision process.
- *rate*: Actors compete for creating the next relational event [@hollway2020rate]
- *choice*: The active actor chooses the receiver of the event from among the same [@stadtfeld2017interaction] or a different set of nodes [@hollway2022multimodal]
- *choice_coordination*: The creation of coordination ties as a two-sided
process [@stadtfeld2017coordination]
- **Dynamic Network Actor Models for interactions (DyNAMi)**:
Investigate dynamics of conversation groups and interpersonal interaction in
different social contexts from an actor-oriented perspective
[@hoffman2020groups]
- *rate*: Actors compete for joining or leaving groups
- *choice*: The active actor choose the group to join
- **Relational Event Models (REM)**: Investigate relational event models
as a tie-oriented process [@butts2008relational], taking into account right-censoring [@stadtfeld2017rejoinder].
### Vignettes
For detailed documentation on each model, including usage examples, users are
encouraged to consult the package's vignettes and help files:
- [Getting Started with goldfish (DyNAM and
REM)](https://stocnet.github.io/goldfish/articles/teaching1.html)
- [Coordination ties (DyNAM-choice
coordination)](https://stocnet.github.io/goldfish/articles/teaching2.html)
- [Face to face interactions
(DyNAMi)](https://stocnet.github.io/goldfish/articles/dynami-example.html)
- [Catalog of available
effects](https://stocnet.github.io/goldfish/articles/goldfishEffects.html)
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
+ [Define data objects and link events](#define-data-objects-and-link-events)
+ [Define dependent events](#define-dependent-events)
+ [Model specification and estimation](#model-specification-and-estimation)
- [About](#about)
- [References](#references)
## Installation
You can install `{goldfish}` directly from
[CRAN](https://cran.r-project.org/package=goldfish):
``` r load_package
install.packages("goldfish")
```
To install the development version from GitHub, use the
[remotes](https://cran.r-project.org/package=remotes) package:
- For latest stable version:
`remotes::install_github("stocnet/goldfish", build_vignettes = TRUE)`
- For latest development version:
`remotes::install_github("stocnet/goldfish@develop", build_vignettes = TRUE)`
Or by downloading and install the latest binary releases for all major OSes
-- Windows, Mac, and Linux -- can be found
[here](https://github.com/stocnet/goldfish/releases).
## Usage
Below is a quick-start guide to using the `{goldfish}` package.
The dataset used in this example is an abbreviated version of the
MIT Social Evolution data (`?Social_Evolution`).
### Define data objects and link events
The main data objects required for the analysis are the node set(s)
`make_nodes()` and network(s) `make_network()`.
The node set object contains labels and attributes of the actors in the network.
In contrast, a network object contains the information of past relational events
between actors.
By default, `make_network()` constructs an empty matrix, its dimensions
defined by the length of the nodeset(s).
Data frames containing event data that modify these data objects can be
linked to them using the `link_events()` method.
```{r load_data}
library(goldfish)
data("Social_Evolution")
callNetwork <- make_network(nodes = actors, directed = TRUE) |> # 1
link_events(change_events = calls, nodes = actors) # 2
```
The events data frame, which indicates the time-varying attributes in
the node set, contains the following columns:
- `time`: The time when the attribute changes,
either a `numeric` or `POSIXct` value.
- `node`: The node for which the attribute changes, a `character` value
that matches the `label` variable in the node set.
- `replace`: The new value of the attribute, a `numeric` value.
The events data frame that details the relational events between actors
contains the following columns:
- `time`: The time when the event occurred,
either a `numeric` or `POSIXct` value.
- `sender`: The actor initiating the event, a `character` value
that matches the `label` variable in the node set.
- `receiver`: The actor receiving the event, a `character` value
that matches the `label` variable in the node set.
- `increment` or `replace`: A `numeric` value indicating either the increment
that the relational event represents or the new value.
### Define dependent events
The next step in defining the data objects is to identify the dependent events.
Here we would like to model as the dependent variable the calls
between individuals.
We specify the event data frame and the node set.
```{r dependent_events}
callsDependent <- make_dependent_events(
events = calls, nodes = actors,
default_network = callNetwork
)
```
The final step is to make a goldfish object.
The data object is a goldfish object that contains all the information
needed to estimate the model.
So, it is a container for the dependent events, the networks, and the nodes
containing all the information of the dependent events and any dyadic or
nodal covariate used as explanatory variables in the model.
```{r goldfish_object}
socialEvolutionData <- make_data(
callsDependent, callNetwork, calls, actors
)
```
### Model specification and estimation
We specify our model using the standard R formula format like:
`goldfish_dependent ~ effects(process_state_element)`
We can see which effects are currently available and how to specify them here:
```r
vignette("goldfishEffects")
```
Now to estimate this model, we use the a `?estimate` function.
For the DyNAM model the `estimate_dynam()` function is used.
```{r}
mod00Rate <- estimate_dynam(
callsDependent ~ indeg + outdeg,
sub_model = "rate",
data = socialEvolutionData
)
summary(mod00Rate)
mod00Choice <- estimate_dynam(
callsDependent ~ inertia + recip + trans,
sub_model = "choice",
data = socialEvolutionData
)
summary(mod00Choice)
```
## About
This project is a joint collaboration between the **Social Networks Lab at ETH Zürich** and the **Geneva Graduate Institute**,
and incorporates and supports several sub-projects.
## References