/
hierarchical.Rmd
47 lines (30 loc) · 1.88 KB
/
hierarchical.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
title: "hierarchical"
author: David Reynolds
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(knitr)
```
## Motivating Question
Suppose we have results from several experiments on the effect of a certain drug. How should we use this data to estimate the drug's effect? What is the error of the estimate?
To make this concrete,
```{r}
experiment = LETTERS[1:8]
effect = rnorm(8)
df = data.frame(experiment = experiment, effect = effect)
kable(df)
```
### Option A
Choose the best study. Clearly this is not optimal since you are not making use of the informatin you have; however, very smart people choose this option all the time.
### Option B
Use some results from statistics class.
Our data then consists of $(\bar{y}_j, \sigma_j)$ for $j \in 1,...,J$, where $\bar{y}_j$ is the mean effect from experiment $j$, and $\sigma_j$ its standard error.
Our simplest route is to assume that $\bar{y_j} \underset {iid}{\sim} N(\mu, \sigma_j)$, and to estimate $\mu$. Conceptually, this assumes that each experiment provides an independent estimate of the drug's *true* effect, $\mu$.
Under this assumption, we can obtain an estimator $\hat{\mu}$ by maximizing the likelihood of our data.
\begin{align}
\hat{\mu} &= \underset{\mu}{\arg\max} \prod_j (2 \pi \sigma_j^2)^{-1/2} \exp \bigg(- \frac{( \bar{y}_j -\mu )^2 }{2 \sigma_j^2} \bigg) \\
&= \frac{\sum_j \bar{y}_j/ \sigma_j^2 }{\sum_j 1/ \sigma_j^2}
\end{align}
This seems okay. However, because the experimental conditions, for example the age or other attributes of the test subjects, length of the experiment and so on, are likely to affect the results, it does not feel right to assume the are no differences at all between the groups - an assumption we make by assuming a common $\mu$. In statistician jargon, we would like to acknowledge the *unobserved heterogeneity* across groups (experiments).