Added a new model fitting function that works with moving windows