AI Glossary / Probabilistic machine learning / Intermediate
Local linear trend model
Definition
A local linear trend model is a state-space time-series model with both a changing level and a changing slope. Observations are noisy measurements of the level, while random disturbances allow the baseline and its rate of change to evolve over time.
What it means
A local level model tracks a moving baseline but has a flat expected forecast. A local linear trend model adds a slope, allowing the expected series to continue rising or falling at its currently estimated rate.
The trend is local because its slope is allowed to change as new information arrives. This differs from a single straight line fitted across the entire history. The model does not require the realized trajectory to remain globally linear.
The basic version is still a specific assumption: over a future horizon with no new observations, its mean forecast extends the current slope. It does not automatically anticipate saturation, turning points, seasonal patterns or a return to a long-run average.
How it works
A common formulation writes observation y_t = level_t + observation noise. The next level is level_t + slope_t + level disturbance, and the next slope is slope_t + slope disturbance.
The standard Gaussian model uses zero-mean disturbances with specified variances, commonly independent across components and time. Its state vector has two entries, level and slope, and its transition matrix is [[1, 1], [0, 1]] for equally spaced unit time steps.
Kalman filtering updates both states and their covariance. A measurement directly observes the level, but can also update the slope through their statistical relationship. Smoothing uses later data to revise earlier states. Disturbance variances and initial uncertainty govern how quickly the estimated trend adapts.
Three practical examples
- A capacity-planning study models a changing operational baseline whose recent rate of growth is itself uncertain.
- A sensor-analysis system separates a slowly changing drift rate from observation noise.
- A forecasting team compares local level, fixed-slope and stochastic-slope models to determine whether changing trend improves held-out predictions.
Think of it this way
Think of estimating both where a moving walkway is and how fast it is moving, while allowing its speed to change. Knowing the current position alone is not enough to predict where it will be later.
The analogy describes level and slope, not physical acceleration measurements. In the statistical model, slope changes are random disturbances, and real operational processes need not follow the same assumptions.
Worked example
Forecasting with uncertainty in future slope changes
Consider an original example in which the current level is known exactly to be 100 and the current slope is known exactly to be 3 per period. This certainty is a simplifying assumption for the calculation. Let level-disturbance variance be 1, slope-disturbance variance be 0.25 and observation-noise variance be 4, with all disturbances independent.
Mean forecasts for the next three observations are 103, 106 and 109. Future disturbances have mean zero, so they do not change those means.
One period ahead, observation variance is 1 + 4 = 5. The new slope disturbance has not yet affected that period's level.
Two periods ahead, variance is 2 times 1 + 1 squared times 0.25 + 4 = 6.25. Three periods ahead, it is 3 times 1 + (2 squared + 1 squared) times 0.25 + 4 = 8.25.
Earlier slope disturbances affect more subsequent level increments, so their contributions accumulate with squared weights. In a fitted model, uncertainty in the current level and slope, including their covariance, would add further terms. The straight mean forecast therefore hides an increasingly uncertain range of possible future paths.
Illustrative case study
Fictional case: reviewing a drifting baseline
A fictional facilities team monitors a continuous equipment-performance index. The index appears to rise for several weeks, then flatten, so the team compares a fixed trend with a local linear trend model.
It evaluates forecasts at several horizons using only information available at each forecast origin. It inspects whether the estimated slope reacts usefully to sustained changes or mostly follows noise. The team also distinguishes smoothed historical trends from estimates that were available in real time.
For long-horizon planning, it examines whether continuing the latest slope is plausible and considers a damped or otherwise constrained alternative. No improvement is claimed simply because the fitted historical curve looks flexible.
Common misconceptions and mistakes
Local linear trend does not mean fitting an unrelated straight line to each small data window. The state evolution links successive levels and slopes through a probabilistic model.
A stochastic slope is different from a fixed drift. Setting slope-disturbance variance to zero makes the slope constant through time, although its value may still be uncertain. Setting level-disturbance variance to zero while retaining slope disturbances gives a related smooth-trend formulation.
The level and slope estimates should not be treated as independent after filtering. Their covariance affects forecasts and updates. Nor should Gaussian forecasts be used uncritically for counts or inherently bounded quantities, where support restrictions may require transformation or a different observation model.
Business use
This model is useful when a series has evolving growth or decline and an interpretable trend component is valuable. Its extra flexibility should be earned through forecast performance, rather than assumed to be better than a simpler baseline.
Specify the time unit: a slope per day differs from a slope per month, and irregular time gaps require a suitable transition formulation. Review residuals for seasonality, outliers and changes the model cannot explain. Report horizon-specific uncertainty and assess whether long-range extrapolation remains credible for the intended operational decision.
People also ask
Does the forecast mean curve automatically bend?
In the basic model, with no future data or extra components, the mean extends the current slope linearly. Individual simulated paths can bend because their slopes change.
Can the slope become negative?
Yes. The standard unconstrained Gaussian specification permits either sign.
What separates it from a local level model?
The additional slope state creates expected growth or decline and introduces another source of uncertainty.
Check your understanding
In the worked example, what is the three-period observation variance if slope-disturbance variance is set to zero while all other assumptions stay fixed?
Answer: It is 3 times 1 + 4 = 7. Removing slope disturbances removes the additional 1.25 variance contribution, but level and observation noise remain.
Related terms
- Local level model
- Kalman filter
- Smoothing
- state-space model
- stochastic trend
- random walk with drift
- forecast uncertainty
Learn next
Propagate the full two-by-two state covariance through several forecast steps. Then compare a stochastic slope with a fixed and a damped slope, using forward-in-time evaluation at the horizons that matter.
More in Probabilistic machine learning
- LDA-HMM - LDA-HMM is a composite text model combining latent Dirichlet allocation's document-level topics with a hidden Markov model's local sequence structure.
- Leapfrog integrator - The leapfrog integrator is a numerical method that advances position and momentum through alternating half and full steps.
- Likelihood tempering - Likelihood tempering changes the influence of observed data by raising the likelihood to a power before combining it with the prior.
- Log-Gaussian Cox process - A log-Gaussian Cox process is a model for randomly located events in which the logarithm of an underlying event intensity follows a Gaussian process.
- Log-sum-exp trick - The log-sum-exp trick is a numerically stable way to calculate the logarithm of a sum of exponentials.
- Manifestation shift - Manifestation shift is a change in how a target condition produces the observable physical characteristics used to recognize it.
Sources
Primary implementation derivation: statsmodels, State space modeling: Local Linear Trends: https://www.statsmodels.org/stable/examples/notebooks/generated/statespace_local_linear_trend.html
Primary model documentation: TensorFlow Probability, LocalLinearTrend: https://www.tensorflow.org/probability/api_docs/python/tfp/sts/LocalLinearTrend
The three-horizon variance calculation and facilities case are original teaching examples.
Previous: Local level model Next: Local model