Module 5 — When is a prediction good?
Lesson 11 of 14
Forecasting across time
5.11 Forecasting Across Time
At 9:00 this morning, an electricity system predicts that demand at 18:00 will be:
[ 42.5\text{ GW} ]
At midday, the forecast changes to:
[ 43.1\text{ GW} ]
At 16:00, it changes again:
[ 44.0\text{ GW} ]
And at 17:55, the forecast is:
[ 43.7\text{ GW} ]
Which forecast was correct?
That question is more complicated than it first appears.
Each forecast was made at a different point in time, using a different amount of information, to predict an outcome at another point in time.
This introduces one of the defining characteristics of forecasting:
Time separates what we know from what we are trying to predict.
And the size of that separation matters enormously.
Prediction has a horizon
Suppose we are currently at time:
[ t ]
and want to predict some quantity at a future time:
[ t+h ]
where (h) is the forecast horizon.
We can represent the prediction as:
[ \hat{y}_{t+h|t} ]
This notation means:
our prediction, made at time (t), of the value of (y) at time (t+h).
If:
[ h=5\text{ minutes} ]
we are making a very short-term forecast.
If:
[ h=24\text{ hours} ]
we are forecasting a day ahead.
If:
[ h=10\text{ years} ]
we are making a long-term forecast.
These are not merely different versions of the same problem.
The information available, sources of uncertainty, appropriate models and possible uses of the forecast may all be completely different.
The further away the future is, the less we usually know
Imagine trying to predict the temperature.
Five minutes from now
We know the current temperature.
We know whether it is rising or falling.
We have recent measurements.
The atmospheric state cannot usually change dramatically in five minutes.
Tomorrow
We still have substantial information, but uncertainty has increased.
Weather systems can evolve.
Forecast errors accumulate.
Three months from now
Predicting the exact temperature at 14:00 on a particular Tuesday becomes essentially impossible.
We may still be able to predict statistical characteristics:
- typical temperatures,
- seasonal ranges,
- probabilities of extreme conditions.
But our ability to predict the precise state of the system deteriorates dramatically.
In many forecasting problems:
[ \text{forecast uncertainty} \uparrow ]
as:
[ \text{forecast horizon} \uparrow ]
The further we look into the future, the larger the space of possible futures generally becomes.
Forecasting one step ahead
Suppose we observe a time series:
[ y_1,y_2,\ldots,y_t ]
and want to predict the next observation:
[ y_{t+1} ]
This is called one-step-ahead forecasting.
For example, if electricity demand is measured every 30 minutes, we might use:
[ y_t ]
and previous observations to predict:
[ y_{t+1} ]
Thirty minutes later, we observe the actual value.
We can then make another prediction:
[ \hat{y}_{t+2|t+1} ]
Then:
[ \hat{y}_{t+3|t+2} ]
and so on.
At each step, the model receives the newest observation before making its next forecast.
This can make short-term forecasting extremely powerful.
Multi-step forecasting
But suppose instead we need to predict the next 24 hours immediately.
For half-hourly electricity demand, that means predicting:
[ 48 ]
future values:
[ \hat{y}{t+1|t}, \hat{y}{t+2|t}, \ldots, \hat{y}_{t+48|t} ]
This is multi-step forecasting.
Now the model cannot observe what actually happens at:
[ t+1 ]
before predicting:
[ t+2 ]
because all 48 forecasts are being produced at time (t).
That creates a harder problem.
The model is predicting increasingly distant states using information that becomes increasingly old relative to the thing being predicted.
Recursive forecasting
One way to produce multi-step forecasts is recursively.
First predict:
[ \hat{y}_{t+1} ]
Then use that prediction as though it were an observation when predicting:
[ \hat{y}_{t+2} ]
Then use the previous predictions to estimate:
[ \hat{y}_{t+3} ]
and continue.
Conceptually:
[ y_t \rightarrow \hat{y}{t+1} \rightarrow \hat{y}{t+2} \rightarrow \hat{y}_{t+3} \rightarrow\cdots ]
This is simple and useful.
But it introduces an important problem.
Prediction errors can propagate.
If:
[ \hat{y}_{t+1} ]
is slightly wrong, that incorrect value becomes an input into the next prediction.
That prediction may therefore also be wrong.
Its error can then affect the next prediction.
Over longer horizons, errors may accumulate.
Direct forecasting
Another approach is to train separate models for different forecast horizons.
For example:
[ f_1(X_t)\rightarrow \hat{y}_{t+1} ]
[ f_2(X_t)\rightarrow \hat{y}_{t+2} ]
[ f_3(X_t)\rightarrow \hat{y}_{t+3} ]
and so on.
Instead of recursively feeding predictions back into the model, each horizon is predicted directly from information available at time (t).
This can avoid some forms of error propagation.
But it may require more models, more training and more data.
Once again, model design depends on the problem we are trying to solve.
Time series contain structure
Many things we forecast are not independent observations.
They have temporal structure.
Electricity demand at 18:00 today is related to demand at:
- 17:30 today,
- 18:00 yesterday,
- 18:00 last Wednesday,
- 18:00 on similar days.
Temperature today is related to temperature yesterday.
Traffic congestion at 08:30 is related to commuting patterns.
Retail demand in December may resemble previous Decembers.
A time series might contain:
- trends,
- cycles,
- seasonality,
- persistence,
- sudden changes,
- long-term structural shifts.
Forecasting across time therefore requires us to understand how the past is organised.
Lags
One of the simplest ways of using time is through lagged variables.
Suppose:
[ y_t ]
is electricity demand now.
We might use:
[ y_{t-1} ]
the previous observation,
[ y_{t-2} ]
two observations ago,
and:
[ y_{t-48} ]
the value at the same time yesterday, assuming half-hourly data.
These are called lags.
A forecasting model might therefore learn:
[ \hat{y}_{t+1}
f( y_t, y_{t-1}, y_{t-2}, y_{t-48}, \ldots ) ]
This is a simple but powerful idea:
The recent and repeated past can contain information about the near future.
Seasonality
Many systems repeat patterns across time.
Electricity demand typically changes according to:
- time of day,
- day of week,
- season,
- holidays.
Transport demand often has morning and evening peaks.
Retail demand changes around weekends and holidays.
Heating demand changes with seasons.
We call repeated temporal patterns seasonality.
A time series might therefore contain several overlapping cycles:
[ \text{daily} + \text{weekly} + \text{annual} ]
A model that ignores these patterns may perform poorly even if it has enormous amounts of data.
Time itself can be an important feature.
Trend is different from seasonality
Suppose electricity consumption grows gradually over ten years.
That is a trend.
Suppose electricity consumption rises every winter and falls every summer.
That is seasonality.
A simplified representation might be:
[ y_t
T_t + S_t + \epsilon_t ]
where:
- (T_t) represents trend,
- (S_t) represents seasonality,
- (\epsilon_t) represents remaining variation.
Real systems are usually more complicated than this.
But separating these ideas helps us understand what a forecasting model may be learning.
The order of data matters
This creates an important difference between ordinary machine-learning datasets and time-series datasets.
Suppose we have ten years of historical observations.
In ordinary machine learning, we might randomly divide the dataset into:
- training data,
- validation data,
- test data.
But random splitting can be dangerous when forecasting across time.
Why?
Because the model may accidentally learn from the future.
Suppose observations from 2026 appear in the training set while observations from 2025 appear in the test set.
We are effectively asking:
How well could a model trained partly on the future have predicted the past?
That is not the forecasting problem we actually face.
You cannot train on tomorrow to predict yesterday
A more realistic evaluation respects the direction of time.
For example:
Training
[ 2020-2024 ]
Validation
[ 2025 ]
Test
[ 2026 ]
Now the model is evaluated in the same direction in which it would operate:
[ \text{past} \rightarrow \text{future} ]
This may sound obvious.
But violations of this principle can create deceptively impressive models.
Data leakage through time
Imagine predicting whether a patient will be readmitted to hospital.
You construct the prediction at the moment the patient is discharged.
But one of your model features was recorded three days after discharge.
That variable may be highly predictive.
It may produce excellent test performance.
It is also completely useless for the actual prediction.
At the moment the decision must be made, the information does not yet exist.
This is a form of data leakage.
The critical question is therefore not merely:
Was this variable recorded somewhere in the dataset?
It is:
Was this information genuinely available at the moment the prediction would have been made?
Forecasting forces us to respect causality in time.
The information set
We can formalise this idea using an information set.
Let:
[ \mathcal{I}_t ]
represent everything legitimately known at time (t).
A forecast should then be based on:
[ P(Y_{t+h}\mid\mathcal{I}_t) ]
not on information that becomes available later.
This gives us a useful principle:
A forecast should be judged according to the information that could actually have been known when the forecast was made.
That sounds simple.
It is extremely important.
Rolling forecasts
In many real systems, forecasts are continuously updated.
Imagine forecasting electricity demand for the next 24 hours.
At:
[ 08{:}00 ]
we produce a 24-hour forecast.
At:
[ 08{:}30 ]
new measurements arrive.
We update the forecast.
At:
[ 09{:}00 ]
we update it again.
The forecasting window continually moves forward.
This is called a rolling forecast.
Conceptually:
[ \text{observe} \rightarrow \text{forecast} \rightarrow \text{observe} \rightarrow \text{update} \rightarrow \text{forecast again} ]
The model is not making one permanent statement about the future.
It is continually revising its beliefs as reality unfolds.
Forecast revision is not necessarily failure
Suppose yesterday's forecast for tomorrow's demand was:
[ 42\text{ GW} ]
Today's forecast becomes:
[ 45\text{ GW} ]
Has the forecasting system failed?
Not necessarily.
Perhaps the weather forecast changed.
Perhaps a major sporting event was announced.
Perhaps an industrial facility changed its operating schedule.
Perhaps new measurements revealed that demand was running higher than expected.
A good forecasting system should respond to new information.
We therefore need to distinguish between:
forecast error
and
forecast revision.
Changing a forecast because new evidence has arrived can be evidence of a functioning forecasting system, not a defective one.
Forecasts should become more informative as the event approaches
Suppose we predict wind generation at 18:00 tomorrow.
Twenty-four hours beforehand, the distribution might be broad:
[ P(W_{18:00}) ]
As time progresses, new weather observations arrive.
At six hours ahead, uncertainty may shrink.
At one hour ahead, it may shrink further.
Conceptually:
[ P(W_{18:00}\mid\mathcal{I}_{t}) ]
becomes increasingly informed as (t) approaches 18:00.
We might therefore expect prediction intervals to narrow.
For example:
24 hours ahead
[ 90%\text{ interval}: 5-17\text{ GW} ]
6 hours ahead
[ 90%\text{ interval}: 8-15\text{ GW} ]
1 hour ahead
[ 90%\text{ interval}: 10.5-13.5\text{ GW} ]
More information has reduced uncertainty.
This is one reason forecast quality should often be evaluated separately at different horizons.
A model can be good at one horizon and bad at another
Suppose two electricity-demand models are compared.
Model A
Excellent at:
[ 5-30\text{ minutes ahead} ]
but poor beyond:
[ 6\text{ hours} ]
Model B
Slightly worse in the next few minutes but much better:
[ 1-7\text{ days ahead} ]
Which model is better?
There is no universal answer.
It depends on the decision.
A real-time control system may prefer Model A.
A generator scheduling system may prefer Model B.
A network investment planner may need something entirely different.
The relevant forecast horizon is determined by the action the forecast is supposed to inform.
Different horizons can require different information
Short-term electricity-demand forecasting might rely heavily on:
- current demand,
- recent demand,
- current temperature,
- current network conditions.
Day-ahead forecasting might care more about:
- weather forecasts,
- day of week,
- holidays,
- scheduled events.
Long-term forecasting might depend on:
- population,
- economic growth,
- electrification,
- technology adoption,
- industrial policy,
- energy efficiency.
As the horizon changes, the problem itself changes.
A five-minute forecast and a twenty-year forecast may both be called:
electricity-demand forecasting
but they are doing very different things.
Forecasting versus projection
This distinction becomes particularly important over long horizons.
Suppose somebody says:
Electricity demand will be 600 TWh in 2050.
That sounds like a forecast.
But perhaps the number assumes:
- 15 million heat pumps,
- 30 million electric vehicles,
- substantial industrial electrification,
- a particular population trajectory,
- particular efficiency improvements.
Then the statement is closer to:
If these assumptions hold, the model produces approximately 600 TWh.
That is better understood as a projection or scenario-dependent forecast.
The distinction matters because uncertainty about the future increasingly comes not merely from random variation, but from uncertainty about:
- technology,
- policy,
- behaviour,
- economics,
- institutions,
- geopolitics.
At sufficiently long horizons, asking for a single precise number can become deeply misleading.
Forecast errors can be correlated through time
Suppose an electricity-demand model underpredicts demand at:
[ 17{:}00 ]
Then again at:
[ 17{:}30 ]
Then:
[ 18{:}00 ]
Then:
[ 18{:}30 ]
These errors may not be independent.
Perhaps the model failed to anticipate a cold evening.
That one mistake affects several consecutive forecasts.
This is called temporal correlation in forecast errors.
It matters because repeated errors can create much greater operational consequences than isolated mistakes.
A system that is wrong by:
[ 1\text{ GW} ]
for one interval is different from a system that is wrong by:
[ 1\text{ GW} ]
for six consecutive hours.
The temporal structure of errors matters just as the temporal structure of the underlying data does.
Forecasting events as well as values
Not every time-based prediction asks:
What will the value be?
Sometimes we ask:
When will something happen?
Examples include:
- when will a machine fail?
- when will a customer leave?
- when will a patient relapse?
- when will a battery reach a particular state?
- when will a queue exceed capacity?
Now time itself becomes the predicted variable.
Instead of predicting:
[ Y_{t+h} ]
we might predict:
[ T_{\text{event}} ]
or a probability such as:
[ P(T_{\text{failure}}\leq30\text{ days}) ]
This shows how deeply time can be embedded in prediction.
We may forecast:
- a future value,
- a future state,
- the probability of an event,
- or the time until an event occurs.
The past is not equally useful forever
Suppose we have 100 years of historical data.
Is all of it equally useful?
Probably not.
The world changes.
A model predicting electricity demand in 2026 may find data from 2025 extremely informative.
Data from 1980 may be less useful because:
- appliances changed,
- industry changed,
- buildings changed,
- lifestyles changed,
- technologies changed.
Likewise, a model predicting online shopping behaviour may find data from twenty years ago only weakly relevant.
This creates a tension.
More historical data gives us more examples.
But older data may describe a world that no longer exists.
Recency versus history
Imagine two forecasting strategies.
Strategy A
Train on:
[ 20\text{ years of data} ]
Strategy B
Train only on:
[ 2\text{ recent years} ]
Strategy A has far more observations.
Strategy B may better represent the current system.
Which is better?
Again, there is no universal answer.
We need to understand:
- how quickly the system changes,
- whether older patterns remain relevant,
- whether rare events require long histories,
- whether recent data is representative.
The most data is not automatically the best data.
The prediction changes as the world changes
This leads towards a major problem we will examine shortly:
distribution shift.
Suppose a model learns:
[ P(Y\mid X) ]
from historical data.
Over time, the underlying system changes.
The relationship becomes:
[ P_{2026}(Y\mid X) \neq P_{2020}(Y\mid X) ]
Perhaps consumer behaviour changed.
Perhaps climate conditions changed.
Perhaps regulation changed.
Perhaps a new technology appeared.
Perhaps people began responding to the model itself.
A model can therefore become worse without changing a single line of code.
The model stayed still.
The world moved.
Forecasting can change the future
There is an even deeper complication.
Suppose at midday an electricity system forecasts a severe shortage for 18:00.
The forecast is published.
Generators respond.
Batteries charge earlier so they can discharge at 18:00.
Consumers shift demand.
Additional generation becomes available.
At 18:00 there is no shortage.
Was the forecast wrong?
Perhaps not.
Without the forecast, the shortage might have occurred.
The prediction caused actions.
The actions changed the future.
We therefore have:
[ \text{data} \rightarrow \text{forecast} \rightarrow \text{decision} \rightarrow \text{action} \rightarrow \text{changed future} ]
This makes evaluating forecasts in adaptive systems much more difficult.
The forecast is no longer merely predicting reality.
It has become part of the mechanism producing reality.
Forecasting and control
This brings us towards control theory.
A controller does not simply predict what a system will do and then watch.
It repeatedly:
- observes the system;
- estimates its state;
- compares that state with a desired outcome;
- takes an action;
- observes the new state;
- adjusts again.
Conceptually:
[ \text{observe} \rightarrow \text{predict} \rightarrow \text{decide} \rightarrow \text{act} \rightarrow \text{observe again} ]
Now prediction is embedded inside a feedback loop.
The objective is no longer necessarily to predict the uncontrolled future perfectly.
It may be to use prediction to produce a better future.
That is a fundamentally different objective.
The strange case of the successful forecast that never happens
Imagine an AI system predicts:
There is an 85% probability that this machine will fail within the next week.
The operator replaces a component immediately.
The machine does not fail.
Was the AI wrong?
We cannot simply conclude that it was.
The prediction triggered an intervention that changed the outcome.
This is an important distinction between:
[ \text{prediction} ]
and:
[ \text{counterfactual prediction} ]
The relevant question may have been:
What would happen if we did nothing?
But once the prediction influences action, we no longer observe that world.
We observe:
What happened after we acted.
This is one of the deepest problems that arises when predictive systems become decision systems.
Backtesting
Before deploying a forecasting model, we often evaluate how it would have performed historically.
This is called backtesting.
Suppose we have data from:
[ 2020-2026 ]
We might pretend we are standing at the beginning of 2024.
Train the model using only information available before that date.
Forecast the next period.
Compare the forecast with what actually happened.
Then move forward:
[ t \rightarrow t+1 ]
retrain or update the model if appropriate, and forecast again.
This attempts to recreate the information conditions the model would actually have faced.
A realistic backtest therefore respects time.
Walk-forward validation
A common approach is walk-forward validation.
For example:
Step 1
Train:
[ 2020-2022 ]
Test:
[ 2023 ]
Step 2
Train:
[ 2020-2023 ]
Test:
[ 2024 ]
Step 3
Train:
[ 2020-2024 ]
Test:
[ 2025 ]
The model repeatedly moves forward through history.
This gives us a much better idea of how it might behave when deployed.
The crucial rule remains:
At every simulated point in time, the model may use only information that would actually have existed at that time.
Time changes what "good" means
Suppose a forecasting system has an average error of:
[ 2% ]
Is that good?
We still do not know.
We need to ask:
- at what forecast horizon?
- during which period?
- under what operating conditions?
- compared with what baseline?
- was the error stable through time?
- did performance deteriorate during rare events?
- did the model use information genuinely available at prediction time?
An average score can conceal all of this.
A model may perform brilliantly most of the year and fail precisely during the periods when accurate forecasts matter most.
Evaluation must therefore preserve the temporal structure of the problem.
The deeper lesson
Forecasting is sometimes presented as though we have:
[ \text{data} \rightarrow \text{model} \rightarrow \text{prediction} ]
But once time enters the picture, the structure becomes richer.
At time (t), we have an information set:
[ \mathcal{I}_t ]
From it, we construct beliefs about a future state:
[ P(Y_{t+h}\mid\mathcal{I}_t) ]
Time passes.
New information arrives:
[ \mathcal{I}_{t+1} ]
Our beliefs change:
[ P(Y_{t+h}\mid\mathcal{I}_{t+1}) ]
Eventually we act.
Our action may itself change:
[ Y_{t+h} ]
And the realised future becomes part of the historical data used for the next prediction.
So the real structure looks much more like:
[ \text{past} \rightarrow \text{present information} \rightarrow \text{forecast} \rightarrow \text{decision} \rightarrow \text{action} \rightarrow \text{future} \rightarrow \text{new data} \rightarrow \text{new forecast} ]
This is a continuously evolving feedback loop.
And it returns us to one of the central ideas of this entire course:
The past is observed. The present is where decisions happen. The future remains uncertain until it becomes the past.
Forecasting is the attempt to bridge those worlds.
But the bridge changes depending on how far ahead we are looking, what information is available, how the system itself is changing, and whether our predictions influence what happens next.
So whenever you encounter a forecast, don't ask only:
What is the prediction?
Ask:
When was it made?
What information was available then?
How far ahead was it predicting?
How uncertain was it?
How has the forecast changed as new information arrived?
and perhaps most importantly:
What decisions will be made because of it?