Skip to content

Commit

Permalink
add missig model
Browse files Browse the repository at this point in the history
  • Loading branch information
aloctavodia committed Mar 26, 2024
1 parent 96ef336 commit 674ca9e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
30 changes: 30 additions & 0 deletions code/Chp_04.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4148,6 +4148,36 @@
"var_names=[\"β0_scaled\", \"β1_scaled\"], figsize=(10, 3), combined=True)\n",
"plt.savefig(\"../fig/neg_vs_mlb.png\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise 5 - model_t2"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ans = pd.read_csv('../data/anscombe.csv')\n",
"\n",
"x_4 = ans[ans.group == 'IV']['x'].values\n",
"y_4 = ans[ans.group == 'IV']['y'].values\n",
"\n",
"with pm.Model() as model_t2:\n",
" α = pm.Normal('α', mu=0, sigma=100)\n",
" β = pm.Normal('β', mu=0, sigma=1)\n",
" ϵ = pm.HalfCauchy('ϵ', 5)\n",
" ν = pm.Exponential('ν', 1/30)\n",
" #ν = pm.Gamma('ν', mu=20, sigma=15)\n",
" #ν = pm.Gamma('ν', 2, 0.1)\n",
"\n",
" y_pred = pm.StudentT('y_pred', mu=α + β * x_4, sigma=ϵ, nu=ν, observed=y_4)\n",
" idata_t2 = pm.sample(2000)"
]
}
],
"metadata": {
Expand Down
45 changes: 45 additions & 0 deletions code/data/anscombe.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
group,x,y
I,10.0,8.04
I,8.0,6.95
I,13.0,7.58
I,9.0,8.81
I,11.0,8.33
I,14.0,9.96
I,6.0,7.24
I,4.0,4.26
I,12.0,10.84
I,7.0,4.82
I,5.0,5.68
II,10.0,9.14
II,8.0,8.14
II,13.0,8.74
II,9.0,8.77
II,11.0,9.26
II,14.0,8.1
II,6.0,6.13
II,4.0,3.1
II,12.0,9.13
II,7.0,7.26
II,5.0,4.74
III,10.0,7.46
III,8.0,6.77
III,13.0,12.74
III,9.0,7.11
III,11.0,7.81
III,14.0,8.84
III,6.0,6.08
III,4.0,5.39
III,12.0,8.15
III,7.0,6.42
III,5.0,5.73
IV,8.0,6.58
IV,8.0,5.76
IV,8.0,7.71
IV,8.0,8.84
IV,8.0,8.47
IV,8.0,7.04
IV,8.0,5.25
IV,19.0,12.5
IV,8.0,5.56
IV,8.0,7.91
IV,8.0,6.89

0 comments on commit 674ca9e

Please sign in to comment.