Entropy 2025, 27, 62 16 of 33
 
# Initialize model for single subject
single_subject_model = create_model (
agent , # ActionModels agent object
priors , # Dictionary with parameter priors
observations , # Vector of observations
actions , # Vector of actions
)
 
If we have multiple subjects whose parameters we wish to estimate, we can achieve this
by passing a dataframe object to the same function. Here, we specify which columns are
actions and inputs, as well as which column to use for grouping the specific time series:
 
# Initialize model for multiple subjects
multiple_subjects_model = create_model (
agent , # ActionModels agent
priors , # Dictionary with parameter priors
data ; # Dataframe with data from multiple subjects
grouping_cols = ["ID"], # Column to split dataframe
input_cols = [" observations "], # Columns with observations
action_cols = [" actions "], # Columns with actions
)
 
This model can be used as a normal Turing model object. ActionModels provides a conve-
nience function for doing this with appropriate defaults:
 
results = fit_model (
single_subject_model ; # Model object
n_iterations = 1000 , # Number of iterations
n_chains = 1 # Number of chains
)
 
The output of the fit_model function is an object containing the standard Turing chains,
which we can use to access the chain statistics:
 
# Extract the Chains object
chains = results . chains
# Rename the chains for interpretable parameter names
rename_chains ( chains , model )
 
ActionModels provides a range of convenience functions for behavioural modelling. We can
extract the posterior parameter estimates for each participant, and extract it in a convenient
data frame structure for later processing:
 
# Extract quantities from the chain
agent_parameters = extract_quantities ( single_subject_model , chains )
# Get posterior median
estimates = get_estimates ( agent_parameters )
 
We can also sample parameter values from the prior and plot the posteriors against the priors:
 
# Sample from the prior
prior_chains = sample ( single_subject_model , Prior (), 1000 )
# Plot parameter distribution .
plot_parameter_distribution ( chains , prior_chains )
 
See the documentation for ActionModels at github.com/ilabcode/ActionModels.jl for vari-
ous other functionalities, including modelling how parameters vary across a population,