In the vignette for the R package dlm: link on page 12, the author runs the function dlmSmooth
to smooth the data and the function returns an object which is assigned to gasSmooth
. Now, gasSmooth$s
is described in the package help as:
Time series (or matrix) of smoothed values of the state vectors. The series starts one time unit before the first observation.
They say:
Based on the fitted model, we can compute the smoothing estimates of the states. This can be used to obtain a decomposition of the data into a smooth trend plus a stochastic seasonal component, subject to measurement error.
and then run:
gasSmooth <- dlmSmooth(lGas, mod = dlmGas)
x <- cbind(lGas, dropFirst(gasSmooth$s[,c(1,3)]))
colnames(x) <- c("Gas", "Trend", "Seasonal")
The author in the vignette selects to plot columns 1 and 3 of this timeseries matrix, but how do they know that these states represent the smoothed trend and the seasonal trend?