  Opinion dynamics - the research field dealing with how people's opinions form
and evolve in a social context - traditionally uses agent-based models to
validate the implications of sociological theories. These models encode the
causal mechanism that drives the opinion formation process, and have the
advantage of being easy to interpret. However, as they do not exploit the
availability of data, their predictive power is limited. Moreover, parameter
calibration and model selection are manual and difficult tasks.
  In this work we propose an inference mechanism for fitting a generative,
agent-like model of opinion dynamics to real-world social traces. Given a set
of observables (e.g., actions and interactions between agents), our model can
recover the most-likely latent opinion trajectories that are compatible with
the assumptions about the process dynamics. This type of model retains the
benefits of agent-based ones (i.e., causal interpretation), while adding the
ability to perform model selection and hypothesis testing on real data.
  We showcase our proposal by translating a classical agent-based model of
opinion dynamics into its generative counterpart. We then design an inference
algorithm based on online expectation maximization to learn the latent
parameters of the model. Such algorithm can recover the latent opinion
trajectories from traces generated by the classical agent-based model. In
addition, it can identify the most likely set of macro parameters used to
generate a data trace, thus allowing testing of sociological hypotheses.
Finally, we apply our model to real-world data from Reddit to explore the
long-standing question about the impact of backfire effect. Our results suggest
a low prominence of the effect in Reddit's political conversation.
