generated from sekulovskin/gitbook-template-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bain_sensitivity.Rmd
42 lines (33 loc) · 1.46 KB
/
bain_sensitivity.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
# Sensitivity analysis using `bain`
Load `bain`:
```{r}
library(bain)
```
Please see @hoijtink2019tutorial for further elaborations.
Note that, most the code below can be replaced by a call to the function `bain_sensitivity`. See the help file for this function for further instructions (call `?bain_sensitivity`).
## The `t-test` example from 3.1.1
```{r include=FALSE}
x<-sesamesim$postnumb[which(sesamesim$sex==1)]
y<-sesamesim$postnumb[which(sesamesim$sex==2)]
ttest <- t_test(x,y,paired = FALSE, var.equal = TRUE)
```
First we test the same hypotheses as in 3.1.1 using the default value `fraction = 1` (i.e., $1*b$).
```{r}
# set a seed value
set.seed(100)
# test hypotheses with bain. The names of the means are x and y.
results <- bain(ttest, "x = y; x > y; x < y", fraction = 1)
```
```{r}
print(results)
```
Now we execute the sensitivity analysis by interactively changing the `fraction` argument to be equal to 2 and 3, respectively (i.e., $2*b$ and $3*b$):
```{r}
results2 <- bain(ttest, "x = y; x > y; x < y", fraction = 2)
results3 <- bain(ttest, "x = y; x > y; x < y", fraction = 3)
```
```{r}
print(results2)
print(results3)
```
The $BF_{0u}$ changes from 11.58 when `fraction` = 1 to 8.19 and 6.68, when `fraction` = 2 and 3, respectively. This stems from the fact that the value of the **complexity**, which is the proportion (density) of the prior distribution that is supported by the (*null*) hypothesis at hand changes, thus changing the values of resulting BF's.