Skip to content

Commit

Permalink
[AR1] Update unfinished suggestions (#513)
Browse files Browse the repository at this point in the history
* [AR1] Update unfinished suggestions

* Update ar1_processes.md

* misc

---------

Co-authored-by: John Stachurski <[email protected]>
  • Loading branch information
SylviaZhaooo and jstac authored Jul 10, 2024
1 parent 473e58e commit fac9a2f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lectures/ar1_processes.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ plt.rcParams["figure.figsize"] = (11, 5) #set default figure size

## The AR(1) model

The *AR(1) model* (autoregressive model of order 1) takes the form
The **AR(1) model** (autoregressive model of order 1) takes the form

```{math}
:label: can_ar1
X_{t+1} = a X_t + b + c W_{t+1}
```

where $a, b, c$ are scalar-valued parameters.
where $a, b, c$ are scalar-valued parameters

(Equation {eq}`can_ar1` is sometimes called a **stochastic difference equation**.)

For example, $X_t$ might be

Expand Down Expand Up @@ -88,6 +90,7 @@ Iterating backwards from time $t$, we obtain
$$
X_t = a X_{t-1} + b + c W_t
= a^2 X_{t-2} + a b + a c W_{t-1} + b + c W_t
= a^3 X_{t-3} + a^2 b + a^2 c W_{t-2} + b + c W_t
= \cdots
$$

Expand Down Expand Up @@ -200,7 +203,7 @@ Notice that, in the figure above, the sequence $\{ \psi_t \}$ seems to be conver
This is even clearer if we project forward further into the future:

```{code-cell} python3
def plot_density_seq(ax, mu_0=-3.0, v_0=0.6, sim_length=60):
def plot_density_seq(ax, mu_0=-3.0, v_0=0.6, sim_length=40):
mu, v = mu_0, v_0
for t in range(sim_length):
mu = a * mu + b
Expand All @@ -220,7 +223,7 @@ For example, this alternative density sequence also converges to the same limit.

```{code-cell} python3
fig, ax = plt.subplots()
plot_density_seq(ax, mu_0=3.0)
plot_density_seq(ax, mu_0=4.0)
plt.show()
```

Expand Down Expand Up @@ -255,7 +258,7 @@ We can confirm this is valid for the sequence above using the following code.

```{code-cell} python3
fig, ax = plt.subplots()
plot_density_seq(ax, mu_0=3.0)
plot_density_seq(ax, mu_0=4.0)
mu_star = b / (1 - a)
std_star = np.sqrt(c**2 / (1 - a**2)) # square root of v_star
Expand Down

1 comment on commit fac9a2f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.