demeaning_algo function

Controls the parameters of the demeaning procedure