Essays on Granularity and Machine Learning in Macroeconomics