LONDON -- John Maynard Keynes, who vies with Adam Smith for the title of Britain's most influential economist, famously said that the economy runs on "animal spirits" -- those emotions that affect human behavior and thus consumer and business confidence.

When people are confident, consumers think nothing about buying more goods, businesses are happy to invest in new projects, and everything seems rosy. But once confidence starts to wane, this damages the economy, as the last few years have shown, because it causes consumers and businesses to tighten their belts and rein in their spending.

Investors should be aware that some sectors of the economy are strongly affected by changes in business and consumer confidence, while others -- notably tobacco and alcohol -- are generally unaffected and tend to do well even in the gloomiest of times.

A new car? No, thanks
The car industry is one of the first to suffer when confidence falls. That's because it's an easy decision to keep your old car on the road, rather than buying a new one, when you're uncertain about the future.

In the last recession, many governments instituted "cash for clunkers" programs to encourage people to replace their cars because new car sales had fallen off a cliff. They argued that this was an "investment" to protect businesses and jobs, but a cynic like me, who follows the Austrian school of economics, believes that programs like these only make things worse. That's because, in doing so, politicians are misallocating resources to protect influential and inefficient vested interests (the motor industry), and they use Keynes' theory about running budget deficits to boost aggregate demand during a recession as an intellectual crutch. They also forgot about the other part of Keynes' theory about deficit spending, which requires that you run a budget surplus in the good times!

To my mind, society would have been much better off if the cash for clunkers money had instead been left in the taxpayers' pockets. Should anyone want to point out that I am a hypocrite because I invest in companies like Morgan Sindall, which happen to be large beneficiaries of Keynesian spending programmes, I'm more than happy to admit to being one!

Safe as houses?
Housing is another industry that thrives upon consumer confidence. While we all need a place to sleep, in times of uncertainty most people don't want to take on additional debt in order to move to a new house. So house sales drop off dramatically, as does the level of new builds, which harms the construction sector. This has a knock-on effect upon the other industries that rely upon people moving, including moving services and furniture.

The situation today is a far cry from the days when people thought nothing about taking out 125% mortgages based on large multiplies of their salary. People didn't just take out these loans because the banks and building societies were daft enough to lend to anyone with a pulse; they were supremely confident that their incomes would continue to rise and that property prices would never fall.

Naturally, with the recession and the fall in house prices, the interest in housing has tailed off somewhat. You can see this reflected in the TV schedules, as many television programs about buying houses and property development have vanished to be replaced by shows about home improvement, gardening, and what seems like a dozen variations upon Cash in the Attic, where people turn unwanted goods into cash.

Capital goods are sensitive
Companies that make capital goods, such as heavy machinery, will always be badly hit when business confidence drops, as many firms will choose not to replace their existing machines and instead try to get a bit more life out of them (though this could boost the sales of spare parts).

But once confidence returns, they should see a dramatic improvement in business as the backlog hits their order book. It is common for these companies' profits to collapse as an economy enters a recession, only to rebound dramatically as it exits. This is why these companies' price-to-earnings ratios will often swing through an extremely wide range of values as the market attempts to price in the latest forecast downturn or upturn in business confidence.

No confidence? Have a smoke
If you want to buy shares in a company that's barely affected by changes in business or consumer confidence, your first port of call should be the tobacco companies. That's because the vast majority of smokers are addicts, so their consumption of tobacco tends to remain fairly constant.

When times are tough, most smokers will cut back their spending on other goods in order to maintain their habit. But some will trade down to cheaper brands, and there will also be a big upsurge in the consumption of tobacco that has been smuggled into Britain from lower-tax countries like Belgium and France.

Consequently, over the last five years, shares in the two British tobacco giants British American Tobacco (AMEX: BTI) and Imperial Tobacco (LSE: IMT.L) have increased respectively by 88% and 7%, compared to a fall of 16% for the FTSE 100 index.

Down in the dumps? Have a drink
Another sector where spending holds up well in trying times is alcohol, though many people will change their patterns of consumption by drinking less in pubs and more at home.

You can see this reflected in the share price of Diageo (NYSE: DEO), which is up by 46% in the last five years, while SABMiller has risen by 96% during the same period. In contrast, the pub chains have generally been hit hard. A good example is JD Wetherspoon (LSE: JDW.L), which is down by 33%.

But it isn't just declining consumer confidence that has harmed the pub trade. The smoking ban has put the boot in on Britain's marginal pubs, and the increasing hostility of the state towards the sector hasn't helped either. The financial difficulties of Britain's two largest pub groups --Enterprise Inns and Punch Taverns -- are enough to make their shareholders turn to the bottle. I'm pretty confident about that!

Let me finish by adding that more share ideas can be found within "Top Sectors For 2012," a Motley Fool study of three favorable sectors that could offer potential opportunities for long-term investors. The report is free.

Further investment opportunities: