Skip to content

Commit

Permalink
chater 5 update
Browse files Browse the repository at this point in the history
  • Loading branch information
김상돈 authored and 김상돈 committed Feb 27, 2022
1 parent 5fe5534 commit 9a7497f
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 31 deletions.
6 changes: 3 additions & 3 deletions 05-the-forecasters-toolbox.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,15 @@ ACF 그래프에서 각 막대가 신뢰구간 안에 포함되는지를 볼 때

이러한 문제를 해결하기 위해, 처음 $l$개의 자기상관이 백색잡음과정에서 얻은 것과 다른지 여부를 검정한다. 자기상관 값의 그룹에 대한 검정을 여러가지 물품을 담고 있는 여행 가방이라는 프랑스 단어를 빌려 포트맨토 검정이라 한다.

이러한 검정 중에 하나를 **Box-Pierce 검정**이라 하며, 통계량은 다음과 같다.
이러한 검정 중에 하나를 **Box-Pierce 검정**이라 하며, 검정통계량은 다음과 같다.

$$
Q = T \sum_{k=1}^l r_k^2,
$$

$l$은 최대 시차를 의미하며, $T$는 관측값의 수를 의미한다. 만약 $r_k$가 0에 가깝다면, $Q$는 작아질 것이다. 만약 $r_k$가 크다면, $Q$는 커질 것이다. 우리는 비계절형 데이터의 경우 $l = 10$으로 제안하며, 계절형 데이터의 경우 $l = 2m$으로 제안한다. 이 때, $m$은 계절 주기를 의미한다. 그러나 $l$이 클 때 검정결과가 좋지 않으므로, 이러한 값들이 $T/5$보다 크다면, $l = T/5$를 사용할 것을 권장한다.

관련된 다른 검정(더 정확한)**Ljung-Box test**이다.
관련된 다른 검정 방법은 (더 정확한)**Ljung-Box 검정**이다. 포트맨토 검정의 경우 $T$가 작을 경우 $Q$가 작아지므로, 실제로는 모형이 적합하지 않은데도 모형이 잘 적합되는 것으로 판정하는 경향이 있다. Ljung and box(1978)은 이를 보완하여 다음과 같은 검정통계량을 제안했다.

$$
Q^{*} = T(T+2) \sum_{k=1}^l (T-k)^{-1}r_k^2.
Expand All @@ -425,7 +425,7 @@ $Q$, $Q^{*}$ 둘 다, 유의하지 않다(즉, p-value가 상대적으로 크다

구글 일일 종가를 예측하는데 적합할 수 있는 대안은 `drift method`입니다. `tidy()`함수는 과거 데이터에서 관찰된 일일 평균 변화를 측정하는 하나의 매개변수인 표류 계수(drift coefficient)를 보여준다.


v
```{r}
fit <- google_2015 %>% model(RW(Close ~ drift()))
tidy(fit)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions docs/01-intro-to-tsibble.md

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions docs/02-timeseries-decomposition.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,18 @@ white.noise.r

```
#> # A tsibble: 100 x 3 [1]
#> t y yavg
#> <int> <dbl> <dbl>
#> 1 1 -0.819 NA
#> 2 2 -1.04 NA
#> 3 3 0.149 NA
#> 4 4 0.825 NA
#> 5 5 -0.996 -0.377
#> 6 6 0.415 -0.130
#> 7 7 -1.91 -0.304
#> 8 8 0.114 -0.311
#> 9 9 -1.87 -0.851
#> 10 10 -0.852 -0.822
#> t y yavg
#> <int> <dbl> <dbl>
#> 1 1 -0.126 NA
#> 2 2 0.126 NA
#> 3 3 0.635 NA
#> 4 4 2.25 NA
#> 5 5 0.772 0.732
#> 6 6 -0.612 0.634
#> 7 7 0.758 0.761
#> 8 8 -0.771 0.480
#> 9 9 -0.414 -0.0534
#> 10 10 -0.241 -0.256
#> # … with 90 more rows
```

Expand Down
6 changes: 3 additions & 3 deletions docs/05-the-forecasters-toolbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,15 +618,15 @@ ACF 그래프에서 각 막대가 신뢰구간 안에 포함되는지를 볼 때

이러한 문제를 해결하기 위해, 처음 $l$개의 자기상관이 백색잡음과정에서 얻은 것과 다른지 여부를 검정한다. 자기상관 값의 그룹에 대한 검정을 여러가지 물품을 담고 있는 여행 가방이라는 프랑스 단어를 빌려 포트맨토 검정이라 한다.

이러한 검정 중에 하나를 **Box-Pierce 검정**이라 하며, 통계량은 다음과 같다.
이러한 검정 중에 하나를 **Box-Pierce 검정**이라 하며, 검정통계량은 다음과 같다.

$$
Q = T \sum_{k=1}^l r_k^2,
$$

$l$은 최대 시차를 의미하며, $T$는 관측값의 수를 의미한다. 만약 $r_k$가 0에 가깝다면, $Q$는 작아질 것이다. 만약 $r_k$가 크다면, $Q$는 커질 것이다. 우리는 비계절형 데이터의 경우 $l = 10$으로 제안하며, 계절형 데이터의 경우 $l = 2m$으로 제안한다. 이 때, $m$은 계절 주기를 의미한다. 그러나 $l$이 클 때 검정결과가 좋지 않으므로, 이러한 값들이 $T/5$보다 크다면, $l = T/5$를 사용할 것을 권장한다.

관련된 다른 검정(더 정확한)**Ljung-Box test**이다.
관련된 다른 검정 방법은 (더 정확한)**Ljung-Box 검정**이다. 포트맨토 검정의 경우 $T$가 작을 경우 $Q$가 작아지므로, 실제로는 모형이 적합하지 않은데도 모형이 잘 적합되는 것으로 판정하는 경향이 있다. Ljung and box(1978)은 이를 보완하여 다음과 같은 검정통계량을 제안했다.

$$
Q^{*} = T(T+2) \sum_{k=1}^l (T-k)^{-1}r_k^2.
Expand Down Expand Up @@ -667,7 +667,7 @@ $Q$, $Q^{*}$ 둘 다, 유의하지 않다(즉, p-value가 상대적으로 크다

구글 일일 종가를 예측하는데 적합할 수 있는 대안은 `drift method`입니다. `tidy()`함수는 과거 데이터에서 관찰된 일일 평균 변화를 측정하는 하나의 매개변수인 표류 계수(drift coefficient)를 보여준다.


v

```r
fit <- google_2015 %>% model(RW(Close ~ drift()))
Expand Down
5 changes: 3 additions & 2 deletions docs/chap5.html
Original file line number Diff line number Diff line change
Expand Up @@ -707,12 +707,12 @@ <h2><span class="header-section-number">4.6</span> 자기상관에 대한 포트
<p>ACF 그래프를 확인하는 것뿐만 아니라, <span class="math inline">\(r_k\)</span>을 개별적으로 다루는 것 대신 <span class="math inline">\(r_k\)</span>의 전체 집합을 하나의 그룹으로 생각하여 자기 상관에 대한 검정을 할 수 있다. <span class="math inline">\(r_k\)</span>가 lag <span class="math inline">\(k\)</span>의 자기상관이라는 것을 상기하자.</p>
<p>ACF 그래프에서 각 막대가 신뢰구간 안에 포함되는지를 볼 때, 우리는 암시적으로 다중 검정을 수행하고 있으며, 각 검정은 False Positive를 줄 가능성이 적다. 이러한 검정이 충분히 완료되면, 적어도 하나는 False Positive를 제공할 가능성이 높으므로, 실제로 그렇지 않은 경우에도 잔차에 자기상관이 남아있다고 결론을 내릴 수 있다.</p>
<p>이러한 문제를 해결하기 위해, 처음 <span class="math inline">\(l\)</span>개의 자기상관이 백색잡음과정에서 얻은 것과 다른지 여부를 검정한다. 자기상관 값의 그룹에 대한 검정을 여러가지 물품을 담고 있는 여행 가방이라는 프랑스 단어를 빌려 포트맨토 검정이라 한다.</p>
<p>이러한 검정 중에 하나를 <strong>Box-Pierce 검정</strong>이라 하며, 통계량은 다음과 같다.</p>
<p>이러한 검정 중에 하나를 <strong>Box-Pierce 검정</strong>이라 하며, 검정통계량은 다음과 같다.</p>
<p><span class="math display">\[
Q = T \sum_{k=1}^l r_k^2,
\]</span></p>
<p><span class="math inline">\(l\)</span>은 최대 시차를 의미하며, <span class="math inline">\(T\)</span>는 관측값의 수를 의미한다. 만약 <span class="math inline">\(r_k\)</span>가 0에 가깝다면, <span class="math inline">\(Q\)</span>는 작아질 것이다. 만약 <span class="math inline">\(r_k\)</span>가 크다면, <span class="math inline">\(Q\)</span>는 커질 것이다. 우리는 비계절형 데이터의 경우 <span class="math inline">\(l = 10\)</span>으로 제안하며, 계절형 데이터의 경우 <span class="math inline">\(l = 2m\)</span>으로 제안한다. 이 때, <span class="math inline">\(m\)</span>은 계절 주기를 의미한다. 그러나 <span class="math inline">\(l\)</span>이 클 때 검정결과가 좋지 않으므로, 이러한 값들이 <span class="math inline">\(T/5\)</span>보다 크다면, <span class="math inline">\(l = T/5\)</span>를 사용할 것을 권장한다.</p>
<p>관련된 다른 검정(더 정확한)<strong>Ljung-Box test</strong>이다.</p>
<p>관련된 다른 검정 방법은 (더 정확한)<strong>Ljung-Box 검정</strong>이다. 포트맨토 검정의 경우 <span class="math inline">\(T\)</span>가 작을 경우 <span class="math inline">\(Q\)</span>가 작아지므로, 실제로는 모형이 적합하지 않은데도 모형이 잘 적합되는 것으로 판정하는 경향이 있다. Ljung and box(1978)은 이를 보완하여 다음과 같은 검정통계량을 제안했다.</p>
<p><span class="math display">\[
Q^{*} = T(T+2) \sum_{k=1}^l (T-k)^{-1}r_k^2.
\]</span></p>
Expand All @@ -731,6 +731,7 @@ <h2><span class="header-section-number">4.6</span> 자기상관에 대한 포트
#&gt; 1 GOOG NAIVE(Close) 7.91 0.637</code></pre>
<p><span class="math inline">\(Q\)</span>, <span class="math inline">\(Q^{*}\)</span> 둘 다, 유의하지 않다(즉, p-value가 상대적으로 크다). 따라서 우리는 잔차가 백색잡음과정과 다르지 않다고 결론지을 수 있다.</p>
<p>구글 일일 종가를 예측하는데 적합할 수 있는 대안은 <code>drift method</code>입니다. <code>tidy()</code>함수는 과거 데이터에서 관찰된 일일 평균 변화를 측정하는 하나의 매개변수인 표류 계수(drift coefficient)를 보여준다.</p>
<p>v</p>
<div class="sourceCode" id="cb43"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb43-1"><a href="chap5.html#cb43-1" aria-hidden="true" tabindex="-1"></a>fit <span class="ot">&lt;-</span> google_2015 <span class="sc">%&gt;%</span> <span class="fu">model</span>(<span class="fu">RW</span>(Close <span class="sc">~</span> <span class="fu">drift</span>()))</span>
<span id="cb43-2"><a href="chap5.html#cb43-2" aria-hidden="true" tabindex="-1"></a><span class="fu">tidy</span>(fit)</span></code></pre></div>
<pre><code>#&gt; # A tibble: 1 × 7
Expand Down
11 changes: 7 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<meta name="author" content="슬기로운통계생활" />


<meta name="date" content="2022-02-20" />
<meta name="date" content="2022-02-27" />

<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
Expand Down Expand Up @@ -277,6 +277,8 @@
<li class="chapter" data-level="4.3.2" data-path="chap5.html"><a href="chap5.html#residuals"><i class="fa fa-check"></i><b>4.3.2</b> residuals</a></li>
</ul></li>
<li class="chapter" data-level="4.4" data-path="chap5.html"><a href="chap5.html#residuals-diagnistics"><i class="fa fa-check"></i><b>4.4</b> Residuals diagnistics</a></li>
<li class="chapter" data-level="4.5" data-path="chap5.html"><a href="chap5.html#예-구글-일일-종가-예측"><i class="fa fa-check"></i><b>4.5</b> 예 : 구글 일일 종가 예측</a></li>
<li class="chapter" data-level="4.6" data-path="chap5.html"><a href="chap5.html#자기상관에-대한-포트맨토-검정"><i class="fa fa-check"></i><b>4.6</b> 자기상관에 대한 포트맨토 검정</a></li>
</ul></li>
<li class="chapter" data-level="" data-path="references.html"><a href="references.html"><i class="fa fa-check"></i>References</a></li>
<li class="divider"></li>
Expand All @@ -302,15 +304,15 @@ <h1>
<div id="header">
<h1 class="title">시계열 공략집 with R</h1>
<p class="author"><em><a href="https://www.youtube.com/c/statisticsplaybook">슬기로운통계생활</a></em></p>
<p class="date"><em>2022-02-20</em></p>
<p class="date"><em>2022-02-27</em></p>
</div>
<div id="들어가며" class="section level1 unnumbered">
<h1>들어가며</h1>
<p><img src="image/timeseries-playbook.png" /></p>
<p>슬기로운 통계생활에서 2022년을 맞이하여 새롭게 시작한 시계열 스터디 내욜을 정리해놓은 레포입니다!</p>
<p>본 교재의 많은 내용은 다음 두 권의 R 시계열 교과서를 기반으로 하고 있습니다.</p>
<ul>
<li>주교재 - Forecasting: Principles and Practice (이하 <code>fpp3</code>, <span class="citation"><a href="#ref-hyndman2018forecasting" role="doc-biblioref">Hyndman and Athanasopoulos</a> (<a href="#ref-hyndman2018forecasting" role="doc-biblioref">2018</a>)</span>)<br />
<li>주교재 - Forecasting: Principles and Practice (이하 <code>fpp3</code>, <span class="citation">Hyndman and Athanasopoulos (<a href="#ref-hyndman2018forecasting" role="doc-biblioref">2018</a>)</span>)<br />
실습 위주의 R 코드가 많은 책입니다. R 코드를 따라 치면서 시계열 입문하기 쉽게 되어있는 책이라서 선정하였습니다.
<ul>
<li><a href="https://amzn.to/3A0trIZ">아마존 구매</a></li>
Expand Down Expand Up @@ -343,7 +345,8 @@ <h3 id="알아두기">
알아두기
</h3>
<p>
<strong>하이라이팅과 주석들을 나중에 따로 볼 수 있다.</strong> 자주 방문하시는 분들은 가입하시고 사용하시면 여러모로 편할 것이다.
<strong>하이라이팅과 주석들을 나중에 따로 볼 수 있다.</strong> 자주
방문하시는 분들은 가입하시고 사용하시면 여러모로 편할 것이다.
</p>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "시계열 공략집 with R"
author: "[슬기로운통계생활](https://www.youtube.com/c/statisticsplaybook)"
date: "2022-02-20"
date: "2022-02-27"
site: bookdown::bookdown_site
output: bookdown::gitbook
documentclass: book
Expand Down Expand Up @@ -50,7 +50,8 @@ With Applications in R [@cryer2008time]

<div class="rmdnote">
<h3 id="알아두기">알아두기</h3>
<p><strong>하이라이팅과 주석들을 나중에 따로 볼 수 있다.</strong> 자주 방문하시는 분들은 가입하시고 사용하시면 여러모로 편할 것이다.</p>
<p><strong>하이라이팅과 주석들을 나중에 따로 볼 수 있다.</strong> 자주
방문하시는 분들은 가입하시고 사용하시면 여러모로 편할 것이다.</p>
</div>


Expand Down
2 changes: 1 addition & 1 deletion docs/search_index.json

Large diffs are not rendered by default.

0 comments on commit 9a7497f

Please sign in to comment.