Wednesday, December 29, 2010

Comparing two proportions : Statistics : A bayesian Perspective : Chapter 8


Chapter 8 deals with comparisons between two populations : the subject population and a control or comparison group.
Assuming a range of 11 discrete proportions from 0.0 to 1.0, and two populations, we build what is in effect a 3D model. We will look at each slice individually. The concept is no different than outlined in chapter 6, although the mechanics are a little different .
The first slice is for the prior probabilities. With each population having 11 models, the combination of two populations means there are 11 * 11 equals 121 models in total. In this example, there is a flat prior.
Model Dc- >
0.00000000
0.10000000
0.20000000
0.30000000
0.40000000
0.50000000
0.60000000
0.70000000
0.80000000
0.90000000
1.00000000

Model Dn ->












1.0
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909
0.9
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909
0.8
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909
0.7
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909
0.6
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909
0.5
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909
0.4
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909
0.3
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909
0.2
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909
0.1
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909
0.0
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.00826446
0.09090909

0.09090909
0.09090909
0.09090909
0.09090909
0.09090909
0.09090909
0.09090909
0.09090909
0.09090909
0.09090909
0.09090909
1.00000000
The diagonal represents those models where the proportion in each population is the same.
The second slice is the likelihood of each model. The likelihood of each of the 11 models for each population is calculated. The likelihood for each of the 121 models is calculated by multiplying the likelihoods for pairs of models.

Model Dc- >
0.00000000
0.00254187
0.00219902
0.00087200
0.00020897
0.00003052
0.00000242
0.00000008
0.00000000
0.00000000
0.00000000

Model Dn ->
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0.00000000
1.0
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.02287679
0.9
0.0000000
0.0000581
0.0000503
0.0000199
0.0000048
0.0000007
0.0000001
0.0000000
0.0000000
0.0000000
0.0000000
0.00879609
0.8
0.0000000
0.0000224
0.0000193
0.0000077
0.0000018
0.0000003
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.00203467
0.7
0.0000000
0.0000052
0.0000045
0.0000018
0.0000004
0.0000001
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.00031346
0.6
0.0000000
0.0000008
0.0000007
0.0000003
0.0000001
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.00003052
0.5
0.0000000
0.0000001
0.0000001
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.00000161
0.4
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.00000003
0.3
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.00000000
0.2
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.00000000
0.1
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.00000000
0.0
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000
0.0000000















0.0000000
0.0000866
0.0000749
0.0000297
0.0000071
0.0000010
0.0000001
0.0000000
0.0000000
0.0000000
0.0000000
The third slice is to multiply likelihoods by prior probabilities:

0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1.0
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.9
0.000000000
0.000000481
0.000000416
0.000000165
0.000000040
0.000000006
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.8
0.000000000
0.000000185
0.000000160
0.000000063
0.000000015
0.000000002
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.7
0.000000000
0.000000043
0.000000037
0.000000015
0.000000004
0.000000001
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.6
0.000000000
0.000000007
0.000000006
0.000000002
0.000000001
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.5
0.000000000
0.000000001
0.000000001
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.4
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.3
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.2
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.1
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.0
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
0.000000000
The fourth slice is to divide the product of likelihood * prior by the total of the products, which gives the posterior probability.

0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1



1.0
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000

0
0.9
0.000
0.292
0.252
0.100
0.024
0.004
0.000
0.000
0.000
0.000
0.000
0.672

0.604617
0.8
0.000
0.112
0.097
0.038
0.009
0.001
0.000
0.000
0.000
0.000
0.000
0.258

0.206644
0.7
0.000
0.026
0.022
0.009
0.002
0.000
0.000
0.000
0.000
0.000
0.000
0.060

0.041825
0.6
0.000
0.004
0.003
0.001
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.009

0.005523
0.5
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.001

0.000448
0.4
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000

1.89E-05
0.3
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000

2.95E-07
0.2
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000

7.7E-10
0.1
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000

2.64E-14
0.0
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000
0.000

0














0.000
0.434
0.376
0.149
0.036
0.005
0.000
0.000
0.000
0.000
0.000
1.000

0.859075
















0
0.04341453
0.075117704
0.04468078
0.01427673
0.00260617
0.00024758
9.3401E-06
7.1638E-08
1.2451E-11
0
0.18035291


From the spreadsheet above, it is possible to read off various probability subsets; for example , the probability of D0.3 is 14.9%.
The null hypothesis is represented by the diagonal

No comments: