What makes time series different
Today let's understand what actually makes a time series different from an ordinary dataset, using one real example.
Riverside Bike Share is a city bike-rental program. Here is its daily rental count for three straight years, 1,095 days, plotted in the order the days actually happened.
Look at that line. It climbs slowly over the three years, dips every weekend, and rises every summer. That is the whole difference this lesson is about: for a time series, the order the values arrived in carries real information that the values alone do not.
Meet Riverside Bike Share's three years of daily rentals
Before going any further, build this series yourself so every number that follows traces back to code you can see.
Riverside's daily rentals have four things going on at once: a slow upward trend as the program grows, a weekday versus weekend swing (commuters ride on weekdays, leisure riders take over on weekends), a summer versus winter swing (more riders when it is warm), and ordinary random noise on top of all of it.
Across all 1,095 days, the average is 195.9 rentals with a standard deviation of 58.6. The first day (145) and the last day (171) both sit fairly close to that average. None of these four summary numbers say anything about the order the days came in. Plot it and you can see the shape those four ingredients actually produce.
Same numbers, shuffled: what changes and what doesn't
Here is a direct test of whether the order matters. Take the exact same 1,095 numbers you just built and shuffle them into a random order, so day 612's rental count might now sit at position 40 and day 3's might sit at position 900.
The mean and the standard deviation match to three decimal places. That makes sense: shuffling only rearranges which value sits at which position, it never changes which 1,095 values are in the set, so any summary that only counts values, and ignores their order, comes out identical.
Now plot the two side by side.
The ordered plot on the left still shows the climb, the weekend dips, the summer rise. The shuffled plot on the right looks like static: no trend, no seasonal rhythm, nothing to read off it at all. Same 1,095 numbers, same mean, same standard deviation, and a completely different picture. Whatever produces that picture is not sitting in the values themselves. It is sitting in the order.
Autocorrelation: correlating a series with its own past
A mean's standard error, a t-test, and plain linear regression all share one assumption underneath them: each observation is independent, meaning knowing one value tells you nothing about the next one. That assumption is exactly what the shuffle test just put to the test, and for the ordered series, it clearly fails. A busy day is followed by another busy day far more often than chance would produce.
There is a name for that failure, and a way to measure exactly how large it is. Autocorrelation is the correlation between a series and a lagged copy of itself: today's value against yesterday's value, for every day in the series. Line up each day's rentals with the day right before it and run an ordinary correlation.
For the ordered series, that correlation is 0.692. For the shuffled series it is -0.026, indistinguishable from zero. Shuffling did not touch a single rental count. It only broke the link between a day and the day before it, and that link is exactly what the 0.692 was measuring.
See that pairing as a scatter plot: every day's rentals against the day right before it.
Press Run on that chart's code and it computes a Pearson correlation on those 1,094 pairs, and it lands at the same 0.692 the hand calculation gave you a moment ago. High rental days genuinely tend to sit next to other high rental days, and the shuffle you ran earlier destroyed exactly that.
Why the standard error of the mean needs a correction
A mean's ordinary standard error, sd / sqrt(n), assumes every one of the n observations adds a fresh, independent piece of information. With autocorrelation at 0.692, that assumption is badly wrong: a big chunk of what tomorrow's rental count tells you, you already knew from today's. So the 1,095 correlated days do not carry 1,095 days' worth of independent information. They behave like a much smaller number of independent days.
That smaller number has a name, the effective sample size, n_eff, and a formula: n_eff = n * (1 - r) / (1 + r), where r is the lag-1 autocorrelation.
Those 1,095 correlated days behave like only about 199 independent ones. Treat them as 1,095 independent days, the way an ordinary standard error does, and you get a naive standard error of 1.77. Correct for the true 199 effective days and it grows to 4.15, more than double. What changed is not the mean itself, still 195.9 exactly as before, but how confident you are allowed to be about it, once the days stop pretending to be independent.
At severity zero, the errors are independent and the 95% interval covers the truth close to 95% of the time. Drag the dial toward severe, and the interval's actual coverage falls well below that stated 95%, while the fit statistic barely moves, or even rises a little. That gap, a model whose fit still looks fine sitting next to an interval whose real coverage has quietly fallen far below the 95% printed on it, is the entire reason this correction matters.
Quick check: reading a lag-1 correlation
The vocabulary: trend, seasonality, cycle, and noise
Riverside's series is built from exactly four ingredients, and every time series you meet from here on can be described using the same four words.
- Trend: the slow, long-run direction of the series. Riverside's trend climbs from 150 toward roughly 205 over the three years, as the bike-share program grows.
- Seasonality: a pattern that repeats at a fixed, known length tied to the calendar. Riverside has two: a weekly one (weekdays average 217.5 rentals, weekends average 141.8) and a yearly one (a roughly 120-rental swing between summer and winter).
- Cycle: a rise and fall with no fixed length, often stretching over years, like a broader business cycle. Riverside's series has none. Three years is simply too short a window for a cycle to ever show up in it.
- Noise: whatever is left once trend, seasonality, and cycle have been accounted for. It is the day-to-day randomness
rnorm()added when you built the series.
The black line is the trend you built the series from. The blue dashed line marks the weekday average, the red dashed line marks the weekend average, and the grey line underneath both is the raw series carrying its own noise.
Lag and horizon: two words used throughout the rest of the course
Two more terms round out the vocabulary you need to read any time series. Lag is how many steps back a comparison looks. Lag 1 compares today against yesterday, the comparison you already computed. Lag 7 compares today against the same day one week earlier.
Lag 7's correlation, 0.933, is even higher than lag 1's 0.692. That makes sense once you remember the weekly pattern: a Monday is more like the Monday one week earlier than it is like the Sunday right before it.
Horizon is a different idea: how many steps ahead a forecast reaches. Forecasting tomorrow's rentals is horizon 1. Forecasting a month from now is horizon 30. Lag looks backward to measure a relationship already in the data. Horizon looks forward to say how far a forecast is trying to reach.
A forecast is a distribution, not one number
Riverside's manager wants tomorrow's rental count, day 1,096. The tempting answer is a single number, probably today's value, 171. But that hides something worth stating plainly: how much that guess could plausibly be off by.
Day-to-day changes in Riverside's rentals typically run about 46 rentals in either direction. So the honest statement for tomorrow is not "171." It is "somewhere around 125 to 217," built directly from that spread. A forecast is really a distribution of plausible outcomes, and a single number is just its centre.
That spread would also widen the further out the forecast reaches, if day-to-day changes kept behaving the same independent way.
One day out, the spread is 46. A week out, it grows to 122. A month out, 252. The spread grows with the square root of the horizon, not the horizon itself, but it still grows a lot: forecasting further ahead means committing to a wider honest range, never a sharper single number.
Closing quiz: putting the vocabulary together
Suppose a new series repeats a fixed shape every 12 months and rises steadily underneath that repeating shape.
Your turn: compute a lag correlation and a forecast range
riverside_rentals still holds all 1,095 days you built earlier in this lesson.
First, compute the lag-2 autocorrelation: correlate the series with the value two days before it, the same way lag-1 used one day before and lag-7 used seven days before.
Show answer
# Correlate riverside_rentals with the value two days before it
round(cor(riverside_rentals[1:1093], riverside_rentals[3:1095]), 3)
#> [1] 0.454Now, last_value (171) and day_to_day_spread (46) are both still available from earlier in this lesson. Compute day 1,096's forecast range from them, low and high, instead of just stating it.
References
- Forecasting: Principles and Practice, "Time series graphics" - Hyndman and Athanasopoulos (2021), 3rd edition, chapter 2. Plotting a series in order before doing anything else to it.
- Forecasting: Principles and Practice, "Autocorrelation" - Hyndman and Athanasopoulos (2021), same book, section 2.9. The lag-k correlation this lesson computed by hand.
- Chatfield, C. (2003), The Analysis of Time Series: An Introduction, 6th edition, Chapman and Hall/CRC. Trend, seasonality, cycle, and noise, and why the usual independence assumption fails for ordered data.
- R documentation: stats::acf - the base R function that automates the lag correlations you computed directly in this lesson.
Quick recap
Order carries information: the same 1,095 numbers gave 0.692 ordered against -0.026 shuffled, and that gap is the whole reason time series get treated differently from an ordinary sample.
Autocorrelation shrinks the effective sample size: 1,095 correlated days behaved like only about 199 independent ones, so the honest standard error came out more than double the naive one, even though the mean never moved.
Trend, seasonality, cycle, and noise describe the parts a series is built from. Lag and horizon frame every comparison and every forecast you will make from here on. And a forecast itself is a range, not a single number, one that widens the further out it reaches.
Next up: putting this exact series into the tidy, rectangular shape the rest of this course builds on.