Essays in new-keynesian macroeconomics and monetary policy with heterogeneous agents