-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path25-Tools-DecisionMaking.Rmd
More file actions
926 lines (743 loc) · 40.7 KB
/
25-Tools-DecisionMaking.Rmd
File metadata and controls
926 lines (743 loc) · 40.7 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
# Making decisions {#MakingDecisions}
```{r}
source("R/showDecisionMaking.R")
```
```{r, child = if (knitr::is_html_output()) {'./introductions/25-Tools-DecisionMaking-HTML.Rmd'} else {'./introductions/25-Tools-DecisionMaking-LaTeX.Rmd'}}
```
<!-- Define colours as appropriate -->
```{r, child = if (knitr::is_html_output()) {'./children/coloursHTML.Rmd'} else {'./children/coloursLaTeX.Rmd'}}
```
## Introduction: drawing cards {#NeedForDecisionMaking}
\index{Decision making}
Suppose I produce a pack of cards, and shuffle them well.
The event of interest is 'the number of red cards when I draw $25$\ cards from the pack, with replacement'.
('With replacement' means that, after drawing a card, I place the card back into the pack, and reshuffle before drawing a new card; each draw is then from an identical, complete pack of $52$\ cards.)
The pack of cards can be considered the *population*.
In a standard pack, the proportion of red cards is $p = 0.5$ for each draw, because sampling is with replacement.
$\hat{p}$ is the proportion of red cards in the *sample* of $n = 25$\ cards.
Suppose the sample of $25$\ cards produces $\hat{p} = 1$; that is, *all* $n = 25$ cards in the sample are red cards
`r if( knitr::is_latex_output()){
'(Fig.\\ \\@ref(fig:Draw15Cards)).'
} else {
'pack (see the animation below).'
}`
What should you conclude?
How likely is it that this would happen by chance from a fair pack?
Is this evidence that the pack of cards is somehow unfair, poorly shuffled, or manipulated?
```{r}
### LOAD CARD IMAGES
im1 <- png::readPNG("Cards/queen_of_hearts.png")
im2 <- png::readPNG("Cards/3_of_diamonds.png")
im3 <- png::readPNG("Cards/4_of_diamonds.png")
im4 <- png::readPNG("Cards/7_of_hearts.png")
im5 <- png::readPNG("Cards/ace_of_diamonds.png")
im6 <- png::readPNG("Cards/2_of_diamonds.png")
im7 <- png::readPNG("Cards/ace_of_hearts.png")
im8 <- png::readPNG("Cards/jack_of_diamonds.png")
im9 <- png::readPNG("Cards/10_of_hearts.png")
im10 <- png::readPNG("Cards/4_of_hearts.png")
im11 <- png::readPNG("Cards/king_of_hearts.png")
im12 <- png::readPNG("Cards/queen_of_diamonds.png")
im13 <- png::readPNG("Cards/7_of_hearts.png")
im14 <- png::readPNG("Cards/5_of_diamonds.png")
im15 <- png::readPNG("Cards/5_of_hearts.png")
im16 <- png::readPNG("Cards/6_of_hearts.png")
im17 <- png::readPNG("Cards/jack_of_hearts.png")
im18 <- png::readPNG("Cards/jack_of_diamonds.png")
im19 <- png::readPNG("Cards/10_of_diamonds.png")
im20 <- png::readPNG("Cards/9_of_hearts.png")
im21 <- png::readPNG("Cards/3_of_diamonds.png")
im22 <- png::readPNG("Cards/5_of_hearts.png")
im23 <- png::readPNG("Cards/9_of_hearts.png")
im24 <- png::readPNG("Cards/king_of_diamonds.png")
im25 <- png::readPNG("Cards/6_of_diamonds.png")
```
```{r animation.hook = "gifski", fig.width = 8, fig.height=4, interval = 0.25, fig.align = "center", dev=if (is_latex_output()){"pdf"}else{"png"}}
### CARDS ARE OF SIZE 500 x 726
asp.cards <- 726/500
if (knitr::is_html_output()){
for (i in (1:(25 + 3))){ # Draw 25 cards, plus three to hold the final positiom
# Set up canvas
par(mar = rep(0.05, 4))
plot( x = c(1.2, 3.5),
y = c(1.2, 2),
type = "n",
xlab = "",
#asp = asp.cards,
ylab = "",
axes = FALSE)
if (i >= 1 ) rasterImage(im1,
1.20, 1.27, 1.80, 1.9)
if (i >= 2 ) rasterImage(im2,
1.25, 1.27, 1.85, 1.9)
if (i >= 3 ) rasterImage(im3,
1.30, 1.27, 1.90, 1.9)
if (i >= 4 ) rasterImage(im4,
1.35, 1.27, 1.95, 1.9)
if (i >= 5 ) rasterImage(im5,
1.40, 1.27, 2.00, 1.9)
if (i >= 6 ) rasterImage(im6,
1.45, 1.27, 2.05, 1.9)
if (i >= 7 ) rasterImage(im7,
1.50, 1.27, 2.10, 1.9)
if (i >= 8 ) rasterImage(im8,
1.55, 1.27, 2.15, 1.9)
if (i >= 9 ) rasterImage(im9,
1.60, 1.27, 2.20, 1.9)
if (i >= 10) rasterImage(im10,
1.65, 1.27, 2.25, 1.9)
if (i >= 11) rasterImage(im11,
1.70, 1.27, 2.30, 1.9)
if (i >= 12) rasterImage(im12,
1.75, 1.27, 2.35, 1.9)
if (i >= 13) rasterImage(im13,
1.80, 1.27, 2.40, 1.9)
if (i >= 14) rasterImage(im14,
1.85, 1.27, 2.45, 1.9)
if (i >= 15) rasterImage(im15,
1.90, 1.27, 2.50, 1.9)
if (i >= 16) rasterImage(im16,
1.95, 1.27, 2.55, 1.9)
if (i >= 17) rasterImage(im17,
2.00, 1.27, 2.60, 1.9)
if (i >= 18) rasterImage(im18,
2.05, 1.27, 2.65, 1.9)
if (i >= 19) rasterImage(im19,
2.10, 1.27, 2.70, 1.9)
if (i >= 20) rasterImage(im20,
2.15, 1.27, 2.75, 1.9)
if (i >= 21) rasterImage(im21,
2.20, 1.27, 2.80, 1.9)
if (i >= 22) rasterImage(im22,
2.25, 1.27, 2.85, 1.9)
if (i >= 23) rasterImage(im23,
2.30, 1.27, 2.90, 1.9)
if (i >= 24) rasterImage(im24,
2.35, 1.27, 2.95, 1.9)
if (i >= 25) rasterImage(im25,
2.40, 1.27, 3.00, 1.9)
text(1.95, 1, "How likely is it that we get\n25 red cards in a row?")
}
}
```
```{r Draw15Cards, fig.align="center", out.width = "75%", fig.width=12, fig.height=2.904, fig.cap="How likely is it to draw (with replacement) $25$ red cards in a row from a fair pack?" }
# NOTE the ratio of height to width: the saqme as asp.plot as computed below
if (knitr::is_latex_output()){
### CARDS ARE OF SIZE 500 x 726
asp.cards <- 726/500
# Separate cards a bit more in the LaTeX
leftCards <- seq(from = 0,
to = 3.00,
length = 25)
offsetCards <- diff(leftCards)[1]
widthCards <- 0.60
rightCards <- leftCards + widthCards
heightCards <- widthCards * asp.cards
handWidth <- widthCards + (25 - 1) * offsetCards
# Width is the width of a card (the final thing shown), plus 24 partial cards
asp.plot <- heightCards / handWidth
# Set up canvas
par(mar = rep(0, 4),
oma = rep(0, 4) )
plot( x = c( min(leftCards),
max(rightCards)),
# y = ( max(rightCards) - min(leftCards) ) * asp.cards,
y = c(0, heightCards),
type = "n",
xlab = "",
ylab = "",
axes = FALSE)
asp.cards <- 1
rasterImage(im1,
xleft = leftCards[1],
ybottom = 0,
xright = rightCards[1],
ytop = heightCards,
asp = asp.cards)
rasterImage(im2,
leftCards[2], 0, rightCards[2], heightCards, asp = asp.cards)
rasterImage(im3,
leftCards[3], 0, rightCards[3], heightCards, asp = asp.cards)
rasterImage(im4,
leftCards[4], 0, rightCards[4], heightCards, asp = asp.cards)
rasterImage(im5,
leftCards[5], 0, rightCards[5], heightCards, asp = asp.cards)
rasterImage(im6,
leftCards[6], 0, rightCards[6], heightCards, asp = asp.cards)
rasterImage(im7,
leftCards[7], 0, rightCards[7], heightCards, asp = asp.cards)
rasterImage(im8,
leftCards[8], 0, rightCards[8], heightCards, asp = asp.cards)
rasterImage(im9,
leftCards[9], 0, rightCards[9], heightCards, asp = asp.cards)
rasterImage(im10,
leftCards[10], 0, rightCards[10], heightCards, asp = asp.cards)
rasterImage(im11,
leftCards[11], 0, rightCards[11], heightCards, asp = asp.cards)
rasterImage(im12,
leftCards[12], 0, rightCards[12], heightCards, asp = asp.cards)
rasterImage(im13,
leftCards[13], 0, rightCards[13], heightCards, asp = asp.cards)
rasterImage(im14,
leftCards[14], 0, rightCards[14], heightCards, asp = asp.cards)
rasterImage(im15,
leftCards[15], 0, rightCards[15], heightCards, asp = asp.cards)
rasterImage(im16,
leftCards[16], 0, rightCards[16], heightCards, asp = asp.cards)
rasterImage(im17,
leftCards[17], 0, rightCards[17], heightCards, asp = asp.cards)
rasterImage(im18,
leftCards[18], 0, rightCards[18], heightCards, asp = asp.cards)
rasterImage(im19,
leftCards[19], 0, rightCards[19], heightCards, asp = asp.cards)
rasterImage(im20,
leftCards[20], 0, rightCards[20], heightCards, asp = asp.cards)
rasterImage(im21,
leftCards[21], 0, rightCards[21], heightCards, asp = asp.cards)
rasterImage(im22,
leftCards[22], 0, rightCards[22], heightCards, asp = asp.cards)
rasterImage(im23,
leftCards[23], 0, rightCards[23], heightCards, asp = asp.cards)
rasterImage(im24,
leftCards[24], 0, rightCards[24], heightCards, asp = asp.cards)
rasterImage(im25,
leftCards[25], 0, rightCards[25], heightCards, asp = asp.cards)
}
```
Of course, the sample of $25$\ cards is just one of *countless* possible samples that could have been chosen to study.
Different samples comprise different cards, and the sample proportion depends on which cards are drawn for the studied sample.
This leads to one of the most important observations about sampling.
::: {.importantBox .important data-latex="{iconmonstr-warning-8-240.png}"}
Studying a sample leads to the following observations:
\vspace{-2ex}
* every sample is likely to be different.
* we observe just one of the many possible samples.
* every sample is likely to yield a different value for the sample statistic.
* we observe just one of the many possible values for the statistic.
\vspace{-2ex}
Since many values for the sample are possible, the possible values of the statistic vary (this is called *sampling variation*)\index{Sampling variation} and have a *distribution* (this is called a *sampling distribution*).\index{Sampling distribution}
:::
In research, decisions need to be made about parameters, based on just one of many possible values of the statistic.
Sensible decisions *can* be made (and *are* made) about parameters based on statistics.
To do this though, the process of *how* decisions are made needs to be articulated, which is the purpose of this chapter.
In the cards example, obtaining $25$\ reds cards out of\ $25$ (i.e., $\hat{p} = 1$) seems very unlikely from. a fair pack; you would probably conclude that the pack is somehow unfair, or that I was cheating somehow.
But importantly, *how* did you reach that decision?
Your unconscious decision-making process may have followed these steps.\index{Decision making}
1. You *assumed*, quite reasonably, that I used a standard, well-shuffled pack of cards, where half the cards are red and half the cards are black.
That is, you assumed the *population proportion* of red cards really was $p = 0.5$.
2. Based on that assumption, you *expected* about half the cards in the sample of\ $25$ to be red (i.e., expected\ $\hat{p}$ to be about\ $0.5$).
You wouldn't necessarily have expected *exactly* half red cards (because of sampling variation), but you expected the value of $\hat{p}$ to be close to\ $0.5$.
3. You then *observed* that *all* $25$\ cards were red.
That is, you observed $\hat{p} = 1$... which seems rather high.
4. You were expecting $\hat{p} = 0.5$ approximately, but instead observed $\hat{p} = 1$.
What you observed ('all red cards') was not at all like what you were expecting ('about half red cards'); the sample *contradicts* what you were expecting (from a fair pack).
This suggests your assumption of a fair pack is probably wrong.
Of course, finding $25$\ red cards in a row is *possible*... just *extremely unlikely*.
For this reason, you would probably conclude that this is persuasive evidence that the pack is not fair.
## Making decisions: hypotheses
Two reasons could explain why the value of the *sample* proportion of red cards in $25$\ cards ($\hat{p} = 1$) is not exactly equal to the value of the population proportion ($p = 0.5$).
1. *The __population__ proportion of red cards really is $p = 0.5$*, and the value of the *sample* proportion $\hat{p}$ is not equal to $0.5$ only due to *sampling variation*.
That is, we just happen to have---by chance---one of those samples where the the value of $\hat{p}$ is very large and not equal to $p$.
2. *The __population__ proportion of red cards really isn't $p = 0.5$*, and this is simply reflected in the observed sample proportion.
These two possible explanations ('statistical hypotheses') have special names.\index{Hypotheses!statistical}
1. The first explanation is the *null hypothesis*, denoted $H_0$.\index{Parameter}\index{Hypotheses!null}
This hypothesis proposes that *the population proportion is $0.5$*; the value of the sample proportion is *not* $0.5$ due to *sampling variation*.
2. The second explanation is the *alternative hypothesis*, denoted $H_1$.\index{Hypotheses!alternative}
This hypothesis proposes that the population proportion is really not $0.5$ at all, which is reflected in the value of the sample proportion.
*How* do we decide which of these explanations is supported by the data?\index{Evidence-based research}
The usual approach to decision-making in science begins by assuming the null hypothesis (the sampling-variation explanation) is true.
Then the data are examined to see if persuasive evidence exists to change our mind (and support the alternative hypothesis).
Remember: conclusions drawn about the *population* from the *sample* can never be certain, since the sample studied is just one of many possible samples that could have been taken (and every sample is likely to be different).
::: {.importantBox .important data-latex="{iconmonstr-warning-8-240.png}"}
The onus is on the data to refute the null hypothesis.
That is, the null hypothesis is retained unless persuasive evidence suggests otherwise.
:::
## Making decisions: the process {#DecisionMaking}
The ideas in Sect.\ \@ref(NeedForDecisionMaking) suggest a formal process of decision-making in research
`r if( knitr::is_html_output() ) {
'(Fig.\\ \\@ref(fig:DecisionFlow)).'
} else {
'(Fig.\\ \\@ref(fig:DecisionFlow2)).'
}`
1. *Make an assumption about the value of the parameter*.
By doing so, we assume that *sampling variation* explains any discrepancy between the value of the observed statistic and this assumed value of the parameter.
2. *Define the expectations of the statistic*.
Based on the assumption made about the parameter, describe what values of the *statistic* might reasonably be observed from all the possible samples from the population (due to sampling variation).
3. *Evaluate the observations*.
Take a sample (one of the many possible samples), and compute the observed sample statistic from these data; then compare this to what was expected.
4. *Make a decision*:
- if the observed value of the *sample statistic* is *unlikely* to have been observed by chance, the statistic (i.e., the evidence) *contradicts* the assumption about the *parameter*, so the assumption is probably (but not certainly) *wrong*.
- if the observed value of the *sample statistic* could easily be explained by chance, the statistic (i.e., the evidence) is *consistent with* the assumption about the *parameter*, so the assumption may be (but is not certainly) *correct*.
```{r DecisionFlow2, fig.cap = "A way to make decisions.", fig.align="center", out.width='100%', fig.width = 9.25, fig.height = 4}
source("R/showDecisionMaking.R")
showDecisionMaking()
```
```{r DecisionFlow, animation.hook="gifski", interval=1.5, progress=TRUE, fig.cap="A way to make decisions.", fig.align="center", fig.width=6, fig.height=3, dev=if (is_latex_output()){"pdf"}else{"png"}}
if( knitr::is_html_output() ) {
for (i in (1:2)){
par( mar = c(0.15, 0.15, 0.15, 0.15))
openplotmat()
pos <- array(NA, dim = c(6, 2))
pos[1, ] <- c(0.10, 0.85) # Assumption
pos[2, ] <- c(0.40, 0.85) # Expectation
pos[3, ] <- c(0.40, 0.15) # Observation
pos[4, ] <- c(0.40, 0.50) # Consistency?
pos[5, ] <- c(0.80, 0.85) # YES
pos[6, ] <- c(0.80, 0.15) # NO
straightarrow(from = pos[1, ], to = pos[2, ],
lty = 1,
lwd = 2)
straightarrow(from = pos[4, ], to = pos[2, ],
lcol = "black",
lty = 2,
lwd = 2)
straightarrow(from = pos[4, ], to = pos[3, ],
lcol = grey(0.4),
arr.pos = 0.5, # Then cover with box
lty = 2)
if (i == 1 ) {
curvedarrow(from = pos[4, ] + c(0, 0.065), to = pos[5, ],
lcol = grey(0.4),
curve = 0.35,
arr.pos = 0.5, # Then cover with box
lty = 2)
textrect( pos[5, ],
radx = 0.11,
rady = 0.1,
shadow.size = 0,
lcol = "darkseagreen2",
box.col = "darkseagreen2",
lab = "Yes: supports\nassumption",
col = grey(0)) # CROSS
}
if (i == 2 ) {
curvedarrow(from = pos[4, ] - c(0, 0.065), to = pos[6, ] ,
lcol = grey(0.4),
curve = -0.35,
arr.pos = 0.5, # Then cover with box
lty = 2)
textrect( pos[6, ],
radx = 0.11,
rady = 0.1,
shadow.size = 0,
lcol = "darksalmon",
box.col = "darksalmon",
lab = "No: contradicts\nassumption",
col = grey(0)) # CROSS
}
textrect( pos[4, ],
radx = 0.11,
rady = 0.1,
shadow.size = 0,
lcol = "snow2",
box.col = "snow2",
lab = "Compare:\nconsistency?",
col = grey(0)) # CHECKMARK
textrect( pos[1, ],
lab = "Population:\nassumption",
radx = 0.11,
rady = 0.1,
shadow.size = 0,
lcol = "slategray1",
box.col = "slategray1",
cex = 1)
textrect( pos[2, ],
lab = "Sample:\nexpectation",
radx = 0.11,
rady = 0.1,
shadow.size = 0,
lcol = "slategray2",
box.col = "slategray2",
cex = 1)
textrect( pos[3, ],
box.col = "slategray3",
lcol = "slategray3",
shadow.size = 0,
radx = 0.11,
rady = 0.1,
lab = "Sample:\nobservation",
cex = 1)
}
}
```
<div style="float:right; width: 222x; border: 1px; padding:10px">
<img src="Illustrations/pexels-ketut-subiyanto-4546136.jpg" width="200px"/>
</div>
This approach is similar to how we unconsciously make decisions every day.
For example, suppose I ask my son to brush his teeth [@data:Budgett:RandomizationTest].
Later, I wish to decide if he really did.
The decision-making process may proceed as follows.
1. *Assumption*: I *assume* my son brushed his teeth (because I asked him to).
2. *Expectation*: based on my assumption, I would *expect* to find his toothbrush is damp.
3. *Observation*: when I check later, I observe a *dry* toothbrush, which is unexpected.
4. *Decision*: the evidence *contradicts* what I expected to find based on my assumption, so my assumption is probably *false*: he probably *didn't* brush his teeth.
I may have made the wrong decision: he may have brushed his teeth, then dried his toothbrush with a hair dryer.
However, based on the evidence, he likely has not brushed his teeth.
The situation may have ended differently: when I check later, suppose I observe a *damp* toothbrush.
Then, the evidence seems *consistent* with what I expected if he brushed his teeth (my assumption), so my assumption is probably *true*; he probably did brush his teeth.
Again, I may be wrong: he may have rinsed his toothbrush under a tap.
Nonetheless, I don't have evidence that he didn't brush his teeth.
Similar logic underlies most decision-making in science.^[Other ways exist to make decisions, such as using prior knowledge. For example, if my son had a reputation for wetting his toothbrush under the tap instead of brushing his teeth, that information can be incorporated into the decision-making. This is called a *Bayesian approach*.]
## Making decisions: the steps {#MakingDecisionsInResearch}
\index{Decision making!steps}
Let's think about each step in the decision-making process
`r if( knitr::is_html_output()){
'(Fig.\\ \\@ref(fig:DecisionFlow))'
} else {
'(Fig.\\ \\@ref(fig:DecisionFlow2))'
}`
individually:
* making an *assumption* about the parameter (Sect.\ \@ref(Assumption)).
* describing the *expectations* of the statistic (Sect.\ \@ref(ExpectationOf)).
* taking the sample *observations* (Sect.\ \@ref(Observation)).
* making a *decision* (Sect.\ \@ref(MakeDecision)).
### Making an assumption about the parameter {#Assumption}
\index{Decision making!assumption}
<div style="float:right; width: 222x; border: 1px; padding:10px">
<img src="Pics/iconmonstr-delivery-6-240.png" width="50px"/>
</div>
The initial assumption is that sampling variation explains any discrepancy between the values of the parameter and the statistic.
This assumption about the value of the parameter is called the *null hypothesis*,\index{Hypotheses!null} denoted\ $H_0$.
The null hypothesis is always that sampling variation explains the difference between the observed value of the statistic and the assumed value of the parameter.
Depending on the RQ and the context, this may mean:
* the parameter value has not changed (e.g., for descriptive or repeated-measures RQs).\index{Research question!descriptive}\index{Research question!repeated-measures}
The value of the statistic might show a change, but only due to sampling variation.
* the value of some parameter is the same in all the groups being compared (e.g., for relational RQs).\index{Research question!relational}
The values of the statistic are not exactly the same due to sampling variation.
* there is no relationship between the variables, as measured by some parameter (e.g., for correlational RQs).\index{Research question!correlational}
The value of the statistic is not exactly this value due to sampling variation.
In other words, the null hypothesis is the 'no change, no difference, no relationship' position.
Using this idea, a reasonable assumption can be made about the parameter.\index{Parameter}
For example, when comparing the mean of two groups, we would initially assume *no difference* between the *population* means: any difference between the *sample* means would be attributed to sampling variation.
<div style="float:right; width: 222x; border: 1px; padding:10px">
<img src="Illustrations/pexels-ketut-subiyanto-4546136.jpg" width="200px"/>
</div>
::: {.example #Assumptions name="Assumptions about the population"}
Many dental associations recommend brushing teeth for two minutes.
@data:Macgregor1979:BrushingDurationKids recorded the toothbrushing time for $85$ uninstructed schoolchildren from England to assess compliance with these guidelines.
We initially *assume* the *population* mean toothbrushing time is two minutes ($H_0$:\ $\mu = 2$).
If the *sample* mean is not two minutes, the null hypothesis explains this discrepancy as sampling variation.
A sample can then be obtained to determine if the sample mean is consistent with, or contradicts, this assumption.
:::
### Describing the expectations of the statistic {#ExpectationOf}
\index{Decision making!expectation}\index{Statistic}
<div style="float:right; width: 222x; border: 1px; padding:10px">
<img src="Pics/iconmonstr-christmas-42-240.png" width="50px"/>
</div>
Based on the assumed value for the parameter, we then determine *what values to expect from the statistic* from all the possible samples we could select (of which we only select one).
Since many samples are possible, and every sample is likely to be different (sampling variation), the observed value of the statistic depends on which one of the countless possible samples we obtain.
To know what values of the statistic are expected, the *sampling distribution* needs to be described.
Think about the cards in Sect.\ \@ref(NeedForDecisionMaking).
In a fair pack, *half* the cards are red in the *population* (the pack of cards), so the population proportion is assumed to be $p = 0.5$.
In a *sample* of $25$\ cards, what values could be reasonably expected for the *sample* proportion\ $\hat{p}$ of red cards (the statistic)?
If samples of size $n = 25$ were repeatedly taken from a fair pack with $p = 0.5$, the sample proportion of red cards would vary from hand to hand, of course.
But *how* would\ $\hat{p}$ vary from sample to sample?
Suppose we simulated only ten hands of $n = 25$ cards each, using a computer;
`r if (knitr::is_latex_output()) {
'Fig.\\ \\@ref(fig:RollDice10) shows the sample proportion of red cards from each repetition.'
} else {
'the animation below shows the sample proportion of red cards from each repetition.'
}`
Naturally, the value of $\hat{p}$ varies.
```{r animation.hook="gifski", interval=0.25, dev=if (is_latex_output()){"pdf"}else{"png"}}
if (knitr::is_html_output()){
set.seed(99999)
num.in.hand <- 25
num.sims <- 10
x.loc <- 1:(num.in.hand)
y.loc <- 1
prop.red <- array(dim = num.sims)
all.hands <- array( dim = c(num.sims, num.in.hand))
for (i in 1:num.sims){
par ( mar = c(5.1, 5.1, 4.1, 2.1)) # DEFAULT is 5.1, 4.1, 4.1, 2.1
plot( x = c(1, (num.in.hand + 2)),
y = c(1, num.sims),
type = "n",
las = 1,
xlab = "",
ylab = "",
main = paste("Hand number",i),
axes = FALSE)
hand <- sample( c("B", "R"),
num.in.hand,
replace = TRUE)
all.hands[i, ] <- hand
prop.red[i] <- sum( (hand == "B")/2 == floor( (hand == "B")/2) ) / num.in.hand
num.all.hands <- (all.hands == "B")
for (j in 1:i){
text(y = j,
x = 1:num.in.hand,
labels = all.hands[j, ],
col = ifelse( num.all.hands[j, ]/2 == floor(num.all.hands[j, ]/2), "red", "grey") )
}
# Add p-hat heading
mtext(expression(hat( italic(p) ) ),
side = 3,
line = 0,
at = num.in.hand + 2 )
# Add the hand number to the left-hand side
axis(side = 2,
at = 1:i,
las = 1,
labels = paste("Hand ", 1:i, sep = "") )
# Add the sample proportion to right-hand side
text(num.in.hand + 2, 1 : i,
labels = format(round(prop.red[1 : i], 2), nsmall = 2) )
#Add dividing line
abline(v = num.in.hand + 1,
col = "grey")
# Divide each hand set
abline(h = (1 : i) - 0.5,
col = "grey")
}
}
```
```{r RollDice10, fig.align = "center", fig.width = 6.5, fig.height=3.1, out.width='75%', fig.cap = "Ten hands of $25$ cards: the sample proportion of cards in each hand that is red (shown on the right-hand side) varies from hand to hand.", cache=FALSE}
if (knitr::is_latex_output()){
set.seed(99999)
num.in.hand <- 25
num.sims <- 10
x.loc <- 1:(num.in.hand)
y.loc <- 1
prop.red <- array(dim = num.sims)
all.hands <- array( dim = c(num.sims, num.in.hand))
par( mar = c(0.5, 4.0, 4.1, 0.5))
plot( x = c(1, (num.in.hand + 2)),
y = c(1, num.sims),
type = "n",
las = 1,
xlab = "",
ylab = "",
main = "Ten example hands of 25 cards, and\nthe proportion of red cards in each hand",
axes = FALSE)
for (i in 1:num.sims){
par ( mar = c(0.1, 4.3, 4.1, 0.1)) # DEFAULT is 5.1, 4.1, 4.1, 2.1
hand <- sample( c("B", "R"),
num.in.hand,
replace = TRUE)
all.hands[i, ] <- hand
prop.red[i] <- sum( (hand == "B")/2 == floor( (hand == "B")/2) ) / num.in.hand
num.all.hands <- (all.hands == "B")
}
for (j in 1:i){
text(y = j,
x = 1:num.in.hand,
labels = all.hands[j, ],
col = ifelse( num.all.hands[j,]/2 == floor(num.all.hands[j,]/2),
"black",
grey(0.5)),
font = ifelse( num.all.hands[j,]/2 == floor(num.all.hands[j,]/2),
2, # BOLD
1) # NORMAL FONT
)
}
# Add p-hat heading
mtext(expression(hat( italic(p) ) ),
side = 3,
line = 0,
at = num.in.hand + 2 )
# Add the hand number to the left-hand side
axis(side = 2,
at = 1:i,
las = 1,
labels = paste("Hand ", 1:i, sep = "") )
# Add the sample proportion to right-hand side
text(num.in.hand+2, 1:i,
labels = format( round(prop.red[1:i], 2), nsmall = 2) )
#Add dividing line
abline(v = num.in.hand + 1,
col = "grey")
# Divide each hand set
abline(h = (1:i) - 0.5,
col = "grey")
# }
}
```
The distribution of the sample statistic is called the *sampling distribution* (Sect.\ \@ref(SamplingVariationIntro)).
The sampling distribution for $\hat{p}$ is given in Sect.\ \@ref(SamplingDistributionKnownp) when the value of $p$ is known (as assumed here): an approximate normal distribution, with mean\ $p = 0.5$, and a standard deviation (the *standard error*) of
$$
\text{s.e.}(\hat{p})
=
\sqrt{\frac{p\times(1 - p)}{n} }
=
\sqrt{\frac{0.5\times(1 - 0.5)}{25} }
=
0.1.
$$
A picture of this sampling distribution can be drawn (Fig.\ \@ref(fig:SamplingDistCards)).
Values of $\hat{p}$ larger than\ $0.8$ or smaller than\ $0.2$ would appear very unlikely.
```{r, SamplingDistCards, fig.cap="The sampling distribution for $\\hat{p}$, the sample proportion of red cards in $25$ cards.", fig.align="center", fig.width=8.5, fig.height=2.75, out.width='85%'}
p.cards <- 0.5
n.cards <- 25
se.cards <- sqrt( (p.cards * (1 - p.cards)) / n.cards)
out <- plotNormal(mu = 0.5,
sd = se.cards,
xlab = "Sample proportion of red cards, in hands of 25 cards",
main = expression(The~sampling~distribution~"for"~hat(italic(p))),
showX = seq(0, 1,
by = 0.1),
xlim.lo = 0,
xlim.hi = 1) # Upper x-axis limit
```
### Evaluating the sample observations {#Observation}
\index{Decision making!observations}
While many samples are possible, we only observe *one* of those countless possible samples.
From our sample of $25$\ cards, all cards are red
`r if (knitr::is_latex_output()) {
'(Fig.\\ \\@ref(fig:Draw15Cards)),'
} else {
'(see Sect.\\ \\@ref(NeedForDecisionMaking)),'
}`
and so the value of the statistic is $\hat{p} = 25/25 = 1$.
Assuming $p = 0.5$, is this value of\ $\hat{p}$ unusual, or not unusual?
From Fig.\ \@ref(fig:SamplingDistCards), the value $\hat{p} = 1$ is *very* unusual: it would not be expected in a sample of $25$\ cards.
### Making a conclusion {#MakeDecision}
\index{Decision making!decision}
<div style="float:right; width: 222x; border: 1px; padding:10px">
<img src="Pics/iconmonstr-shipping-box-7-240.png" width="50px"/>
</div>
Observing $25$\ red cards out of $25$\ cards from a fair pack is highly unusual, so the chance that our specific, randomly-chosen sample produced $\hat{p} = 1$ is incredibly unlikely.
So you could reasonably conclude that finding $\hat{p} = 1$ almost never occurs, *if the assumption of a fair pack was true*.
But since we *did* find $\hat{p} = 1$, the assumption of a fair pack is probably wrong.
That is, there is persuasive evidence that the assumption is wrong, and that the pack of cards is not fair.\index{Evidence-based research}
The decision-making process is shown in Fig.\ \@ref(fig:DecisionFlowCards).
```{r DecisionFlowCards, fig.cap = "A way to make decisions for the cards example.", fig.align="center", out.width='100%', fig.width = 9.5, fig.height = 4}
source("R/showDecisionMaking.R")
showDecisionMaking(populationText = expression( atop(bold(Assume)~the~pack,
is~fair*":"~italic(p)==0.5)),
expectationText = expression(atop(bold(Expect)~about~half,
red~cards*":"~hat(italic(p))~near~0.5)),
oneSampleText = expression( atop(Deal~one~hand,
of~25~cards) ),
oneStatisticText = expression( atop(bold(All)~cards~are,
red*":"~hat(italic(p))==1)),
Decision = "Reject"
)
```
What if we had observed $18$\ red cards in a hand of $25$\ cards, a sample proportion of $\hat{p} = 18/25 = 0.72$?
The conclusion is not quite so obvious then: Fig.\ \@ref(fig:SamplingDistCards) shows that $\hat{p} = 0.72$ is unlikely, but $\hat{p} = 0.72$ (and even larger values) certainly do occur.
What if $15$\ red cards were found in the\ $25$ (i.e., $\hat{p} = 0.6$)?
Figure\ \@ref(fig:SamplingDistCards) shows that $\hat{p} = 0.6$ could reasonably be observed, since there are many possible samples that lead to $\hat{p} = 0.6$, or even larger values.
This would not seem unusual at all, and is certainly not persuasive evidence to change our mind.
Many of the possible samples produce values of\ $\hat{p}$ near\ $0.6$.
This process of decision-making is similar to the process used in research.
This process will be studied in coming chapters.
## Example: brushing teeth {#ToolsDecisionMakingExample}
Many dental associations recommend brushing teeth for two minutes (i.e., for $120\secs$).
@data:Macgregor1979:BrushingDurationKids recorded the toothbrushing time for $85$\ uninstructed schoolchildren from England to assess compliance with these guidelines.
Of course, every possible sample of $85$ children in England will include different children, and so produce various sample mean brushing times\ $\bar{x}$.
Even if the *population* mean toothbrushing time really was $120\secs$ (i.e., $\mu = 120$), the *sample* mean probably wouldn't be exactly $120\secs$, because of this sampling variation.
To begin, *assume* the population mean toothbrushing time is $\mu = 120$; that is, $H_0$ is $\mu = 120$.
*If* this is true, we then could describe what values of the sample statistic $\bar{x}$ could be *expected* from all possible samples by describing the sampling distribution of\ $\bar{x}$: how sample means are likely to vary for samples of size $85$ when $\mu = 120$.
The study found the mean time spent brushing was $60.3\secs$, with a standard deviation of $23.8\secs$.
Using the ideas in Chap.\ \@ref(OneMeanConfInterval), and in Sect.\ \@ref(SamplingDistSampleMean) specifically, the sampling distribution of $\bar{x}$ has an approximate normal distribution, with mean $\mu = 120$ (from $H_0$) and a standard deviation of $\text{s.e.}(\bar{x}) = 23.8/\sqrt{85} = 2.58\secs$ (shown in Fig.\ \@ref(fig:SamplingDistBrushing)).
A sample mean of $\bar{x} = 60.3$ seems incredibly unlikely if $\mu = 120$.
This suggests that the sample evidence *contradicts* the assumption that $\mu = 120$, and so the mean toothbrushing time in the population is very unlikely to be $120\secs$.
```{r, SamplingDistBrushing, fig.cap="The sampling distribution for $\\bar{x}$, the mean toothbrushing time in schoolchildren from England. A sample mean of $60.3\\secs$ seems very unlikely.", fig.align="center", fig.width=8, fig.height=2.75, out.width='85%'}
out <- plotNormal(mu = 120,
sd = 23.8/sqrt(85),
xlab = "Sample mean toothbrushing time, in seconds",
main = expression(The~sampling~distrinution~"for"~bar(italic(x))),
xlim.lo = 110,
xlim.hi = 130) # Upper x-axis limit
```
## Chapter summary {#ToolsDecisionMakingSummary}
Making decisions about parameters based on a statistic is challenging:
only one of the many possible samples is observed.
Since every sample is likely to be different, different values of the sample statistic are possible.
In this chapter, though, a process for making decisions has been studied
`r if( knitr::is_html_output()){
'(Fig.\\ \\@ref(fig:DecisionFlow)).'
} else {
'(Fig.\\ \\@ref(fig:DecisionFlow2)).'
}`
Decisions are often made by making an *assumption* about the parameter, which leads to an *expectation* of what values of the statistic are reasonably possible.
We can then make *observations* about our sample, and then make a *decision* about whether the sample data support or contradict the initial assumption.
## Quick review questions {#ToolsDecisionMakingQuickReview}
::: {.webex-check .webex-box}
Are the following statements *true* or *false*?
1. Parameters describe *populations*.\tightlist
`r if( knitr::is_html_output() ) {torf(answer = TRUE )}`
2. Both $\bar{x}$ and $\mu$ are *statistics*.
`r if( knitr::is_html_output() ) {torf(answer = FALSE )}`
3. The value of a statistic is likely to be *same* in every sample.
`r if( knitr::is_html_output() ) {torf(answer = FALSE )}`
4. *Sampling variation* describes how the value of a *statistic* varies from sample to sample.
`r if( knitr::is_html_output() ) {torf(answer = TRUE )}`
5. An initial assumption is made about the *sample statistic*.
`r if( knitr::is_html_output() ) {torf(answer = FALSE )}`
6. If the sample results seem inconsistent with what was expected, then the assumption about the population is probably true.
`r if( knitr::is_html_output() ) {torf(answer = FALSE )}`
7. In the sample, we know exactly what value of\ $\hat{p}$ to expect.
`r if( knitr::is_html_output() ) {torf(answer = FALSE )}`
8. Hypotheses are made about the population.
`r if( knitr::is_html_output() ) {torf(answer = TRUE )}`
:::
## Exercises {#MakingDecisionsExercises}
[Answers to odd-numbered exercises] are given at the end of the book.
`r if( knitr::is_latex_output() ) "\\captionsetup{font=small}"`
::: {.exercise #MakingDecisionsDice}
While playing a die-based game, your opponent rolls a
`r if (knitr::is_latex_output()) {
'\\largedice{6}'
} else {
'<span class="larger-die">⚅</span>'
}`
ten times in a row.
1. Do you think there is a problem with the die?
1. Explain how you came to this decision.
:::
::: {.exercise #MakingDecisionsCoin}
A friend tosses a coin, and obtains
`r if (knitr::is_latex_output()) {
'\\Heads\\ '
} else {
'<span class="HTcircle">H</span> '
}`two times in a row.
1. Do you think there is a problem with the coin?
1. Explain how you came to this decision.
:::
::: {.exercise #MakingDecisionsJuryService}
Since my wife and I have been married, I have been called to jury service four times.
The latest notice reads: 'Your name has been selected at random from the electoral roll'.
In the same time, my wife has *never* been called to jury service.
Do you think the selection process really is 'at random'?
Explain.
:::
::: {.exercise #MakingDecisionsClaim}
In a 2012 advertisement, an Australian pizza company claimed that their $12$-inch pizzas were 'real $12$-inch pizzas' [@mypapers:Dunn:PizzaSize].
1. What is a reasonable assumption to make to test this claim?
2. The claim is supported by a sample of $125$ pizzas, which gave the sample mean pizza diameter as $\bar{x} = 11.48$ inches.
What are the two reasons why the sample mean is not exactly $12$-inches?
3. Does the claim appear to be supported by, or contradicted by, the data?
Explain.
4. Would your conclusion change if the sample mean was $\bar{x} = 11.25$\ inches?
Explain.
5. Does your answer depend on the sample size?
For example, is observing a sample mean of $11.25$\ inches from a sample of size $n = 10$ equivalent to observing a sample mean of $11.25$\ inches from a sample of size $n = 125$?
Explain.
:::
::: {.exercise #MakingDecisionsOlder}
Suppose that $36$% of all students at a certain large university are aged over\ $30$.
A student takes a sample of $n = 40$\ students from the School of Arts to determine if students in that school are somehow different from the general university population in terms of age.
1. What is the null hypothesis?
1. If the student researcher finds $13$\ students in the sample aged over\ $30$, does this present persuasive evidence to change your mind?
Explain.
1. If the student researcher finds three students in the sample aged over\ $30$, does this present persuasive evidence to change your mind?
Explain.
:::
`r if( knitr::is_latex_output() ) "\\captionsetup{font=normalsize}"`
<!-- QUICK REVIEW ANSWERS -->
`r if (knitr::is_html_output()) '<!--'`
::: {.EOCanswerBox .EOCanswer data-latex="{iconmonstr-check-mark-14-240.png}"}
**Answers to *Quick review* questions:**
**1.** True.
**2.** False.
**3.** False.
**4.** True.
**5.** False.
**6.** False.
**7.** False.
**8.** True.
:::
`r if (knitr::is_html_output()) '-->'`