Stock markets around the world were off to their worst start to a year, ever, in 2016. The Dow Jones Industrial Average and the broader S&P 500 index were down around 5% during the first two weeks of the year. Why did this happen? The answer is complicated, but understanding what stocks are and why they have a price will shed some light on the matter.

What Stock Markets Are

Before you can understand why stock markets rise and fall, you need to understand what a stock market is. A stock market is a place where people come together to buy and sell ownership shares in a company. The value of a company, or its market capitalization, is the sum of all the ownership shares it has outstanding multiplied by the price of those shares. For example, Apple, Inc. (AAPL) has 5.13 billion shares that trade at $178 a share as of January 2018—therefore Apple is worth $913 billion. (See also: Stocks Basics Tutorial.)

The next piece to understand is what a company’s value represents. A company has stuff and it sells stuff. The stuff it has—buildings, machinery, patents, money in the bank, etc.—constitute its book value, or the amount of money a company would get if they sold all of that stuff at once. But companies are primarily in business of trying to make a profit, and in doing so they earn cash by selling products or services. So the value of a company has to do with the stuff it owns now and the cash flows it will receive in the future. The value of the stuff it owns now is fairly easy to determine, but the value of all the future cash flow streams is a bit trickier to nail down—and it is this piece that is responsible for market gyrations.

Because of the time value of money, profits to be earned in the future must be discounted back to represent today’s dollars—just like a dollar put into a bank account will be worth more in the future after it has earned some interest, just in reverse. How much to discount these future cash flows depends on a lot of things including the cost of capital (which is the cost to borrow or find investment, and this depends on interest rates), the riskiness of the business (in the stock market this is often estimated using beta) and the foregone cost of doing nothing and keeping your money in the bank (the opportunity cost or risk-free rate).

Cash Flows and Price-to-Earnings

Once an appropriate discount rate has been estimated, the hard part is to figure out what future cash flows will be—a month from now, a year from now, five years from now. Financial analysts try to figure these amounts out in a number of ways accounting for both company-specific factors and macro factors such as overall economic health. Fortunately, the stock market reflects the expectation of future cash flows in an easy to compute ratio of price to earnings, also known as the P/E ratio. A P/E ratio of 10x means that a company is being valued today at 10 times its current earnings. A P/E ratio of 20x for the same company would mean that given the same amount of earnings, the market is giving it twice as much value, indicating that those future cash flows are going to be larger.

So that’s basically it: stock markets are places where people buy and sell shares of companies, and these shares are valued in large part as a multiple of current earnings that represent the net present value of future cash flows. Because the future is unknown today, various peoples’ estimates will be different from one another, giving some a higher expected stock price and some a lower stock price. If the current price is lower than the expected price, people will buy it. If it is higher, people will sell it. And this is the stock market.

Why Stock Markets Fall—And Why They Fell in Early 2016

When an economy is growing, people are spending and profits are rising. Companies invest in projects, expand their businesses and hire more people. Investors are optimistic and expectations of future cash flows rise, and stocks enter a bull market.

Simply put, stock markets fall when expectations of future cash flows decrease, making the prices of companies seem too high, therefore causing people to sell shares. If many more people come to this decision than there are people to buy those shares, the price will fall until it reaches a level where people will begin to believe that they are fairly valued.

China, Actually

Let’s look at China. A lot of the blame for the 2016 global market declines was related to weakness in the Chinese economy and a crash in Chinese stocks. Weak demand from China not only reduced expected future profits from Chinese companies but also from global corporations who do business with China, and this has a ripple effect. American companies that produce commodities or products that are exported to China see lower earnings. American banks that lend to those companies see their profits fall as those loans become more risky. Expectations about future cash flows fall and stock prices will follow suit. (See also: China’s Stock Markets vs U.S. Stock Markets.)

China’s stock market rose dramatically over the years leading up to 2016 as investors believed that Chinese economic growth would keep on expanding at a rapid pace. The average P/E ratio for the Shanghai market rose to around 50x earnings, and the tech-heavy Shenzen index rose to a P/E of over 100x. The P/E ratio for the Nasdaq composite before the dot-com bubble burst was as high as 175x in March 2000. To put this into perspective, the average P/E ratio for U.S. stocks historically has been around 15.6x.

In order to restore more realistic P/E ratios based on more realistic expectations of growth and future cash flows, stock prices needed to fall. And they needed to fall until that ratio begins to make sense.

We also had a very low interest rate environment for a record amount of time, which made borrowing cheaper and easier for companies to expand their operations. Low interest rates, however, can cause them to take on too much risk and expand more rapidly than is justified. When the Federal Reserve began raising interest rates in December 2015, the cost of borrowing increased and took a bite out of profits, reducing future cash flows. Rising interest rates also have the effect of increasing the rate used to discount cash flows, making $1 earned next year worth less today than given a lower rate of interest.

Another factor is that people are not always rational—especially when it comes to money and investments. Rather than an orderly drop in price to restore some fundamental level of price to earnings, people often overreact and panic. When there is panic, there is fear, irrational behavior spreads and markets collapse. Expectations about future cash flows essentially drop to zero and people become more concerned with converting investments into cash as quickly as possible.

The Bottom Line

Of course, panic doesn’t last forever, and ultimately smart investors see oversold price levels as buying opportunities when company values go “on sale."