You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/howto/hypothesis_testing.ipynb
+40-4Lines changed: 40 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@
60
60
" * Posterior probability statements\n",
61
61
" * Highest Density Intervals (HDIs)\n",
62
62
" * Regions of Practical Equivalence (ROPE)\n",
63
-
" * Bayes Factors using ArviZ's `plot_bf` function\n",
63
+
" * Bayes Factors\n",
64
64
"\n",
65
65
"We'll work through a scenario where we want to know if the mean of some metric (e.g., monthly profit) is different from zero."
66
66
]
@@ -77,6 +77,22 @@
77
77
":::"
78
78
]
79
79
},
80
+
{
81
+
"cell_type": "markdown",
82
+
"id": "6292d775",
83
+
"metadata": {},
84
+
"source": [
85
+
"### Parameter estimation vs model comparison\n",
86
+
"\n",
87
+
"The Bayesian evaluation of null values can proceed in two distinct ways (see {cite:t}`kruschke2011bayesian`):\n",
88
+
"\n",
89
+
"#### Parameter estimation\n",
90
+
"The parameter estimation approach considers a model where the parameter is allowed to vary (which includes the null value). We then compute the posterior distribution of this value and come up with some kind of decision rule which determines if we accept or reject the null value.\n",
91
+
"\n",
92
+
"#### Model comparison\n",
93
+
"Two competing models are considered. The first model assumes that the null value is true, or fixed, and the second model allows a range of values. The models are compared to see which is more supported by the data. An example would be in assessing if a coin is fair (null hypothesis) or biased (alternative hypothesis) - we would set up a model where the coin has a fixed probability of heads (0.5) and another model where the probability of heads is a free parameter. Readers are referred to the PyMC examples focussing on {ref}`pymc:model_comparison` for more details."
"The intuition we can get from this is that if the ROPE is narrow, we would require quite a high level of precision to accept the null hypthesis. The posterior distribution would have to be very tightly centered around the null value to have a large probability of being within the ROPE."
550
+
]
551
+
},
528
552
{
529
553
"cell_type": "markdown",
530
554
"id": "46cf08f2",
@@ -538,11 +562,15 @@
538
562
"id": "de465219",
539
563
"metadata": {},
540
564
"source": [
541
-
"{cite:t}`kruschke2018rejecting` outlines the HDI+ROPE decision rule, which is summarised in the figure taken from that paper:\n",
565
+
"{cite:t}`kruschke2018rejecting` outlines the HDI+ROPE decision rule, which is summarised in the figure taken from that paper. Namely:\n",
566
+
"\n",
567
+
"* **Accept the null value**: If the HDI falls entirely within the ROPE. The HDI does not need to include the null value.\n",
568
+
"* **Reject the null value**: If the HDI falls entirely outside the ROPE. \n",
569
+
"* **Remain undecided**: If the HDI is partially or fully outside the ROPE.\n",
542
570
"\n",
543
-
"\n",
571
+
"In our case, looking back at our posterior + ROPE plot above, we would remain undecided because the HDI does not fall entirely outside nor within the ROPE.\n",
544
572
"\n",
545
-
"In our case, we would remain undecided because the HDI does not fall entirely outside nor within the ROPE."
573
+
""
546
574
]
547
575
},
548
576
{
@@ -602,6 +630,14 @@
602
630
"We can see that the probability of $\\mu=0$ has gone _down_ after observing the data. This is reflected in the value of $BF_{01}=0.54$ in that it is less than 1."
603
631
]
604
632
},
633
+
{
634
+
"cell_type": "markdown",
635
+
"id": "4283bdd3",
636
+
"metadata": {},
637
+
"source": [
638
+
"Readers are referred to {ref}`Bayes_factor` for a more detailed look at Bayes Factors."
Copy file name to clipboardExpand all lines: examples/howto/hypothesis_testing.myst.md
+28-4Lines changed: 28 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,7 @@ In this tutorial, we'll use PyMC to:
45
45
* Posterior probability statements
46
46
* Highest Density Intervals (HDIs)
47
47
* Regions of Practical Equivalence (ROPE)
48
-
* Bayes Factors using ArviZ's `plot_bf` function
48
+
* Bayes Factors
49
49
50
50
We'll work through a scenario where we want to know if the mean of some metric (e.g., monthly profit) is different from zero.
51
51
@@ -59,6 +59,18 @@ However, in real-world scenarios—such as policy-making, resource allocation, o
59
59
60
60
+++
61
61
62
+
### Parameter estimation vs model comparison
63
+
64
+
The Bayesian evaluation of null values can proceed in two distinct ways (see {cite:t}`kruschke2011bayesian`):
65
+
66
+
#### Parameter estimation
67
+
The parameter estimation approach considers a model where the parameter is allowed to vary (which includes the null value). We then compute the posterior distribution of this value and come up with some kind of decision rule which determines if we accept or reject the null value.
68
+
69
+
#### Model comparison
70
+
Two competing models are considered. The first model assumes that the null value is true, or fixed, and the second model allows a range of values. The models are compared to see which is more supported by the data. An example would be in assessing if a coin is fair (null hypothesis) or biased (alternative hypothesis) - we would set up a model where the coin has a fixed probability of heads (0.5) and another model where the probability of heads is a free parameter. Readers are referred to the PyMC examples focussing on {ref}`pymc:model_comparison` for more details.
71
+
72
+
+++
73
+
62
74
## Setting up the example
63
75
64
76
Rather than focus on a complex example, we'll pick a trivial one were we are simply estimating the mean of a single variable. This will allow us to focus on the hypothesis testing. The important thing is what we do with our MCMC samples, not the particulars of the model.
@@ -179,15 +191,23 @@ Third time in a row, `arviz` has our back and can plot the ROPE and HDIs.
The intuition we can get from this is that if the ROPE is narrow, we would require quite a high level of precision to accept the null hypthesis. The posterior distribution would have to be very tightly centered around the null value to have a large probability of being within the ROPE.
195
+
196
+
+++
197
+
182
198
### HDI+ROPE decision criteria
183
199
184
200
+++
185
201
186
-
{cite:t}`kruschke2018rejecting` outlines the HDI+ROPE decision rule, which is summarised in the figure taken from that paper:
202
+
{cite:t}`kruschke2018rejecting` outlines the HDI+ROPE decision rule, which is summarised in the figure taken from that paper. Namely:
187
203
188
-

204
+
***Accept the null value**: If the HDI falls entirely within the ROPE. The HDI does not need to include the null value.
205
+
***Reject the null value**: If the HDI falls entirely outside the ROPE.
206
+
***Remain undecided**: If the HDI is partially or fully outside the ROPE.
189
207
190
-
In our case, we would remain undecided because the HDI does not fall entirely outside nor within the ROPE.
208
+
In our case, looking back at our posterior + ROPE plot above, we would remain undecided because the HDI does not fall entirely outside nor within the ROPE.
209
+
210
+

191
211
192
212
+++
193
213
@@ -212,6 +232,10 @@ We can see that the probability of $\mu=0$ has gone _down_ after observing the d
212
232
213
233
+++
214
234
235
+
Readers are referred to {ref}`Bayes_factor` for a more detailed look at Bayes Factors.
0 commit comments