The Latin American economy is an export-based economy consisting of individual countries in the geographical regions of North America, Central America, South America, and the Caribbean. The socioeconomic patterns of what is now called Latin America were set in the colonial era when the region was controlled by the Spanish and Portuguese empires. Up until independence in the early nineteenth century, colonial Latin American regional economies thrived and worked things out. Many parts of the region had favorable factor endowments of deposits of precious metals, mainly silver, or tropical climatic conditions and locations near coasts that allowed for the development of cane sugar plantations. In the nineteenth century following independence, many economies of Latin America declined. In the late nineteenth century, much of Latin America was integrated into the world economy as an exporter of commodities. Foreign capital investment, construction of infrastructure, such as railroads, growth in the labor sector with immigration from abroad, strengthening of institutions, and expansion of education aided industrial growth and economic expansion. A number of regions have thriving economies, but "poverty and inequality have been deeply rooted in Latin American societies since the early colonial era."