Simulate and Analyse Social Interaction Models
ThesocialSim R package provides tools to simulateand analyse datasets of social interactions between individuals usinghierarchical Bayesian models implemented in Stan.
It enables users to generate realistic social interaction data, whereindividual phenotypes influence and respond to those of their partners.You can simulate a sampling design by adjusting thenumber ofindividuals, partners, and repeated dyads. The simulationframework allows control over variation inmean trait values,social responsiveness, and social impact and correlation,making it suitable for research ondirect and indirect geneticeffects (DGEs and IGEs) andinteractingphenotypes. See?simulate_data for a full list ofadjustable parameters.
The package also provides analysis functions to evaluate modelperformance in terms of bias and dispersion, using both established andnovel approaches to modelling social effects, includingimpact–responsiveness, variance–partitioning, and trait-basedmodels.
You can install the development version from GitHub using:
# install.packages("remotes")remotes::install_github("RoriWijnhorst/socialSim")# Then load the package:library(socialSim)library(socialSim)# 1. Simulate data. See ?simulate_data for all adjustable parameterssim<-simulate_data(ind =1200,# number of unique focal individualspartners =4,# number of social partners per individualrepeats =1,# number of repeats of dyadsiterations =10,# number of datasets createdB_0 =1,# population interceptpsi =0.3,# population-level responseValpha =0.2,# variance in direct effectsVepsilon =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 resultssummary<-summarise_results(res)print(summary)| Model name | Description |
|---|---|
| I&R.stan | Full impact–responsiveness model |
| VP.stan | Variance-partitioning model |
| Trait.stan | Trait-based model with residual partner effects |
| Trait_only.stan | Simple trait-based model without residual partner effects |
| Trait_RS.stan | Random-slope trait model with residual partner effects |
| Trait_EIV.stan | Errors-in-variable trait model with residual partner effects |