MyNixOS website logo
Description

Simulate and Analyse Social Interaction Data.

Provides tools to simulate and analyse datasets of social interactions between individuals using hierarchical Bayesian models implemented in Stan. The package interacts with Stan via 'cmdstanr' (available from <https://mc-stan.org/r-packages/>) or 'rstan', depending on user setup. Users can generate realistic interaction data where individual phenotypes influence and respond to those of their partners, with control over sampling design parameters such as the number of individuals, partners, and repeated dyads. The simulation framework allows flexible control over variation and correlation in mean trait values, social responsiveness, and social impact, making it suitable for research on interacting phenotypes and on direct and indirect genetic effects ('DGEs' and 'IGEs'). The package also includes functions to fit and compare alternative models of social effects, including impact–responsiveness, variance–partitioning, and trait-based models, and to summarise model performance in terms of bias and dispersion. For more details on the study of social interactions and impact-responsiveness, see Moore et al. (1997) <doi:10.1111/j.1558-5646.1997.tb01458.x> and de Groot et al. (2022) <doi:10.1016/j.neubiorev.2022.104996>.

socialSim GitHub

Simulate and Analyse Social Interaction Models

R-CMD-check

The socialSim R package provides tools to simulate and analyse datasets of social interactions between individuals using hierarchical Bayesian models implemented in Stan.

It enables users to generate realistic social interaction data, where individual phenotypes influence and respond to those of their partners. You can simulate a sampling design by adjusting the number of individuals, partners, and repeated dyads. The simulation framework allows control over variation in mean trait values, social responsiveness, and social impact and correlation, making it suitable for research on direct and indirect genetic effects (DGEs and IGEs) and interacting phenotypes. See ?simulate_data for a full list of adjustable parameters.

The package also provides analysis functions to evaluate model performance in terms of bias and dispersion, using both established and novel approaches to modelling social effects, including impact–responsiveness, variance–partitioning, and trait-based models.


🧭 Installation

You can install the development version from GitHub using:

# install.packages("remotes")
remotes::install_github("RoriWijnhorst/socialSim")
# Then load the package:
library(socialSim)

⚙️ Example workflow:

library(socialSim)

# 1. Simulate data. See ?simulate_data for all adjustable parameters
sim <- simulate_data(
  ind = 1200,           # number of unique focal individuals
  partners = 4,         # number of social partners per individual
  repeats = 1,          # number of repeats of dyads   
  iterations = 10,      # number of datasets created    
  B_0 = 1,              # population intercept
  psi = 0.3,            # population-level response
  Valpha = 0.2,         # variance in direct effects
  Vepsilon = 0.1        # variance in residual partner effects
)

# 2. Fit a Stan model. For the analyses, cmdstanr or rstan needs to be installed.
# using cmdstanr will be faster, since it runs model in parallel on different cores of your PC.
res <- run_model(sim, model = "Trait.stan", iter=2000, cores = 6)

# 3. Summarise results
summary <- summarise_results(res)
print(summary)

🧪 Available IGE models

Model nameDescription
I&R.stanFull impact–responsiveness model
VP.stanVariance-partitioning model
Trait.stanTrait-based model with residual partner effects
Trait_only.stanSimple trait-based model without residual partner effects
Trait_RS.stanRandom-slope trait model with residual partner effects
Trait_EIV.stanErrors-in-variable trait model with residual partner effects.
Metadata

Version

0.1.6

License

Unknown

Platforms (76)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows