Chapter 1: The World of Time Series Forecasting
The World of Time Series Forecasting
Understanding Data Across Time
When you check your phone each morning and glance at the weather forecast for the day, you are engaging with a time series. When you look at your bank account balance and notice how it has changed over the past months, you are examining a time series. When a doctor reviews your blood pressure readings taken over several weeks, she is analyzing a time series. Time series data is everywhere, woven into the fabric of our daily lives, our businesses, and our understanding of the world.
A time series is simply a sequence of data points collected or recorded at successive time intervals. What distinguishes time series data from other types of data is the temporal ordering of observations—each data point carries a timestamp, and the sequence of these timestamps matters enormously. Unlike cross-sectional data where observations are independent of each other, time series observations are typically dependent on their predecessors. The temperature today is related to the temperature yesterday. The sales figure for this month is connected to last month's performance. This temporal dependency is what makes time series analysis both challenging and extraordinarily useful.
Consider the stock price of a technology company over the course of a trading year. Each day, the price moves up or down based on countless factors: company announcements, broader market trends, economic news, and pure investor sentiment. If you were to merely list all the daily closing prices, you would have a time series. But if you then analyze how these prices evolved, what patterns emerged, and what might happen next, you would be performing time series analysis and forecasting.
The applications of time series forecasting extend far beyond financial markets. In healthcare, hospitals use forecasts of patient admissions to optimize staffing levels and resource allocation. A hospital that can accurately predict a surge in emergency room visits during flu season can save lives and reduce costs. In retail, companies like Amazon and Walmart analyze purchasing patterns over time to manage inventory, preventing both stockouts that lose sales and overstocking that ties up capital. In energy, grid operators forecast electricity demand hours and days in advance to balance supply and demand, ensuring the lights stay on while minimizing waste from unused power plants.
Everyday Examples of Time Series Data
Let us explore several common examples of time series that you likely encounter regularly, examining what makes each one interesting and challenging to forecast.
Daily Temperature Readings
If you record the temperature in your city every hour over a year, you create a time series with approximately 8,760 data points (24 hours × 365 days). This series contains multiple overlapping patterns. There is a daily cycle: temperatures typically rise during the day and fall at night. There is an annual cycle: summer months are warmer than winter months in most regions. There are longer-term trends related to climate change, gradually shifting baseline temperatures upward over decades. And there is substantial randomness: a cold front might plunge temperatures below seasonal norms, or an unusual heat wave might push them well above expected levels.
Forecasting daily temperature matters enormously. Weather prediction helps individuals plan their activities, helps farmers protect crops from frost, and helps energy companies anticipate heating and cooling demand. The meteorological industry has invested billions of dollars in sophisticated forecasting systems, yet temperature prediction remains imperfect because the underlying systems are inherently chaotic—a small error in initial conditions can compound into large forecast errors over time.
Monthly Retail Sales
A clothing retailer might track the total sales revenue from each of its stores, recorded monthly. This time series exhibits several important characteristics. There is a strong annual seasonality: sales spike in November and December during the holiday shopping season, then decline in January as consumer spending normalizes. There may be a longer-term trend as the retailer grows or contracts. There are cyclical patterns tied to economic booms and recessions. And there is noise—random variations from store promotions, local events, and unpredictable consumer behavior.
Accurate sales forecasting allows the retailer to optimize many business decisions. Purchasing managers need to know how many winter coats to order from manufacturers, typically six months before those coats reach the sales floor. Store managers need to schedule staff appropriately. Marketing teams need to budget for promotional campaigns. A forecast that is too high leads to excess inventory and markdowns. A forecast that is too low leads to stockouts and lost sales. The economic value of accurate forecasting can be substantial—studies suggest that improved forecasting in retail supply chains can increase profitability by 2-5%.
Hourly Website Traffic
A technology company might track the number of visitors to its website, measured every hour. This time series shows clear intra-day patterns: traffic peaks during business hours when people are at work and browsing the internet, then drops significantly in the overnight hours. There are weekly patterns, with lower traffic on weekends. There are seasonal patterns tied to news cycles and marketing campaigns. And there are long-term trends as the company's user base grows or shrinks.
Website traffic forecasting helps the company plan server capacity, schedule content updates, and allocate customer support resources. During an unexpected traffic surge—such as when a viral post drives thousands of visitors to the site—the company must quickly scale up server resources or risk crashes that would frustrate users and damage the brand. Conversely, if traffic is forecasted to be low during holiday periods, the company might schedule major site maintenance that would otherwise disrupt users.
Annual Population Growth
Demographers track the population of countries and cities over time, recorded annually. This time series evolves slowly but shows profound patterns. There are long-term trends related to birth rates, death rates, and migration patterns. There are generational effects—baby booms create ripples that affect housing demand decades later. And there are policy impacts: China's one-child policy dramatically altered population dynamics for generations.
Population forecasts inform trillion-dollar decisions. Governments need to know how many school children will need classrooms in five, ten, and twenty years. Healthcare systems need to anticipate the growing share of elderly patients as populations age. Urban planners need to design transportation systems and housing for future residents. These forecasts shape infrastructure investments that will last for decades.
The Building Blocks of Time Series
Understanding time series requires recognizing the fundamental components that combine to create the data we observe. These components—trend, seasonality, cyclical patterns, and noise—are the vocabulary of time series analysis, and mastering this vocabulary will help you understand which forecasting methods are appropriate for different situations.
Trend: The Long-Term Direction
A trend represents the underlying direction of a time series over an extended period. If you examine a plot of a time series and draw a line that captures the general direction ignoring short-term fluctuations, that line represents the trend. Trends can be upward, downward, or relatively flat.
Consider the stock price of a successful company over twenty years. Despite short-term volatility—weeks when the stock falls sharply, months when it surges—the overall trajectory might be clearly upward. Investors and analysts care deeply about trends because they often refle