From 188901be763e51f89e49854ed9605e871d167cd9 Mon Sep 17 00:00:00 2001 From: Kylen Padayachee Date: Wed, 5 Sep 2018 10:33:10 +0200 Subject: [PATCH] Fixed tags --- .../posts/performing_bayes_t_test_excel.Rmd | 15 +++++++++----- .../posts/performing_bayes_t_test_excel.html | 20 +++++++++++++------ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/content/posts/performing_bayes_t_test_excel.Rmd b/content/posts/performing_bayes_t_test_excel.Rmd index b7fa478..6581b25 100644 --- a/content/posts/performing_bayes_t_test_excel.Rmd +++ b/content/posts/performing_bayes_t_test_excel.Rmd @@ -1,10 +1,14 @@ --- -title: "Performing a Bayesian T-Test in Excel" -author: "Kylen" -date: "2018-08-22" -output: html_document +title: Performing a Bayesian T-Test in Excel +author: Kylen +date: 2018-09-03 +slug: bayes-t-test-excel +categories: + - Excel +tags: + - Excel + - Bayes --- -\usepackage{amsmath} #Objectives In this post we will compare two samples for differences in their means. The catch is that we want to implement this in a spreadsheet programme (MS Excel), so that it can be easily used by people with no background in R/Python. Microsoft have included many functions allowing for standard frequentist analyses to be performed in Excel, however we will use these functions in order to perform bayesian inference. @@ -45,6 +49,7 @@ Since the t-distribution is symmetric, if we assume an improper uniform prior fo #Inference With the requisite setup out of the way we can now move on to performing inference. Here I will present the bayesian analgues of common frequentist inferential techniques. + ##Hypothesis Testing Firstly we set up our 2 hypotheses: $$H_0: \gamma = 0 \\ diff --git a/content/posts/performing_bayes_t_test_excel.html b/content/posts/performing_bayes_t_test_excel.html index c3eb2bf..8d88efe 100644 --- a/content/posts/performing_bayes_t_test_excel.html +++ b/content/posts/performing_bayes_t_test_excel.html @@ -1,13 +1,17 @@ --- -title: "Performing a Bayesian T-Test in Excel" -author: "Kylen" -date: "2018-08-22" -output: html_document +title: Performing a Bayesian T-Test in Excel +author: Kylen +date: 2018-09-03 +slug: bayes-t-test-excel +categories: + - Excel +tags: + - Excel + - Bayes --- -

Objectives

In this post we will compare two samples for differences in their means. The catch is that we want to implement this in a spreadsheet programme (MS Excel), so that it can be easily used by people with no background in R/Python. Microsoft have included many functions allowing for standard frequentist analyses to be performed in Excel, however we will use these functions in order to perform bayesian inference.

@@ -49,13 +53,17 @@

Posterior Distributions

Inference

-

With the requisite setup out of the way we can now move on to performing inference. Here I will present the bayesian analgues of common frequentist inferential techniques. ##Hypothesis Testing Firstly we set up our 2 hypotheses: \[H_0: \gamma = 0 \\ +

With the requisite setup out of the way we can now move on to performing inference. Here I will present the bayesian analgues of common frequentist inferential techniques.

+
+

Hypothesis Testing

+

Firstly we set up our 2 hypotheses: \[H_0: \gamma = 0 \\ H_1: \gamma \sim \mbox{Unif}(-m,m)\]

Or, in the one sided case: \[H_1: \gamma \sim \mbox{Unif}(0,m)\]

For a Bayesian Hypothesis test we calculate the odds ratio: \(K = \frac{Pr(T=t|H_1)}{Pr(T=t|H_0)}\)

This shows how much the data favour the \(H_1\) compared to \(H_0\). The denominator is simply the density of the t-distibution with \(\nu\) degrees of freedom at the observed value of \(t\).

The numerator is given by \(\int_{-m}^m \frac{1}{2m}f_\nu(t-\gamma\frac{s_t}{s_\Delta}) d\gamma\), where \(f_\nu\) is the pdf of a standard t distribution with \(\nu\) degrees of freedom. This simplifies to \(\frac{s_\Delta}{2ms_t}(F_\nu(t+m\frac{s_t}{s_\Delta})-F_\nu(t-m\frac{s_t}{s_\Delta}))\). In the one sided case it instead simplifies to : \(\frac{s_\Delta}{ms_t}(F_\nu(t)-F_\nu(t-m\frac{s_t}{s_\Delta}))\)

Excel contains functions for both the pdf and cdf of the t-distribution (the T.Dist function, which has a boolean parameter ‘cumulative’).

+

Credibility Intervals

Recall that with an improper uniform prior \(\gamma\frac{s_t}{s_\Delta} - t\) has an approximate t-distribution with \(\nu\) degrees of freedom. Excel has a function for the inverse cumulative t-distribution (T.Inv) so we can obtain a percentile \(\alpha\) of \(\gamma\) as \((F_\nu^{-1}(\alpha)+t)\frac{s_\Delta}{s_t}\). We can create credibility intervals using this. As the t-distribution is symmetric, a symmetric interval will also be the minimum width (highest probability density) interval.