Skip to content

[AR1] Update unfinished suggestions #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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