My dissertation consists of three chapters. In the first chapter, I study housing prices and the comparative advantage of cities. The spatial concentration of economic activity varies substantially across U.S. cities. Cities with larger shares of skill-intensive industries have high housing prices. This chapter proposes a theory of cities that relates housing prices, spatial sorting, and comparative advantage and that is able to analyze policies designed to attract skilled workers to particular regions. Empirically, I find support for my model's predictions about the cross section of cities. By extending the model to study the equilibrium effects of policies, I find that both land regulations and local financial incentives have positive impacts on local productivity and income. The second chapter provides a spatial explanation for cross-city price differences. I document that large cities are more expensive than small cities and the price differences are larger in non-tradable service goods but smaller in tradable manufacturing goods. I propose a spatial model to explain why relative price of non-tradable goods is higher in large cities. I use a monocentric city model with an explicit internal structure of the city. Locations closer to the center have a higher land price but a lower transport or commuting cost. In equilibrium, all agents in the city face this trade-off and choose their optimal location. The model provides a theoretical microeconomic foundation for the large empirical literature on cross-city price differences. The third chapter explores the sudden stops in emerging economies. In emerging economies, about 40% of domestic credits are provided by banks. I explore the role of banks' intermediation in exacerbating the allocative inefficiency. I build a small open economy model in which banks are the only domestic agents with access to international capital markets. Because of the working capital constraint, a shock to the world interest rate during sudden stops will increase the cost of production. This worsens the misallocation and generates an endogenous fall in TFP and output. The model is calibrated to Mexico before the 1995 crisis. It can explain more than half of the fall in TFP.