Rachel Amos remembers growing up in Lagos on a diet of mashed unripe bananas and a homemade pudding of maize, sugar and water. In her eyes, buying food in grocery stores was something only rich people did.

Amos, now a 24-year-old tailor, has moved into the ranks of supermarket patrons. She has turned away from buying from street vendors, choosing instead to shop for items like Nestle SA-made cereal and Unilever’s Close Up toothpaste at a Spar International outlet near the shantytown she lives in.

“Supermarkets are better,” Amos said as her two-year-old daughter Joy wheeled a shopping cart through Spar’s aisles. “They sell original things, it’s neater and there are no flies.”

It’s people like Amos, whose saga captures the potential for growth in Nigerians’ purchasing power, that are prompting foreign investors to look past the militant attacks in the African nation’s northern region and pile into consumer-focused stocks. In Nigeria, they see semblances of the consumer boom that swept through Brazil, China and India over the past decade: an underdeveloped country home to a population of about 170 million that is consistently posting annual economic growth above 6 percent.

Nigeria is just one of several countries experiencing growth in mass consumer markets, and U.S. and European corporations and private equity firms are quickly buying into the opportunities. For example, Emerging Capital Partners, a London-based private equity firm, has raised more than $2 billion for growth capital investment in Africa. Other firms are targeting China and Latin American countries. For more on the cross-border M&A trend, see Mergers & Acquisitions’ July cover story, “5 Buyers Find New Customers Abroad.”

While Nigerian stocks overall are cheap relative to regional peers, consumer shares have been bid up to lofty levels by international buyers including Silk Invest Ltd. and Tundra Fonder AB.

Nigeria’s currency gained 0.1 percent to 162.76 per dollar by 1:28 p.m. in Lagos. The naira has fallen 1.5 percent this year.

Unilever’s Nigerian unit, which sells Lipton tea and Knorr bouillon cubes, trades at more than twice the price-to-earnings ratio of its Rotterdam-based holding company after doubling in market value in the past three years. Lagos-based Nestle Nigeria Plc trades at an 87 percent premium to its Swiss parent, the world’s biggest food company, after almost tripling in value in the past three years.

Heineken NV’s Nigerian Breweries Plc gained 97 percent over that period while Cadbury Nigeria Plc is up almost threefold. Those rallies compare with a 70 percent advance in the Nigeria Stock Exchange’s benchmark index.

“The premium is here to stay,” Anton Schaad, a money manager at St. Galler Kantonalbank AG, which oversees $48 billion, said by e-mail from St. Gallen, Switzerland yesterday. “I don’t really fear a crash.”

While food companies are fairly valued, investors should look into telecommunications, banks and cement makers, according to Zin Bekkali, chief executive officer of Silk Invest in London, which manages $500 million. Nestle Nigeria, Nigerian Breweries and Guaranty Trust Bank Plc are among the top 10 holdings in Silk’s African Lions fund, with Nigeria accounting for 23 percent of its investments, according to the fund’s website.

“We still very much believe in the consumer theme in Africa,” Bekkali said in an e-mailed response to questions on June 20.

Lagos is among five African cities -- including Johannesburg and Cairo -- that will each have more than $25 billion a year in consumer spending by 2020, equivalent to Mumbai and New Delhi, according to a 2010 McKinsey & Co. report.

Nigeria’s gross domestic product per capita has tripled over the past decade, buoyed in part by a surge in oil proceeds that account for 70 percent of government revenue. Still, the most recent poverty survey by the Nigerian statistics agency, published in 2012, shows that 61 percent of Nigerians were living on less than a dollar a day in 2010, up from 52 percent in 2004.

Nigeria, which overtook South Africa as the continent’s largest economy after rebasing its data this year, is battling an Islamist insurgency in its northern states. Boko Haram has bombed markets and government buildings and in April kidnapped more than 200 schoolgirls in a bid to introduce Shariah law over the whole country, which is split between Christians and Muslims.

For consumer companies, it’s not just the attacks that undermine their businesses as they face limited power supply that drives up costs and bad roads, which hamper distribution. Unilever posted a 42 percent slide in first-quarter net income, while at Nestle Nigeria, full-year earnings rose 6 percent to 22.3 billion naira ($137 million).

The weak earnings growth doesn’t justify the companies’ valuations, Esili Eigbe, an analyst at London-based Exotix Ltd., who has sell recommendations on both the shares, said in e- mailed notes last month. Lanre Buluro, head of research at Lagos-based Primera Africa Securities Ltd., recommended investors turn to UAC of Nigeria Plc, which has interests spanning food to real estate, Dangote Sugar Refinery Plc and Flour Mills Nigeria Plc, the country’s biggest miller.

“They sell intermediate products; if you’re going to make bread, you’re going to need flour,” Buluro said. “They sell products that the regular middle-class person can afford. We see that process much more positive long-term.”

Across all of Africa, the middle class is estimated at 350 million people, or more than the number of people living in the U.S., according to the African Development Bank.

The definition of consumers should be broadened beyond the middle class to include everyone living above the poverty line, which is growing at a faster pace, Silk’s Bekkali said. He estimates that over the next 15 years, the number of Africans living above the poverty line will grow by about 500 million.

“The consumer is a longer-term story and an important ingredient in my portfolio,” Mathias Althoff, a money manager at Tundra Fonder, which oversees the equivalent of $180 million, said in an e-mail yesterday from Stockholm. Nigerian banks are trading at attractive valuations as more people move into cities and open accounts, while the opportunities for food companies “are big, especially in Nigeria, where the population is so big,” he said.

Amos, who lives in a wood house she built herself, is anxious for more products to line store shelves as companies including Cape Town-based Shoprite Holdings Ltd., Africa’s largest retailer, expand in Nigeria. She would like to see cheaper meat, more vegetables and less expensive clothes for her child and she’s looking forward to the day she can afford a few extras. She has her eye on a television.

“When I make more money,” Amos said, “I’ll be buying those things I think I can’t afford.”

Additional reporting by Mary Kathleen Flynn