Entropy 2025, 27, 62 28 of 33
the behaviour (Figure 8). We saw that the estimation successfully captured the difference
between the two groups, and that the α parameter recovered fairly well. Note that the
ability to recover parameters depends on the specific model and task, as well as on the
specific values of the parameters (when α is very high, for example, the behaviour becomes
essentially deterministic; further increases in α would then not have any effect on the
behaviour, and therefore, not be estimable). A subtle issue here is that the parameters
that best explain some data are not necessarily the parameters used to generate those
data. This is because the best parameters are those that maximise the marginal likelihood
of the data (also known as the model evidence); because the model evidence includes
a complexity term, the parameter recovery will often recover parameters that provide a
simpler explanation for the data relative to the parameters used to generate these data.
 
# Extract quantities from the fitted model
agent_parameters = extract_quantities ( model , renamed_posterior_chains )
# Extract posterior estimates
posterior_estimates = get_estimates ( agent_parameters )
 
Figure 8. Results of the parameter recovery study. (A) Estimated parameter values plotted against
the values used to generate the data. (B) Parameter estimates split by the two groups from which the
parameter values of synthetic subjects were sampled.
Finally, there are various metrics for model comparison that might be calculated, as
implemented by various software packages. Here for demonstration, we calculated the
Pareto-Smoothed Importance Sampling approximation to Leave One Out cross-validation
(PSIS-LOO) [59], as implemented by ParetoSmooth.jl [64]:
 
using ParetoSmooth : psis_loo
# Calculate the PSIS LOO
PSIS_loo = psis_loo ( model , results . chains )
 
5. Discussion
We introduce ActiveInference.jl, a novel Julia software package for creating and
using POMDP-based AIF models for simulation and fitting to empirical data, demonstrat-
ing its ease of use on a small parameter study with simulated agents. ActiveInference.jl
makes AIF modelling available in a fast language, equipped with an interface and situated
in an ecosystem oriented specifically towards cognitive and behavioural modelling.
Importantly, the ability to fit models to empirical data with sampling-based methods
provides value to researchers within cognitive modelling and computational psychiatry: it
allows for comparing estimated parameter values between population groups or investigat-