In 1821, Costa Rica became one of several Central American provinces that jointly declared their independence from Spain. Two years later it joined the United Provinces of Central America, but this federation disintegrated in 1838, at which time Costa Rica proclaimed its sovereignty and independence. Since the late 19th century, only two brief periods of violence have marred the country's democratic development: in 1917-19, Federico Tinoco ruled as a dictator, and in 1948 Jose Figueres led an armed uprising in the wake of a disputed presidential election. Costa Rica has a market economy supported by one of the most peaceful and stable democracies in Latin America. Its economy is based on tourism, agriculture and electronics exports. Its citizens enjoy one of the highest life expectancy levels in the Western hemisphere and better living standards than the country’s neighbors, Nicaragua and Panama.