Summary. An important epidemiological problem is to estimate the decay through time of immunity following infection. For this purpose, we propose a semiparametric time series epidemic model that is based on the mechanism of the susceptible–infected–recovered–susceptible system to analyse complex time series data. We develop an estimation method for the model. Simulations show that the approach proposed can capture the non-linearity of epidemics as well as estimate the decay of immunity. We apply our approach to influenza in France and the Netherlands and show a rapid decline in immunity following infection, which agrees with recent spatiotemporal analyses.