The present paper introduces a data-driven framework for describing the time-varying nature of an SIRD model in the context of COVID-19. By embedding a rolling regression in a mixed integer bilevel nonlinear programming problem, our aim is to provide the research community with a model that reproduces accurately the observed changes in the number of infected, recovered, and death cases, while providing information about the time dependency of the parameters that govern the SIRD model. We propose this optimization model and a genetic algorithm to tackle its solution. Moreover, we test this algorithm with 2020 COVID-19 data from the state of Minnesota and found that our results are consistent both qualitatively and quantitatively, thus proving that the framework proposed is an effective an flexible tool to describe the dynamics of a pandemic.