  We introduce a new method to accurately and efficiently estimate the
effective dynamics of collective variables in molecular simulations. Such
reduced dynamics play an essential role in the study of a broad class of
processes, ranging from chemical reactions in solution to conformational
changes in biomolecules or phase transitions in condensed matter systems. The
standard Markovian approximation often breaks down due to the lack of a proper
separation of time scales and memory effects must be taken into account. Using
a parametrization based on hidden auxiliary variables, we obtain a generalized
Langevin equation by maximizing the statistical likelihood of the observed
trajectories. Both the memory kernel and random noise are correctly recovered
by this procedure. This data-driven approach provides a reduced dynamical model
for multidimensional collective variables, enabling the accurate sampling of
their long-time dynamical properties at a computational cost drastically
reduced with respect to all-atom numerical simulations. The present strategy,
based on the reproduction of the dynamics of trajectories rather than the
memory kernel or the velocity-autocorrelation function, conveniently provides
other observables beyond these two, including e.g. stationary currents in
non-equilibrium situations, or the distribution of first passage times between
metastable states.
