Skip to content

Commit

Permalink
update pages
Browse files Browse the repository at this point in the history
  • Loading branch information
HumphreyYang committed Dec 13, 2023
1 parent 37d7207 commit cc9d4ee
Show file tree
Hide file tree
Showing 29 changed files with 970 additions and 973 deletions.
60 changes: 30 additions & 30 deletions _sources/ar1_bayes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "6013ae77",
"id": "c10d71ae",
"metadata": {},
"source": [
"# Posterior Distributions for AR(1) Parameters\n",
Expand All @@ -13,7 +13,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "47810a32",
"id": "c35ed4c0",
"metadata": {
"tags": [
"hide-output"
Expand All @@ -27,7 +27,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "67b516d9",
"id": "0e69bbed",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -51,7 +51,7 @@
},
{
"cell_type": "markdown",
"id": "b9cfb0da",
"id": "a6787ce2",
"metadata": {},
"source": [
"This lecture uses Bayesian methods offered by [pymc](https://www.pymc.io/projects/docs/en/stable/) and [numpyro](https://num.pyro.ai/en/stable/) to make statistical inferences about two parameters of a univariate first-order autoregression.\n",
Expand Down Expand Up @@ -151,7 +151,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "adf685b2",
"id": "93be6790",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -179,7 +179,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6c2cd2ae",
"id": "2474928c",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -189,7 +189,7 @@
},
{
"cell_type": "markdown",
"id": "1d6051fe",
"id": "697bbd31",
"metadata": {},
"source": [
"Now we shall use Bayes' law to construct a posterior distribution, conditioning on the initial value of $y_0$.\n",
Expand All @@ -207,7 +207,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0c363eef",
"id": "a990e832",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -228,7 +228,7 @@
},
{
"cell_type": "markdown",
"id": "d012b3b3",
"id": "09b81bea",
"metadata": {},
"source": [
"[pmc.sample](https://www.pymc.io/projects/docs/en/latest/api/generated/pymc.sample.html?highlight=sample#pymc.sample) by default uses the NUTS samplers to generate samples as shown in the below cell:"
Expand All @@ -237,7 +237,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e35861a5",
"id": "7cf090ae",
"metadata": {
"tag": [
"hide-output"
Expand All @@ -252,7 +252,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3cf2578c",
"id": "e4213657",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -262,7 +262,7 @@
},
{
"cell_type": "markdown",
"id": "e732852d",
"id": "cc38cb31",
"metadata": {},
"source": [
"Evidently, the posteriors aren't centered on the true values of $.5, 1$ that we used to generate the data.\n",
Expand All @@ -278,7 +278,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "77d718a3",
"id": "3916f902",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -290,7 +290,7 @@
},
{
"cell_type": "markdown",
"id": "6c0f469a",
"id": "4923a1a6",
"metadata": {},
"source": [
"Now we shall compute a posterior distribution after seeing the same data but instead assuming that $y_0$ is drawn from the stationary distribution.\n",
Expand All @@ -307,7 +307,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3c3e105f",
"id": "8c729b82",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -331,7 +331,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "06b2bb89",
"id": "72dec655",
"metadata": {
"tag": [
"hide-output"
Expand All @@ -348,7 +348,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "bb6c6194",
"id": "b65286b0",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -359,7 +359,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5698c3f5",
"id": "b97c5a83",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -371,7 +371,7 @@
},
{
"cell_type": "markdown",
"id": "f08b887e",
"id": "fb857ef1",
"metadata": {},
"source": [
"Please note how the posterior for $\\rho$ has shifted to the right relative to when we conditioned on $y_0$ instead of assuming that $y_0$ is drawn from the stationary distribution.\n",
Expand All @@ -393,7 +393,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ba67d93f",
"id": "9731b733",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -427,7 +427,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b8e53fba",
"id": "34eac730",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -446,7 +446,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d458bd18",
"id": "6efe88a6",
"metadata": {
"tag": [
"hide-output"
Expand All @@ -468,7 +468,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1ecdaa52",
"id": "13ac5f54",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -478,7 +478,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5dc0b1db",
"id": "55357b0c",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -487,7 +487,7 @@
},
{
"cell_type": "markdown",
"id": "333854a4",
"id": "a7585d5b",
"metadata": {},
"source": [
"Next, we again compute the posterior under the assumption that $y_0$ is drawn from the stationary distribution, so that\n",
Expand All @@ -502,7 +502,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7177f488",
"id": "c3ed0cef",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -525,7 +525,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "1c055d7c",
"id": "d6331c3c",
"metadata": {
"tag": [
"hide-output"
Expand All @@ -547,7 +547,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ebd11acb",
"id": "544e9719",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -557,7 +557,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ad2ebb99",
"id": "3c766b4f",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -566,7 +566,7 @@
},
{
"cell_type": "markdown",
"id": "d6bc153e",
"id": "a03d726f",
"metadata": {},
"source": [
"Look what happened to the posterior!\n",
Expand Down
Loading

0 comments on commit cc9d4ee

Please sign in to comment.