Essays in Econometrics of Heterogeneous Agents