From 382a0ee30c56ac44fd37ffbc57874a8597ffdeb0 Mon Sep 17 00:00:00 2001 From: Berend Bouvy Date: Fri, 29 Nov 2024 09:19:01 +0100 Subject: [PATCH] Final points from Christiaan --- book/time_series/acf.md | 58 +++++------------------------- book/time_series/ar_exercise.ipynb | 7 ++-- book/time_series/intro.md | 2 +- book/time_series/stationarity.md | 2 +- 4 files changed, 14 insertions(+), 55 deletions(-) diff --git a/book/time_series/acf.md b/book/time_series/acf.md index f33e1fb..ab6659d 100644 --- a/book/time_series/acf.md +++ b/book/time_series/acf.md @@ -12,7 +12,7 @@ Let us assume an arbitrary (discrete) stationary time series, $S=[S_1,S_2,...,S_ The *formal* (or: theoretical) autocovariance is defined as $$ -Cov(S_t, S_{t-\tau}) =\mathbb{E}(S_tS_{t-\tau})-\mu^2 +Cov(S_t, S_{t+\tau}) =\mathbb{E}(S_tS_{t+\tau})-\mu^2 =c_{\tau} $$ @@ -23,7 +23,7 @@ We have that $Cov(S_t, S_{t-\tau}) =Cov(S_t, S_{t+\tau})$. Show that the covariance can be written as: -$$Cov(S_t, S_{t-\tau}) = \mathbb{E}(S_tS_{t-\tau})-\mu^2 +$$Cov(S_t, S_{t+\tau}) = \mathbb{E}(S_tS_{t+\tau})-\mu^2 =c_{\tau}$$ @@ -31,12 +31,12 @@ $$Cov(S_t, S_{t-\tau}) = \mathbb{E}(S_tS_{t-\tau})-\mu^2 :class: tip, dropdown $$ - Cov(S_t, S_{t-\tau})= \mathbb{E}[(S_t - \mathbb{E}(S_t))(S_{t-\tau} - \mathbb{E}(S_{t-\tau}))]\\ - = \mathbb{E}((S_t-\mu)(S_{t-\tau}-\mu))\\ - = \mathbb{E}(S_tS_{t-\tau} - \mu S_{t-\tau} - \mu S_t + \mu^2)\\ - = \mathbb{E}(S_tS_{t-\tau}) - \mu \mathbb{E}(S_{t-\tau}) - \mu \mathbb{E}(S_t) + \mu^2\\ -= \mathbb{E}(S_tS_{t-\tau}) - 2\mu^2 + \mu^2\\ -= \mathbb{E}(S_tS_{t-\tau}) - \mu^2\\ + Cov(S_t, S_{t+\tau})= \mathbb{E}[(S_t - \mathbb{E}(S_t))(S_{t+\tau} - \mathbb{E}(S_{t+\tau}))]\\ + = \mathbb{E}((S_t-\mu)(S_{t+\tau}-\mu))\\ + = \mathbb{E}(S_tS_{t+\tau} - \mu S_{t+\tau} - \mu S_t + \mu^2)\\ + = \mathbb{E}(S_tS_{t+\tau}) - \mu \mathbb{E}(S_{t+\tau}) - \mu \mathbb{E}(S_t) + \mu^2\\ += \mathbb{E}(S_tS_{t+\tau}) - 2\mu^2 + \mu^2\\ += \mathbb{E}(S_tS_{t+\tau}) - \mu^2\\ $$ ```` ::: @@ -46,7 +46,6 @@ $$ Prove that $Cov(S_t, S_{t-\tau}) =Cov(S_t, S_{t+\tau})$: - ````{admonition} Solution :class: tip, dropdown @@ -77,7 +76,7 @@ $$ Cov(S_t, S_{t-\tau}) = Cov(S_t, S_{t+\tau})$$ The *formal* autocorrelation is defined as $$ -r_{\tau} = \mathbb{E}(S_tS_{t-\tau}) +r_{\tau} = \mathbb{E}(S_tS_{t+\tau}) $$ ```{note} @@ -265,42 +264,3 @@ $$ ``` ::: - - - - diff --git a/book/time_series/ar_exercise.ipynb b/book/time_series/ar_exercise.ipynb index 53e23db..d9044e8 100644 --- a/book/time_series/ar_exercise.ipynb +++ b/book/time_series/ar_exercise.ipynb @@ -148,8 +148,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "AR(1) vs AR(2) test statistic: -2 Critical value: 3.841458820694124\n", - "Fail to reject AR(1)\n", + "AR(1) vs AR(2) test statistic: 65.46386398456401 Critical value: 3.841458820694124\n", + "Reject AR(1) in favor of AR(2)\n", "AR(2) vs AR(3) test statistic: 3.5318291727430835 Critical value: 3.841458820694124\n", "Fail to reject AR(2)\n" ] @@ -186,7 +186,6 @@ "dof = 1\n", "crit = chi2.ppf(0.95, dof)\n", "test_stat = n * np.log(rss1 / rss2)\n", - "test_stat = -2 \n", "print('AR(1) vs AR(2) test statistic:', test_stat, 'Critical value:', crit)\n", "\n", "if test_stat > crit:\n", @@ -215,7 +214,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [ { diff --git a/book/time_series/intro.md b/book/time_series/intro.md index 8b8c6dc..b761b92 100644 --- a/book/time_series/intro.md +++ b/book/time_series/intro.md @@ -9,5 +9,5 @@ Next, we will consider stationary time series, meaning that the statistical prop :width: 600px :align: center -Recorded and expected global warming from 1960 to 2100 ([Huseien, Shah (2021)](https://www.mdpi.com/2071-1050/13/17/9720)) +Recorded and expected global warming from 1960 to 2100, from IPCC report ([Masson-Delmotte, et al. (20219)](https://www.researchgate.net/profile/Peter-Marcotullio/publication/330090901_Sustainable_development_poverty_eradication_and_reducing_inequalities_In_Global_warming_of_15C_An_IPCC_Special_Report/links/6386062b48124c2bc68128da/Sustainable-development-poverty-eradication-and-reducing-inequalities-In-Global-warming-of-15C-An-IPCC-Special-Report.pdf)) ``` diff --git a/book/time_series/stationarity.md b/book/time_series/stationarity.md index 7ebcf32..e0cc6ac 100644 --- a/book/time_series/stationarity.md +++ b/book/time_series/stationarity.md @@ -3,7 +3,7 @@ ```{admonition} Definition -A stationary time series is a stochastic process whose statistical properties do not depend on the time at which it is observed. +A stationary time series $S(t)$ is a stochastic process whose statistical properties do not depend on the time at which it is observed. ``` This means that parameters such as *mean* and *(co)variance* should remain constant over time and not follow any trend, seasonality or irregularity.