Hypothesis testing simulation: comparing chocolate

There were two kinds of chocolate: Sam's Choice or Cote d'Or; the latter selling for about $2.90 and the former $1.90, each a 3.5 ounce bar of 70% cocoa. Each of n=15 of you provided a preference of chocolate sample 0 or chocolate sample 1 (one person abstained and I dis-regarded that datum). I had randomized which type of chocolate was labeled as '0' or '1', using the code 0=Cote d'Or and 1=Sam's and the random sequence of 0s and 1s given by R being given in the table below.


ID#  Random# O-label 1-label  Resp  Pref
 1	1     	C	S	1    S	
 2	1	C	S	0    C
 3	1	C	S	0    C
 4	1	C	S	0    C
 5	0	S	C	0    S
 6	0	S	C	1    C
 7	0	S	C	NONE
 8	0	S	C	1    C
 9	1	C	S	0    C
10 	0	S	C	0    S
11	0	S	C	1    C
12	1	C	S	1    S
13	0	S	C	0    S
14	1	C	S	1    S
15	0	S	C	0    S
16	0	S	C	0    S

In class, we chose a value x.star such that P(X >= x.star) is less than or equal to .05, and x.star is as close to 7.5 as possible. By trial and error:

x <- 11:15
y <- 1-pbinom(x-1,15,.5)
cbind(x,round(y,4))
      x
[1,] 11 0.0592
[2,] 12 0.0176
[3,] 13 0.0037
[4,] 14 0.0005
[5,] 15 0.0000

Thus x.star = the critical number is 12 and we reject H_0 in favor of H_1 iff X >= 12; this test has an alpha of .0176.

The data above show x=7; so we cannot reject the null.