Report#
Submit one set of handwritten answers per group at 12:30.
These questions on paper for the last hour (11:30-12:30h) of this session assess your understanding of the subject, your mathematical reasoning and insight, as well as interpretation of results, not your ability to recall specific Python syntax. There are five questions.
Computers, phones, online resources and AI tools are not permitted. You may use only handwritten notes prepared earlier in the session. Show the formulas and reasoning that support your answers; numerical or graphical answers without an explanation will not receive full credit.
Re-cap of some useful equation form the textbook#
This summarizes some useful equations from the chapter on Time series analysis of the MUDE textbook:
Time series: \(Y=\mathrm{Ax}+\epsilon\)
BLUE estimator for signal-of-interest: \(\hat X=(\mathrm{A}^T\Sigma_{Y}^{-1}\mathrm{A})^{-1}\mathrm{A}^T\Sigma_{Y}^{-1}Y\)
Stationary noise time series (residuals): \(S:=\hat \epsilon =Y-\mathrm{A}\hat X\)
Predicted signal-of-interest: \(\hat Y_{signal}=\mathrm{A}_p\hat X\), where \(\mathrm{A}_p\) is the design matrix describing the functional relationship between the future values \(Y_p\) and \(\mathrm{x}\).
Stochastic noise based on the AR model: \(\hat \epsilon_p = \Sigma_{Y_pY}\Sigma_Y^{-1}\hat \epsilon\), where \(\Sigma_{Y_pY}\) is the covariance matrix between the future values \(Y_p\) and the observed values \(Y\).
Forecasted values of the time series: \(\hat Y_p=\mathrm{A}_p\hat X+\hat \epsilon_p\).
The maximum likelihood estimator of autocovariance: \(\hat C_{\tau} = \frac{1}{m}\sum_{i=1}^{m-\tau}(S_{i+\tau}-\mu)(S_i-\mu), \hspace{2px} \tau=0,1,...,m-1\)
The normalized autocovariance estimator: \(\hat \rho_{\tau} = \frac{\hat C_{\tau}}{\hat C_0}, \hspace{5px}\tau = 0,...,m-1 \implies \hat \rho_0 = 1\)
A zero-mean first order autoregressive process: \(S_t = \phi S_{t-1}+\epsilon_{t}, \hspace{5px} -1\leq\phi<1, \hspace{5px} t=2,...,m\) , where \(\epsilon_t\) is an i.i.d. noise process, e.g. distributed as \(\epsilon_t\sim N(0,\sigma_{\epsilon}^2)\).
Re-cap of the Python notebook#
In the Python notebook you used a time series consisting of 30 years of daily temperature data, resulting in quite a long time series with 10950 measurements (or data points). The functional model in part 2 consisted of the yearly cyclic behavior and a linear trend (with offset and slope).
In order to formulate the stochastic model, you analyzed in part 3 the normalized autocovariance function (ACF) \(\hat \rho_{\tau}\), with the residuals \(S := \hat \epsilon = Y - A \hat X\), being stationary, of the functional model in part 2 as input. You employed an Autoregressive noise process of order 1, AR(1), to model the ‘memory’ in the residuals in the stochastic model, with coefficient \(\phi\) of about 0.8.
With these ingredients, functional and stochastic model, the daily temperature was predicted a few days ahead. The graph below shows this prediction. The last month of data is shown in blue, the fitted or estimated functional model, covering the trend and the annual cycle, in orange, and the two green dots as predictions for respectively one and five days ahead.
|
|---|
Prediction of daily mean temperature, one and five days ahead, based on 30 years of data. |
Goal of this assignment#
With this assignment you are supposed to demonstrate that you understand the workflow of analyzing a time series and making a prediction ahead, and that you are able to actually apply it to a simple problem. Intentionally we go here for a small-scale and simple problem as to allow for reasonable computational effort without a PC, laptop or smartphone.
The problem#
The water-level in a basin has been observed for five days in a row. The observations read \(y_1=21\), \(y_2=22\), \(y_3=20\), \(y_4=19\) and \(y_5=18\), for time \(t=1,2,3,4,5\) days. We set-up a functional model, analyze the residuals, and use an AR(1) noise process for the stochastic model, and finally we make a prediction for the water-level at day 6, i.e. at time \(t=6\) days.
Question 1 - Functional model#
We keep things simple and assume that the water-level is constant, and consequently use a functional model only with an offset. So, the functional model contains only one unknown parameter (the water-level, which is constant). There is no slope, there is no cyclic behavior. Using (unweighted) least-squares estimation, determine the estimate for the offset, i.e. the unknown water-level.
Solution — Question 1#
The \(A\)-matrix for \(E(Y)=Ax\) in this problem is simple and reads \(A=(1,1,1,1,1)^T\), a column-vector with just 5 times the value of 1. Then unweighted least-squares implies \(\hat X=(A^T A)^{-1} A^T Y\) and this leads to effectively computing the average of the five measurements \(y_1\), \(y_2\), \(y_3\), \(y_4\) and \(y_5\) (as \((A^T A)^{-1}=\frac{1}{5}\)). The estimate reads \(\hat x=20\).
Question 2 - Residuals#
Compute the residuals after fitting the functional model, i.e. \(\hat \epsilon = Y - A \hat X\), which will be our (stationary) noise process \(S\) for further analyses below.
Solution — Question 2#
With the given equation for the residuals \(\hat \epsilon = Y - A \hat X\), and the result of Question 1, we get \(\hat \epsilon = (21, 22, 20, 19, 18)^T - (1, 1, 1, 1, 1)^T 20 = (1, 2, 0, -1, -2)^T\).
Question 3 - ACF#
Using the given expression for the maximum likelihood estimator of autocovariance \(\hat C_{\tau}\), compute the normalized autocovariance estimate \(\hat \rho_{\tau}=\frac{\hat c_{\tau}}{\hat c_{0}}\), but only for \(\tau=1\). You can verify that the mean of the noise process (vector \(\hat \epsilon\)) in this case equals zero.
Solution - Question 3#
Estimated autocovariance \(\hat c_{\tau=0} = 1^2 + 2^2 + 0^2 + (-1)^2 + (-2)^2 = 10\). Estimated autocovariance \(\hat c_{\tau=1} = 1\cdot2 + 2\cdot0 + 0\cdot(-1) + (-1)\cdot(-2)=4\). Then \(\hat \rho_{\tau=1}=\frac{\hat c_{\tau=1}}{\hat c_{\tau=0}}=\frac{4}{10}\).
Note that the autocovariance at lag 0 and at lag 1 have been computed without the factor \(\cfrac{1}{m}\), as it cancels anyway in the ratio for the normalized autocovariance.
Question 4 - AR(1) noise process#
With an AR(1) noise process, the coefficient \(\phi\), describing the dependence on the preceding measurement through \(S_t = \phi S_{t-1} + \epsilon_t\), is simply the normalized autocorrelation for \(\tau=1\), computed with Question 3. Hence, we have \(\phi=\hat \rho_{\tau=1}\). Can you describe, in your own words, how this value of \(\phi\) will impact the prediction?
Solution - Question 4#
An AR(1) noise process will look back only one epoch (measurement) into the past. The given relation is \(S_t = \phi S_{t-1} + \epsilon_t\), and if you want, you can make the prediction for time \(t+1\) at the current time \(t\) explicit by writing \(S_{t+1} = \phi S_{t} + \epsilon_{t+1}\). This means that the noise component at the next epoch \(t+1\) simply equals the value of \(\phi\) times the noise component at the current epoch \(t\), i.e. \(S_t\). Coefficient \(\phi\) measures how much of the present noise propagates into the next epoch. The term \(\epsilon\) represents zero mean white noise, and hence, the best we can do in predicting is to take a sample value equal to zero for this one. For prediction we are effectively left with: \(S_{t+1} = \phi S_{t}\).
Question 5 - Prediction#
Finally we put things together and compute a prediction of the water-level at time \(t=6\) days.
Solution - Question 5#
The equation for predicting a future value reads \(\hat Y_p = A_p \hat X + \hat \epsilon_p\). Predicting the functional model ahead in time is easy in this case. The water-level was assumed to be constant, so \(A_p=1\) is just another factor of 1.0. The estimated \(\hat x\) is just extended to \(t=6\). Predicting the stochastic model ahead in time was covered in Question 4: the residual at \(t=5\) equals \(\hat \epsilon_{t=5}=-2\), and \(\hat \epsilon_{t=6} = \phi \hat \epsilon_{t=5}\). In this way the ‘memory’-effect of the noise process is propagated into the prediction.
Putting things together yields: \(\hat y_p = 1 \cdot 20 + 0.4 \cdot (-2) = 19.2\), where \(\hat y_p\) denotes the predicted measurement, at some future time (in our case \(t=6\)), generically indicated by index ‘p’, with the ‘p’ of prediction.
How did things go? (Optional)#
After the session, your group may share feedback with us (i.e. the teaching team) about the notebook and the written questions, or use this space to let us know if you ran into challenges while working on this GA, and if you have any feedback to report.
By Christian Tiberius, Delft University of Technology. CC BY 4.0, more info on the Credits page of Workbook.
