Statistics Glossary → Unobserved Components Model (Structural Time Series)
Unobserved Components Model (Structural Time Series)analysis
A structural time series model that writes a series as the sum of components that cannot be observed directly (level, slope, season, cycle and irregular) and estimates them with the Kalman filter to produce forecasts.
Concept
The observed value of a series can be thought of as the sum of several hidden movements: a slowly changing 'true' level, the growth rate of that level (slope), a regularly repeating seasonal pattern, fluctuations lasting several years (cycle), and random departures such as measurement noise (the irregular component). None of these components is measured directly; only their sum is seen. An unobserved components model defines each component explicitly and estimates it from the data, so the result can be interpreted directly: 'is the level rising, is the seasonal pattern changing?'
In the simplest form, the local level model, the observed value is the sum of a level and noise, and the level changes by small random steps each period: y_t = μ_t + ε_t, μ_t = μ_{t−1} + η_t. The variances of the components (how much ε and η fluctuate) are estimated by maximum likelihood; if a component's variance comes out as zero, that component is constant over time. The Kalman filter updates the components at each period in the light of the new observation, while smoothing uses all the data to give the best estimate of each period's components.
The model assumes that the components and errors are normally distributed and independent of one another; in a suitable model the residuals should resemble white noise. Missing observations are handled naturally by the Kalman filter. Which components enter the model is a choice that affects the results; specifying components more complex than needed can make the estimation unstable.
When to use it
- To separate a series' trend, season and cycle into interpretable components, study how they change over time, and forecast with the same model.
- The model is suitable when the series has missing observations, or when the effect of an intervention (e.g. a policy change) is to be measured with an explanatory variable.
- If a purely descriptive decomposition is enough, use STL; for short-term forecasting without the need to interpret components, ARIMA or Holt-Winters can also be used.
An everyday example
A district water authority is examining ten years of monthly water consumption. Consumption rises slowly as the population grows (level and slope), increases every summer because of garden watering (season), and shows odd jumps in some months because of meter-reading errors (irregular). An unobserved components model estimates these parts separately: the smoothed level shows the 'true' consumption trend, cleaned of reading errors. A small seasonal variance says the summer increase has hardly changed over the years, and a positive slope says demand is still growing; the authority plans the need for a new reservoir around this forecast.
Parameters in MerQur
Explanatory variables
Concept: Explanatory variables are known factors that affect the series outside the components; their coefficients are assumed constant over time. The effect of an intervention can be measured with a dummy variable that is 1 after the relevant period and 0 before it; forecasting also requires the future values of these variables.
Everyday example: If the water authority introduced a tiered tariff at the start of year five, a 'post-tariff = 1' dummy is added. A coefficient of, say, −900 m³ means that, after accounting for the other components, the tariff permanently lowered monthly consumption by about 900 m³.
What it does: Estimates the coefficients of the explanatory variables as time-constant state elements with a diffuse initialisation. For forecasting, explanatory values are needed in the rows after the last observation (y empty).
Effect on the result: Adjusts the component variances and the likelihood for the explanatory variable.
On the validation data: 1899 shift dummy in Nile: coefficient -247.777777778 (SE 28.4352014427), diffuse log-likelihood -618.109264921; the level variance is near zero at the boundary (6.3e-12).
Date and Value
Concept: The date column orders the observations and lets the seasonal period be set from the frequency of the data (monthly, quarterly); the value is the series to be modelled. Missing values are not dropped: the Kalman filter passes through that period by predicting it from the components' previous state.
Everyday example: If two months of the consumption record are missing, the model does not skip them; it predicts a sensible value for those months from the level and seasonal components and carries on from there.
What it does: The date column or numeric time (1871, 1960.25 etc.) orders the series and determines the seasonal period automatically; if absent, the observation order is used and the period must be entered manually. Value is the series to be modelled; a missing y is carried by the Kalman filter.
Effect on the result: Determines the period and the time axis; the model results do not change.
On the validation data: Nile 1871-1970 annual series.
Level (Stochastic (variance estimated), Fixed (variance = 0))
Concept: A stochastic level changes by small random steps each period (a random walk), and the variance of these steps is estimated from the data. With a fixed level the level is the same throughout, and all the fluctuation is left to the other components.
Everyday example: If the consumption level shifts over the years as new neighbourhoods join the district, a stochastic level follows this shift. If the level truly never changes, a fixed level gives a simpler and more stable model.
What it does: With the stochastic choice the level changes as a random walk; with the fixed choice the level variance is 0 and is not estimated.
Effect on the result: Determines the level variance and the likelihood.
On the validation data: Nile local level: irregular variance 15098.5183822, level variance 1469.17631948, diffuse log L -632.545625103, AIC 1269.09125021; forecast h = 1: 798.367294458 (SE 143.526537676).
Slope (Stochastic (variance estimated), Fixed (variance = 0), None)
Concept: The slope is the level's growth per period. A stochastic slope lets the growth rate itself change over time (local linear trend); a fixed slope assumes the level changes by the same average amount each period (local level with drift), and 'none' assumes the level has no systematic direction.
Everyday example: If the district's population grows at a similar pace every year, a fixed slope is enough and gives the average monthly increase in consumption in m³. If the growth rate speeds up and slows down with waves of migration, a stochastic slope is more suitable.
What it does: Adds the slope (trend) component. Stochastic level with stochastic slope is the local linear trend; fixed slope is a local level with drift.
Effect on the result: Determines trend flexibility and the forecast slope.
On the validation data: In the log UKgas structural model the slope variance is 7.90125050019e-06; in the log AirPassengers model the slope variance is at the boundary ~0, diffuse log L 228.160107091.
Seasonal (Dummy, Trigonometric, None), [Parameters] check box (stochastic seasonal) and Seasonal period
Concept: The seasonal component represents the regularly repeating pattern. In dummy form each seasonal position has its own effect; in trigonometric form the pattern is built as a sum of sine and cosine waves. A stochastic season lets the pattern change slowly over the years; otherwise the pattern is the same every year.
Everyday example: For monthly water consumption the period is 12, and the July-August peak appears in the seasonal component. If restrictions on garden watering have been introduced in recent years, the summer peak shrinks; a stochastic season can follow this change.
What it does: Dummy seasonal has s - 1 states; in trigonometric seasonal the harmonics come with the same variance. If the check box is unchecked, the seasonal pattern is fixed. The period is determined automatically from the time column (monthly 12, quarterly 4).
Effect on the result: Changes the seasonal variance, the likelihood and the components.
On the validation data: log AirPassengers 1949-1958, fixed slope + trigonometric seasonal: diffuse log L 180.626169348, AIC -355.252338696; forecast h = 1: 5.86992279605.
Other components: Damped stochastic cycle (check box)
Concept: A cycle is a fluctuation that, unlike a season, is not tied to the calendar, lasts several years and gradually dies out. The cycle's period, damping rate (rho) and disturbance variance are estimated from the data.
Everyday example: If a run of dry years is followed by wet ones, water consumption may show ups and downs lasting several years alongside the seasonal pattern that repeats every summer. The cycle component separates this wave from the trend and the season.
What it does: Adds a damped stochastic cycle: rho (0 < rho < 1), period (> 2) and the cycle disturbance variance are estimated; stationary initialisation.
Effect on the result: The likelihood may be multimodal; the best log-likelihood is chosen by multi-start ML.
On the validation data: log UKgas + cycle: log L 74.3729701701, rho 0.943095451234, period 2.48293153236.
Other components: Irregular (check box; default on)
Concept: The irregular component is random departures, such as measurement error, that do not carry over from one period to the next. If it is switched off, the observed series is taken to be exactly the sum of the components and all the fluctuation is loaded onto the other components.
Everyday example: If meter-reading errors show consumption too high one month and too low the next, this fluctuation falls into the irregular component. With the irregular switched off, the model reads these jumps as real changes in the level.
What it does: Adds the measurement (irregular) component; if turned off, the irregular variance is taken as 0.
Effect on the result: Determines the tightness of the smoothing.
On the validation data: On in all examples.
Forecast horizon (default 12; 0 = no forecast)
Concept: Sets how many periods beyond the last observation are forecast. Forecasts are obtained by carrying the components' latest state forward; uncertainty grows with the horizon because the components' random changes add up at each step.
Everyday example: With 12 steps the authority gets a consumption forecast for every month of the next year. In a model with only a local level the forecast is the same for every month; with a slope and a season added, the forecast both rises and peaks in the summer months.
What it does: Determines the number of forecast steps after the last observation; forecast intervals are given.
Effect on the result: Affects only the forecast output.
On the validation data: Nile: forecast, SE and intervals are given for h = 1 and h = 5.
Ljung-Box lag (0 = automatic)
Concept: The Ljung-Box test checks whether autocorrelation remains in the one-step forecast errors (residuals); the lag is how many periods back the test looks. A significant result shows that the model has missed some of the series' structure.
Everyday example: If autocorrelation at lag 12 remains in the residuals of the water consumption model, the seasonal component may be specified inadequately. With 24 lags the test looks over a two-year window.
What it does: Determines the lag of the Ljung-Box test of the residuals; in automatic it is 2s in a seasonal model, otherwise 10 (at most n/5). The degrees of freedom are lag - q + 1.
Effect on the result: Affects only the diagnostic output.
On the validation data: Nile Q(10) 13.1952325025 (p 0.153969362612); AirPassengers 1949-1958 Q(24) 22.5734939166; UKgas Q(8) 8.31986263068.
Confidence Level (%90, %95, %99, Other (custom))
Concept: Sets how much confidence the forecast intervals carry; the higher the confidence level, the wider the interval. The interval is the plausible range of a single future observation.
Everyday example: If the consumption forecast for next July is 52,000 m³, the 95% interval might be [47,000, 57,000]. When planning reservoir capacity, the upper limit of the interval is used to reduce the risk of shortage.
What it does: Determines the confidence level of the forecast intervals.
Effect on the result: Changes only the intervals.
On the validation data: Compared at 95%.
Save level, seasonal and one-step prediction to the dataset (check box)
Concept: Adds the smoothed components and the one-step forecasts to the data set as new columns. The smoothed level is each period's 'true' level estimated using all the data.
Everyday example: By plotting the smoothed level column alongside raw consumption, the authority can show its board the trend cleaned of reading errors. The one-step forecasts show how accurate the model was in past months.
What it does: Adds the smoothed level, seasonal and one-step prediction as new columns.
Effect on the result: Does not change the calculation.
On the validation data: Nile smoothed level (t = 1) 1111.66867856.
Example on real data
Data: Nile, Durbin and Koopman 2001, R datasets
Variables: date time (year), value value (annual Nile flow); local level model (no slope, no season)
- Question: Can the annual Nile flow (1871-1970) be decomposed into a level component and measurement noise?
- Model: Local level (stochastic level + irregular) model, exact diffuse Kalman filter and maximum likelihood.
- Variances: Irregular σ²_ε = 15098.52 (SE 3145.55, p < .001); level σ²_η = 1469.18 (SE 1280.37, p = .251); signal-to-noise ratio about 0.10.
- Fit: log L = -632.55, AIC = 1269.09, BIC = 1274.28; the level component is significant (χ²(1) = 158.08, p < .001).
- Diagnostics: Ljung-Box Q(10) = 13.20, df = 9, p = .154; Jarque-Bera p = .977; the residuals are white noise and normal.
- Forecast: 798.37 for 1971 (95% CI [517.06, 1079.67]); in the local level model the forecast is flat and the interval widens with the horizon.
- APA: Local level model, log L = -632.55, AIC = 1269.09; σ²(irregular) = 15098.52, σ²(level) = 1469.18; Q(10) = 13.20, p = .154.
Related concepts
State-space model and the Kalman filterForecast horizon and forecast intervalSeasonality and seasonal periodLjung-Box (portmanteau) testRandom starts and local optimaPrediction intervalMaximum likelihood (ML) estimation
The numbers in the examples are MerQur's output on independent, publicly available validation data; see the MerQur Technical Note for details.