Iterated inference pipeline for time series analysis with state space models