-
Notifications
You must be signed in to change notification settings - Fork 1
/
Chapter_39.html
957 lines (913 loc) · 91.7 KB
/
Chapter_39.html
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
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
<!DOCTYPE html>
<html lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Chapter 39 Practical. Statistical techniques in R | Fundamental statistical concepts and techniques in the biological and environmental sciences: With jamovi</title>
<meta name="description" content="This is an introductory statistics textbook for students in the biological and environmental sciences with examples using jamovi statistical software." />
<meta name="generator" content="bookdown 0.37 and GitBook 2.6.7" />
<meta property="og:title" content="Chapter 39 Practical. Statistical techniques in R | Fundamental statistical concepts and techniques in the biological and environmental sciences: With jamovi" />
<meta property="og:type" content="book" />
<meta property="og:description" content="This is an introductory statistics textbook for students in the biological and environmental sciences with examples using jamovi statistical software." />
<meta name="github-repo" content="bradduthie/statistics_book" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Chapter 39 Practical. Statistical techniques in R | Fundamental statistical concepts and techniques in the biological and environmental sciences: With jamovi" />
<meta name="twitter:description" content="This is an introductory statistics textbook for students in the biological and environmental sciences with examples using jamovi statistical software." />
<meta name="author" content="Brad Duthie" />
<meta name="date" content="2024-02-24" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="prev" href="Chapter_38.html"/>
<link rel="next" href="appendexA.html"/>
<script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.4.6/dist/fuse.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-clipboard.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.1.0/anchor-sections.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.1.0/anchor-sections-hash.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.1.0/anchor-sections.js"></script>
<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { font-weight: bold; } /* Alert */
code span.an { font-style: italic; } /* Annotation */
code span.cf { font-weight: bold; } /* ControlFlow */
code span.co { font-style: italic; } /* Comment */
code span.cv { font-style: italic; } /* CommentVar */
code span.do { font-style: italic; } /* Documentation */
code span.dt { text-decoration: underline; } /* DataType */
code span.er { font-weight: bold; } /* Error */
code span.in { font-style: italic; } /* Information */
code span.kw { font-weight: bold; } /* Keyword */
code span.pp { font-weight: bold; } /* Preprocessor */
code span.wa { font-style: italic; } /* Warning */
</style>
<style type="text/css">
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
</style>
<style type="text/css">
/* Used with Pandoc 2.11+ new --citeproc when CSL is used */
div.csl-bib-body { }
div.csl-entry {
clear: both;
}
.hanging div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}
</style>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li><a href="./">Statistics with jamovi</a></li>
<li class="divider"></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i>Preface</a>
<ul>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#structure"><i class="fa fa-check"></i>How this book is structured</a></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#datasets"><i class="fa fa-check"></i>Datasets used in this book</a></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#acknowledgements"><i class="fa fa-check"></i>Acknowledgements</a></li>
<li class="chapter" data-level="" data-path="index.html"><a href="index.html#author"><i class="fa fa-check"></i>About the author</a></li>
</ul></li>
<li class="part"><span><b>I Background mathematics and data organisation</b></span></li>
<li class="chapter" data-level="" data-path="Week1.html"><a href="Week1.html"><i class="fa fa-check"></i>Part I Overview</a></li>
<li class="chapter" data-level="1" data-path="Chapter_1.html"><a href="Chapter_1.html"><i class="fa fa-check"></i><b>1</b> Background mathematics</a>
<ul>
<li class="chapter" data-level="1.1" data-path="Chapter_1.html"><a href="Chapter_1.html#numbers-and-operations"><i class="fa fa-check"></i><b>1.1</b> Numbers and operations</a></li>
<li class="chapter" data-level="1.2" data-path="Chapter_1.html"><a href="Chapter_1.html#logarithms"><i class="fa fa-check"></i><b>1.2</b> Logarithms</a></li>
<li class="chapter" data-level="1.3" data-path="Chapter_1.html"><a href="Chapter_1.html#order-of-operations"><i class="fa fa-check"></i><b>1.3</b> Order of operations</a></li>
</ul></li>
<li class="chapter" data-level="2" data-path="Chapter_2.html"><a href="Chapter_2.html"><i class="fa fa-check"></i><b>2</b> Data organisation</a>
<ul>
<li class="chapter" data-level="2.1" data-path="Chapter_2.html"><a href="Chapter_2.html#tidy-data"><i class="fa fa-check"></i><b>2.1</b> Tidy data</a></li>
<li class="chapter" data-level="2.2" data-path="Chapter_2.html"><a href="Chapter_2.html#data-files"><i class="fa fa-check"></i><b>2.2</b> Data files</a></li>
<li class="chapter" data-level="2.3" data-path="Chapter_2.html"><a href="Chapter_2.html#managing-data-files"><i class="fa fa-check"></i><b>2.3</b> Managing data files</a></li>
</ul></li>
<li class="chapter" data-level="3" data-path="Chapter_3.html"><a href="Chapter_3.html"><i class="fa fa-check"></i><b>3</b> <em>Practical</em>. Preparing data</a>
<ul>
<li class="chapter" data-level="3.1" data-path="Chapter_3.html"><a href="Chapter_3.html#exercise-1-transferring-data-to-a-spreadsheet"><i class="fa fa-check"></i><b>3.1</b> Exercise 1: Transferring data to a spreadsheet</a></li>
<li class="chapter" data-level="3.2" data-path="Chapter_3.html"><a href="Chapter_3.html#exercise-2-making-spreadsheet-data-tidy"><i class="fa fa-check"></i><b>3.2</b> Exercise 2: Making spreadsheet data tidy</a></li>
<li class="chapter" data-level="3.3" data-path="Chapter_3.html"><a href="Chapter_3.html#exercise-3-making-data-tidy-again"><i class="fa fa-check"></i><b>3.3</b> Exercise 3: Making data tidy again</a></li>
<li class="chapter" data-level="3.4" data-path="Chapter_3.html"><a href="Chapter_3.html#exercise-4-tidy-data-and-spreadsheet-calculations"><i class="fa fa-check"></i><b>3.4</b> Exercise 4: Tidy data and spreadsheet calculations</a></li>
<li class="chapter" data-level="3.5" data-path="Chapter_3.html"><a href="Chapter_3.html#summary"><i class="fa fa-check"></i><b>3.5</b> Summary</a></li>
</ul></li>
<li class="part"><span><b>II Statistical concepts</b></span></li>
<li class="chapter" data-level="" data-path="Week2.html"><a href="Week2.html"><i class="fa fa-check"></i>Part II Overview</a></li>
<li class="chapter" data-level="4" data-path="Chapter_4.html"><a href="Chapter_4.html"><i class="fa fa-check"></i><b>4</b> Populations and samples</a></li>
<li class="chapter" data-level="5" data-path="Chapter_5.html"><a href="Chapter_5.html"><i class="fa fa-check"></i><b>5</b> Types of variables</a></li>
<li class="chapter" data-level="6" data-path="Chapter_6.html"><a href="Chapter_6.html"><i class="fa fa-check"></i><b>6</b> Accuracy, precision, and units</a>
<ul>
<li class="chapter" data-level="6.1" data-path="Chapter_6.html"><a href="Chapter_6.html#accuracy"><i class="fa fa-check"></i><b>6.1</b> Accuracy</a></li>
<li class="chapter" data-level="6.2" data-path="Chapter_6.html"><a href="Chapter_6.html#precision"><i class="fa fa-check"></i><b>6.2</b> Precision</a></li>
<li class="chapter" data-level="6.3" data-path="Chapter_6.html"><a href="Chapter_6.html#systems-of-units"><i class="fa fa-check"></i><b>6.3</b> Systems of units</a></li>
<li class="chapter" data-level="6.4" data-path="Chapter_6.html"><a href="Chapter_6.html#other-examples-of-units"><i class="fa fa-check"></i><b>6.4</b> Other examples of units</a>
<ul>
<li class="chapter" data-level="6.4.1" data-path="Chapter_6.html"><a href="Chapter_6.html#units-of-density"><i class="fa fa-check"></i><b>6.4.1</b> Units of density</a></li>
<li class="chapter" data-level="6.4.2" data-path="Chapter_6.html"><a href="Chapter_6.html#mass-of-metal-discharged-from-a-catchment"><i class="fa fa-check"></i><b>6.4.2</b> Mass of metal discharged from a catchment</a></li>
<li class="chapter" data-level="6.4.3" data-path="Chapter_6.html"><a href="Chapter_6.html#soil-carbon-inventories"><i class="fa fa-check"></i><b>6.4.3</b> Soil carbon inventories</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="7" data-path="Chapter_7.html"><a href="Chapter_7.html"><i class="fa fa-check"></i><b>7</b> Uncertainty propagation</a>
<ul>
<li class="chapter" data-level="7.1" data-path="Chapter_7.html"><a href="Chapter_7.html#adding-or-subtracting-errors"><i class="fa fa-check"></i><b>7.1</b> Adding or subtracting errors</a></li>
<li class="chapter" data-level="7.2" data-path="Chapter_7.html"><a href="Chapter_7.html#multiplying-or-dividing-errors"><i class="fa fa-check"></i><b>7.2</b> Multiplying or dividing errors</a></li>
</ul></li>
<li class="chapter" data-level="8" data-path="Chapter_8.html"><a href="Chapter_8.html"><i class="fa fa-check"></i><b>8</b> <em>Practical</em>. Introduction to jamovi</a>
<ul>
<li class="chapter" data-level="8.1" data-path="Chapter_8.html"><a href="Chapter_8.html#summary_statistics_02"><i class="fa fa-check"></i><b>8.1</b> Exercise for summary statistics</a></li>
<li class="chapter" data-level="8.2" data-path="Chapter_8.html"><a href="Chapter_8.html#transforming_variables_02"><i class="fa fa-check"></i><b>8.2</b> Exercise on transforming variables</a></li>
<li class="chapter" data-level="8.3" data-path="Chapter_8.html"><a href="Chapter_8.html#computing_variables_02"><i class="fa fa-check"></i><b>8.3</b> Exercise on computing variables</a></li>
<li class="chapter" data-level="8.4" data-path="Chapter_8.html"><a href="Chapter_8.html#summary-1"><i class="fa fa-check"></i><b>8.4</b> Summary</a></li>
</ul></li>
<li class="part"><span><b>III Summary statistics</b></span></li>
<li class="chapter" data-level="" data-path="Week3.html"><a href="Week3.html"><i class="fa fa-check"></i>Part III Overview</a></li>
<li class="chapter" data-level="9" data-path="Chapter_9.html"><a href="Chapter_9.html"><i class="fa fa-check"></i><b>9</b> Decimal places, significant figures, and rounding</a>
<ul>
<li class="chapter" data-level="9.1" data-path="Chapter_9.html"><a href="Chapter_9.html#decimal-places-and-significant-figures"><i class="fa fa-check"></i><b>9.1</b> Decimal places and significant figures</a></li>
<li class="chapter" data-level="9.2" data-path="Chapter_9.html"><a href="Chapter_9.html#rounding"><i class="fa fa-check"></i><b>9.2</b> Rounding</a></li>
</ul></li>
<li class="chapter" data-level="10" data-path="Chapter_10.html"><a href="Chapter_10.html"><i class="fa fa-check"></i><b>10</b> Graphs</a>
<ul>
<li class="chapter" data-level="10.1" data-path="Chapter_10.html"><a href="Chapter_10.html#histograms"><i class="fa fa-check"></i><b>10.1</b> Histograms</a></li>
<li class="chapter" data-level="10.2" data-path="Chapter_10.html"><a href="Chapter_10.html#barplots-and-pie-charts"><i class="fa fa-check"></i><b>10.2</b> Barplots and pie charts</a></li>
<li class="chapter" data-level="10.3" data-path="Chapter_10.html"><a href="Chapter_10.html#box-whisker-plots"><i class="fa fa-check"></i><b>10.3</b> Box-whisker plots</a></li>
</ul></li>
<li class="chapter" data-level="11" data-path="Chapter_11.html"><a href="Chapter_11.html"><i class="fa fa-check"></i><b>11</b> Measures of central tendency</a>
<ul>
<li class="chapter" data-level="11.1" data-path="Chapter_11.html"><a href="Chapter_11.html#the-mean"><i class="fa fa-check"></i><b>11.1</b> The mean</a></li>
<li class="chapter" data-level="11.2" data-path="Chapter_11.html"><a href="Chapter_11.html#the-mode"><i class="fa fa-check"></i><b>11.2</b> The mode</a></li>
<li class="chapter" data-level="11.3" data-path="Chapter_11.html"><a href="Chapter_11.html#the-median-and-quantiles"><i class="fa fa-check"></i><b>11.3</b> The median and quantiles</a></li>
</ul></li>
<li class="chapter" data-level="12" data-path="Chapter_12.html"><a href="Chapter_12.html"><i class="fa fa-check"></i><b>12</b> Measures of spread</a>
<ul>
<li class="chapter" data-level="12.1" data-path="Chapter_12.html"><a href="Chapter_12.html#the-range"><i class="fa fa-check"></i><b>12.1</b> The range</a></li>
<li class="chapter" data-level="12.2" data-path="Chapter_12.html"><a href="Chapter_12.html#the-inter-quartile-range"><i class="fa fa-check"></i><b>12.2</b> The inter-quartile range</a></li>
<li class="chapter" data-level="12.3" data-path="Chapter_12.html"><a href="Chapter_12.html#the-variance"><i class="fa fa-check"></i><b>12.3</b> The variance</a></li>
<li class="chapter" data-level="12.4" data-path="Chapter_12.html"><a href="Chapter_12.html#the-standard-deviation"><i class="fa fa-check"></i><b>12.4</b> The standard deviation</a></li>
<li class="chapter" data-level="12.5" data-path="Chapter_12.html"><a href="Chapter_12.html#the-coefficient-of-variation"><i class="fa fa-check"></i><b>12.5</b> The coefficient of variation</a></li>
<li class="chapter" data-level="12.6" data-path="Chapter_12.html"><a href="Chapter_12.html#the-standard-error"><i class="fa fa-check"></i><b>12.6</b> The standard error</a></li>
</ul></li>
<li class="chapter" data-level="13" data-path="skew-and-kurtosis.html"><a href="skew-and-kurtosis.html"><i class="fa fa-check"></i><b>13</b> Skew and Kurtosis</a>
<ul>
<li class="chapter" data-level="13.1" data-path="skew-and-kurtosis.html"><a href="skew-and-kurtosis.html#skew"><i class="fa fa-check"></i><b>13.1</b> Skew</a></li>
<li class="chapter" data-level="13.2" data-path="skew-and-kurtosis.html"><a href="skew-and-kurtosis.html#kurtosis"><i class="fa fa-check"></i><b>13.2</b> Kurtosis</a></li>
<li class="chapter" data-level="13.3" data-path="skew-and-kurtosis.html"><a href="skew-and-kurtosis.html#moments"><i class="fa fa-check"></i><b>13.3</b> Moments</a></li>
</ul></li>
<li class="chapter" data-level="14" data-path="Chapter_14.html"><a href="Chapter_14.html"><i class="fa fa-check"></i><b>14</b> <em>Practical</em>. Plotting and statistical summaries in jamovi</a>
<ul>
<li class="chapter" data-level="14.1" data-path="Chapter_14.html"><a href="Chapter_14.html#reorganise-the-dataset-into-a-tidy-format"><i class="fa fa-check"></i><b>14.1</b> Reorganise the dataset into a tidy format</a></li>
<li class="chapter" data-level="14.2" data-path="Chapter_14.html"><a href="Chapter_14.html#histograms-and-box-whisker-plots"><i class="fa fa-check"></i><b>14.2</b> Histograms and box-whisker plots</a></li>
<li class="chapter" data-level="14.3" data-path="Chapter_14.html"><a href="Chapter_14.html#calculate-summary-statistics"><i class="fa fa-check"></i><b>14.3</b> Calculate summary statistics</a></li>
<li class="chapter" data-level="14.4" data-path="Chapter_14.html"><a href="Chapter_14.html#reporting-decimals-and-significant-figures"><i class="fa fa-check"></i><b>14.4</b> Reporting decimals and significant figures</a></li>
<li class="chapter" data-level="14.5" data-path="Chapter_14.html"><a href="Chapter_14.html#comparing-across-sites"><i class="fa fa-check"></i><b>14.5</b> Comparing across sites</a></li>
</ul></li>
<li class="part"><span><b>IV Probability models and the Central Limit Theorem</b></span></li>
<li class="chapter" data-level="" data-path="Week4.html"><a href="Week4.html"><i class="fa fa-check"></i>Part IV Overview</a></li>
<li class="chapter" data-level="15" data-path="Chapter_15.html"><a href="Chapter_15.html"><i class="fa fa-check"></i><b>15</b> Introduction to probability models</a>
<ul>
<li class="chapter" data-level="15.1" data-path="Chapter_15.html"><a href="Chapter_15.html#an-instructive-example"><i class="fa fa-check"></i><b>15.1</b> An instructive example</a></li>
<li class="chapter" data-level="15.2" data-path="Chapter_15.html"><a href="Chapter_15.html#biological-applications"><i class="fa fa-check"></i><b>15.2</b> Biological applications</a></li>
<li class="chapter" data-level="15.3" data-path="Chapter_15.html"><a href="Chapter_15.html#sampling-with-and-without-replacement"><i class="fa fa-check"></i><b>15.3</b> Sampling with and without replacement</a></li>
<li class="chapter" data-level="15.4" data-path="Chapter_15.html"><a href="Chapter_15.html#probability-distributions"><i class="fa fa-check"></i><b>15.4</b> Probability distributions</a>
<ul>
<li class="chapter" data-level="15.4.1" data-path="Chapter_15.html"><a href="Chapter_15.html#binomial-distribution"><i class="fa fa-check"></i><b>15.4.1</b> Binomial distribution</a></li>
<li class="chapter" data-level="15.4.2" data-path="Chapter_15.html"><a href="Chapter_15.html#poisson-distribution"><i class="fa fa-check"></i><b>15.4.2</b> Poisson distribution</a></li>
<li class="chapter" data-level="15.4.3" data-path="Chapter_15.html"><a href="Chapter_15.html#uniform-distribution"><i class="fa fa-check"></i><b>15.4.3</b> Uniform distribution</a></li>
<li class="chapter" data-level="15.4.4" data-path="Chapter_15.html"><a href="Chapter_15.html#normal-distribution"><i class="fa fa-check"></i><b>15.4.4</b> Normal distribution</a></li>
</ul></li>
<li class="chapter" data-level="15.5" data-path="Chapter_15.html"><a href="Chapter_15.html#summary-2"><i class="fa fa-check"></i><b>15.5</b> Summary</a></li>
</ul></li>
<li class="chapter" data-level="16" data-path="Chapter_16.html"><a href="Chapter_16.html"><i class="fa fa-check"></i><b>16</b> The Central Limit Theorem (CLT)</a>
<ul>
<li class="chapter" data-level="16.1" data-path="Chapter_16.html"><a href="Chapter_16.html#the-distribution-of-means-is-normal"><i class="fa fa-check"></i><b>16.1</b> The distribution of means is normal</a></li>
<li class="chapter" data-level="16.2" data-path="Chapter_16.html"><a href="Chapter_16.html#probability-and-z-scores"><i class="fa fa-check"></i><b>16.2</b> Probability and z-scores</a></li>
</ul></li>
<li class="chapter" data-level="17" data-path="Chapter_17.html"><a href="Chapter_17.html"><i class="fa fa-check"></i><b>17</b> <em>Practical</em>. Probability and simulation</a>
<ul>
<li class="chapter" data-level="17.1" data-path="Chapter_17.html"><a href="Chapter_17.html#probabilities-from-a-dataset"><i class="fa fa-check"></i><b>17.1</b> Probabilities from a dataset</a></li>
<li class="chapter" data-level="17.2" data-path="Chapter_17.html"><a href="Chapter_17.html#probabilities-from-a-normal-distribution"><i class="fa fa-check"></i><b>17.2</b> Probabilities from a normal distribution</a></li>
<li class="chapter" data-level="17.3" data-path="Chapter_17.html"><a href="Chapter_17.html#central-limit-theorem"><i class="fa fa-check"></i><b>17.3</b> Central limit theorem</a></li>
</ul></li>
<li class="part"><span><b>V Statistical inference</b></span></li>
<li class="chapter" data-level="" data-path="Week5.html"><a href="Week5.html"><i class="fa fa-check"></i>Part V Overview</a></li>
<li class="chapter" data-level="18" data-path="Chapter_18.html"><a href="Chapter_18.html"><i class="fa fa-check"></i><b>18</b> Confidence intervals (CIs)</a>
<ul>
<li class="chapter" data-level="18.1" data-path="Chapter_18.html"><a href="Chapter_18.html#normal-distribution-cis"><i class="fa fa-check"></i><b>18.1</b> Normal distribution CIs</a></li>
<li class="chapter" data-level="18.2" data-path="Chapter_18.html"><a href="Chapter_18.html#binomial-distribution-cis"><i class="fa fa-check"></i><b>18.2</b> Binomial distribution CIs</a></li>
</ul></li>
<li class="chapter" data-level="19" data-path="Chapter_19.html"><a href="Chapter_19.html"><i class="fa fa-check"></i><b>19</b> The t-interval</a></li>
<li class="chapter" data-level="20" data-path="Chapter_20.html"><a href="Chapter_20.html"><i class="fa fa-check"></i><b>20</b> <em>Practical</em>. z- and t- intervals</a>
<ul>
<li class="chapter" data-level="20.1" data-path="Chapter_20.html"><a href="Chapter_20.html#confidence-intervals-with-distraction"><i class="fa fa-check"></i><b>20.1</b> Confidence intervals with distrACTION</a></li>
<li class="chapter" data-level="20.2" data-path="Chapter_20.html"><a href="Chapter_20.html#confidence-intervals-from-z--and-t-scores"><i class="fa fa-check"></i><b>20.2</b> Confidence intervals from z- and t-scores</a></li>
<li class="chapter" data-level="20.3" data-path="Chapter_20.html"><a href="Chapter_20.html#confidence-intervals-for-different-sample-sizes-t--and-z-"><i class="fa fa-check"></i><b>20.3</b> Confidence intervals for different sample sizes (t- and z-)</a></li>
<li class="chapter" data-level="20.4" data-path="Chapter_20.html"><a href="Chapter_20.html#proportion-confidence-intervals"><i class="fa fa-check"></i><b>20.4</b> Proportion confidence intervals</a></li>
<li class="chapter" data-level="20.5" data-path="Chapter_20.html"><a href="Chapter_20.html#another-proportion-confidence-interval"><i class="fa fa-check"></i><b>20.5</b> Another proportion confidence interval</a></li>
</ul></li>
<li class="part"><span><b>VI Hypothesis testing</b></span></li>
<li class="chapter" data-level="" data-path="Week6.html"><a href="Week6.html"><i class="fa fa-check"></i>Part VI Overview</a></li>
<li class="chapter" data-level="21" data-path="Chapter_21.html"><a href="Chapter_21.html"><i class="fa fa-check"></i><b>21</b> What is hypothesis testing?</a>
<ul>
<li class="chapter" data-level="21.1" data-path="Chapter_21.html"><a href="Chapter_21.html#how-ridiculous-is-our-hypothesis"><i class="fa fa-check"></i><b>21.1</b> How ridiculous is our hypothesis?</a></li>
<li class="chapter" data-level="21.2" data-path="Chapter_21.html"><a href="Chapter_21.html#statistical-hypothesis-testing"><i class="fa fa-check"></i><b>21.2</b> Statistical hypothesis testing</a></li>
<li class="chapter" data-level="21.3" data-path="Chapter_21.html"><a href="Chapter_21.html#p-values-false-positives-and-power"><i class="fa fa-check"></i><b>21.3</b> P-values, false positives, and power</a></li>
</ul></li>
<li class="chapter" data-level="22" data-path="Chapter_22.html"><a href="Chapter_22.html"><i class="fa fa-check"></i><b>22</b> The t-test</a>
<ul>
<li class="chapter" data-level="22.1" data-path="Chapter_22.html"><a href="Chapter_22.html#one-sample-t-test"><i class="fa fa-check"></i><b>22.1</b> One sample t-test</a></li>
<li class="chapter" data-level="22.2" data-path="Chapter_22.html"><a href="Chapter_22.html#independent-samples-t-test"><i class="fa fa-check"></i><b>22.2</b> Independent samples t-test</a></li>
<li class="chapter" data-level="22.3" data-path="Chapter_22.html"><a href="Chapter_22.html#paired-sample-t-test"><i class="fa fa-check"></i><b>22.3</b> Paired sample t-test</a></li>
<li class="chapter" data-level="22.4" data-path="Chapter_22.html"><a href="Chapter_22.html#assumptions-of-t-tests"><i class="fa fa-check"></i><b>22.4</b> Assumptions of t-tests</a></li>
<li class="chapter" data-level="22.5" data-path="Chapter_22.html"><a href="Chapter_22.html#non-parametric-alternatives"><i class="fa fa-check"></i><b>22.5</b> Non-parametric alternatives</a>
<ul>
<li class="chapter" data-level="22.5.1" data-path="Chapter_22.html"><a href="Chapter_22.html#wilcoxon-test"><i class="fa fa-check"></i><b>22.5.1</b> Wilcoxon test</a></li>
<li class="chapter" data-level="22.5.2" data-path="Chapter_22.html"><a href="Chapter_22.html#mann-whitney-u-test"><i class="fa fa-check"></i><b>22.5.2</b> Mann-Whitney U test</a></li>
</ul></li>
<li class="chapter" data-level="22.6" data-path="Chapter_22.html"><a href="Chapter_22.html#summary-3"><i class="fa fa-check"></i><b>22.6</b> Summary</a></li>
</ul></li>
<li class="chapter" data-level="23" data-path="Chapter_23.html"><a href="Chapter_23.html"><i class="fa fa-check"></i><b>23</b> <em>Practical</em>. Hypothesis testing and t-tests</a>
<ul>
<li class="chapter" data-level="23.1" data-path="Chapter_23.html"><a href="Chapter_23.html#exercise-on-a-simple-one-sample-t-test"><i class="fa fa-check"></i><b>23.1</b> Exercise on a simple one sample t-test</a></li>
<li class="chapter" data-level="23.2" data-path="Chapter_23.html"><a href="Chapter_23.html#exercise-on-a-paired-t-test"><i class="fa fa-check"></i><b>23.2</b> Exercise on a paired t-test</a></li>
<li class="chapter" data-level="23.3" data-path="Chapter_23.html"><a href="Chapter_23.html#wilcoxon-test-1"><i class="fa fa-check"></i><b>23.3</b> Wilcoxon test</a></li>
<li class="chapter" data-level="23.4" data-path="Chapter_23.html"><a href="Chapter_23.html#independent-samples-t-test-1"><i class="fa fa-check"></i><b>23.4</b> Independent samples t-test</a></li>
<li class="chapter" data-level="23.5" data-path="Chapter_23.html"><a href="Chapter_23.html#mann-whitney-u-test-1"><i class="fa fa-check"></i><b>23.5</b> Mann-Whitney U Test</a></li>
</ul></li>
<li class="part"><span><b>VII Analysis of Variance (ANOVA)</b></span></li>
<li class="chapter" data-level="" data-path="Week8.html"><a href="Week8.html"><i class="fa fa-check"></i>Part VII Overview</a></li>
<li class="chapter" data-level="24" data-path="Chapter_24.html"><a href="Chapter_24.html"><i class="fa fa-check"></i><b>24</b> Analysis of variance</a>
<ul>
<li class="chapter" data-level="24.1" data-path="Chapter_24.html"><a href="Chapter_24.html#the-f-distribution"><i class="fa fa-check"></i><b>24.1</b> The F-distribution</a></li>
<li class="chapter" data-level="24.2" data-path="Chapter_24.html"><a href="Chapter_24.html#one-way-anova"><i class="fa fa-check"></i><b>24.2</b> One-way ANOVA</a>
<ul>
<li class="chapter" data-level="24.2.1" data-path="Chapter_24.html"><a href="Chapter_24.html#anova-mean-variance-among-groups"><i class="fa fa-check"></i><b>24.2.1</b> ANOVA mean variance among groups</a></li>
<li class="chapter" data-level="24.2.2" data-path="Chapter_24.html"><a href="Chapter_24.html#anova-mean-variance-within-groups"><i class="fa fa-check"></i><b>24.2.2</b> ANOVA mean variance within groups</a></li>
<li class="chapter" data-level="24.2.3" data-path="Chapter_24.html"><a href="Chapter_24.html#anova-f-statistic-calculation"><i class="fa fa-check"></i><b>24.2.3</b> ANOVA F statistic calculation</a></li>
</ul></li>
<li class="chapter" data-level="24.3" data-path="Chapter_24.html"><a href="Chapter_24.html#assumptions-of-anova"><i class="fa fa-check"></i><b>24.3</b> Assumptions of ANOVA</a></li>
</ul></li>
<li class="chapter" data-level="25" data-path="Chapter_25.html"><a href="Chapter_25.html"><i class="fa fa-check"></i><b>25</b> Multiple comparisons</a></li>
<li class="chapter" data-level="26" data-path="Chapter_26.html"><a href="Chapter_26.html"><i class="fa fa-check"></i><b>26</b> Kruskall-Wallis H test</a></li>
<li class="chapter" data-level="27" data-path="Chapter_27.html"><a href="Chapter_27.html"><i class="fa fa-check"></i><b>27</b> Two-way ANOVA</a></li>
<li class="chapter" data-level="28" data-path="Chapter_28.html"><a href="Chapter_28.html"><i class="fa fa-check"></i><b>28</b> <em>Practical</em>. ANOVA and associated tests</a>
<ul>
<li class="chapter" data-level="28.1" data-path="Chapter_28.html"><a href="Chapter_28.html#one-way-anova-site"><i class="fa fa-check"></i><b>28.1</b> One-way ANOVA (site)</a></li>
<li class="chapter" data-level="28.2" data-path="Chapter_28.html"><a href="Chapter_28.html#one-way-anova-profile"><i class="fa fa-check"></i><b>28.2</b> One-way ANOVA (profile)</a></li>
<li class="chapter" data-level="28.3" data-path="Chapter_28.html"><a href="Chapter_28.html#multiple-comparisons"><i class="fa fa-check"></i><b>28.3</b> Multiple comparisons</a></li>
<li class="chapter" data-level="28.4" data-path="Chapter_28.html"><a href="Chapter_28.html#kruskall-wallis-h-test"><i class="fa fa-check"></i><b>28.4</b> Kruskall-Wallis H test</a></li>
<li class="chapter" data-level="28.5" data-path="Chapter_28.html"><a href="Chapter_28.html#two-way-anova"><i class="fa fa-check"></i><b>28.5</b> Two-way ANOVA</a></li>
</ul></li>
<li class="part"><span><b>VIII Counts and Correlation</b></span></li>
<li class="chapter" data-level="" data-path="Week9.html"><a href="Week9.html"><i class="fa fa-check"></i>Part VIII Overview</a></li>
<li class="chapter" data-level="29" data-path="Chapter_29.html"><a href="Chapter_29.html"><i class="fa fa-check"></i><b>29</b> Frequency and count data</a>
<ul>
<li class="chapter" data-level="29.1" data-path="Chapter_29.html"><a href="Chapter_29.html#the-chi-square-distribution"><i class="fa fa-check"></i><b>29.1</b> The Chi-square distribution</a></li>
<li class="chapter" data-level="29.2" data-path="Chapter_29.html"><a href="Chapter_29.html#chi-squared-goodness-of-fit"><i class="fa fa-check"></i><b>29.2</b> Chi-squared goodness of fit</a></li>
<li class="chapter" data-level="29.3" data-path="Chapter_29.html"><a href="Chapter_29.html#chi-squared-test-of-association"><i class="fa fa-check"></i><b>29.3</b> Chi-squared test of association</a></li>
</ul></li>
<li class="chapter" data-level="30" data-path="Chapter_30.html"><a href="Chapter_30.html"><i class="fa fa-check"></i><b>30</b> Correlation</a>
<ul>
<li class="chapter" data-level="30.1" data-path="Chapter_30.html"><a href="Chapter_30.html#scatterplots"><i class="fa fa-check"></i><b>30.1</b> Scatterplots</a></li>
<li class="chapter" data-level="30.2" data-path="Chapter_30.html"><a href="Chapter_30.html#the-correlation-coefficient"><i class="fa fa-check"></i><b>30.2</b> The correlation coefficient</a>
<ul>
<li class="chapter" data-level="30.2.1" data-path="Chapter_30.html"><a href="Chapter_30.html#pearson-product-moment-correlation-coefficient"><i class="fa fa-check"></i><b>30.2.1</b> Pearson product moment correlation coefficient</a></li>
<li class="chapter" data-level="30.2.2" data-path="Chapter_30.html"><a href="Chapter_30.html#spearman-rank-correlation-coefficient"><i class="fa fa-check"></i><b>30.2.2</b> Spearman rank correlation coefficient</a></li>
</ul></li>
<li class="chapter" data-level="30.3" data-path="Chapter_30.html"><a href="Chapter_30.html#correlation-hypothesis-testing"><i class="fa fa-check"></i><b>30.3</b> Correlation hypothesis testing</a></li>
</ul></li>
<li class="chapter" data-level="31" data-path="Chapter_31.html"><a href="Chapter_31.html"><i class="fa fa-check"></i><b>31</b> <em>Practical</em>. Analysis of counts and correlations</a>
<ul>
<li class="chapter" data-level="31.1" data-path="Chapter_31.html"><a href="Chapter_31.html#survival-goodness-of-fit"><i class="fa fa-check"></i><b>31.1</b> Survival goodness of fit</a></li>
<li class="chapter" data-level="31.2" data-path="Chapter_31.html"><a href="Chapter_31.html#colony-goodness-of-fit"><i class="fa fa-check"></i><b>31.2</b> Colony goodness of fit</a></li>
<li class="chapter" data-level="31.3" data-path="Chapter_31.html"><a href="Chapter_31.html#chi-square-test-of-association"><i class="fa fa-check"></i><b>31.3</b> Chi-Square test of association</a></li>
<li class="chapter" data-level="31.4" data-path="Chapter_31.html"><a href="Chapter_31.html#pearson-product-moment-correlation-test"><i class="fa fa-check"></i><b>31.4</b> Pearson product moment correlation test</a></li>
<li class="chapter" data-level="31.5" data-path="Chapter_31.html"><a href="Chapter_31.html#spearman-rank-correlation-test"><i class="fa fa-check"></i><b>31.5</b> Spearman rank correlation test</a></li>
<li class="chapter" data-level="31.6" data-path="Chapter_31.html"><a href="Chapter_31.html#untidy-goodness-of-fit"><i class="fa fa-check"></i><b>31.6</b> Untidy goodness of fit</a></li>
</ul></li>
<li class="part"><span><b>IX Linear Regression</b></span></li>
<li class="chapter" data-level="" data-path="Week10.html"><a href="Week10.html"><i class="fa fa-check"></i>Part IX Overview</a></li>
<li class="chapter" data-level="32" data-path="Chapter_32.html"><a href="Chapter_32.html"><i class="fa fa-check"></i><b>32</b> Simple linear regression</a>
<ul>
<li class="chapter" data-level="32.1" data-path="Chapter_32.html"><a href="Chapter_32.html#visual-interpretation-of-regression"><i class="fa fa-check"></i><b>32.1</b> Visual interpretation of regression</a></li>
<li class="chapter" data-level="32.2" data-path="Chapter_32.html"><a href="Chapter_32.html#intercepts-slopes-and-residuals"><i class="fa fa-check"></i><b>32.2</b> Intercepts, slopes, and residuals</a></li>
<li class="chapter" data-level="32.3" data-path="Chapter_32.html"><a href="Chapter_32.html#regression-coefficients"><i class="fa fa-check"></i><b>32.3</b> Regression coefficients</a></li>
<li class="chapter" data-level="32.4" data-path="Chapter_32.html"><a href="Chapter_32.html#regression-line-calculation"><i class="fa fa-check"></i><b>32.4</b> Regression line calculation</a></li>
<li class="chapter" data-level="32.5" data-path="Chapter_32.html"><a href="Chapter_32.html#coefficient-of-determination"><i class="fa fa-check"></i><b>32.5</b> Coefficient of determination</a></li>
<li class="chapter" data-level="32.6" data-path="Chapter_32.html"><a href="Chapter_32.html#regression-assumptions"><i class="fa fa-check"></i><b>32.6</b> Regression assumptions</a></li>
<li class="chapter" data-level="32.7" data-path="Chapter_32.html"><a href="Chapter_32.html#regression-hypothesis-testing"><i class="fa fa-check"></i><b>32.7</b> Regression hypothesis testing</a>
<ul>
<li class="chapter" data-level="32.7.1" data-path="Chapter_32.html"><a href="Chapter_32.html#overall-model-significance"><i class="fa fa-check"></i><b>32.7.1</b> Overall model significance</a></li>
<li class="chapter" data-level="32.7.2" data-path="Chapter_32.html"><a href="Chapter_32.html#significance-of-the-intercept"><i class="fa fa-check"></i><b>32.7.2</b> Significance of the intercept</a></li>
<li class="chapter" data-level="32.7.3" data-path="Chapter_32.html"><a href="Chapter_32.html#significance-of-the-slope"><i class="fa fa-check"></i><b>32.7.3</b> Significance of the slope</a></li>
<li class="chapter" data-level="32.7.4" data-path="Chapter_32.html"><a href="Chapter_32.html#simple-regression-output"><i class="fa fa-check"></i><b>32.7.4</b> Simple regression output</a></li>
</ul></li>
<li class="chapter" data-level="32.8" data-path="Chapter_32.html"><a href="Chapter_32.html#prediction-with-linear-models"><i class="fa fa-check"></i><b>32.8</b> Prediction with linear models</a></li>
<li class="chapter" data-level="32.9" data-path="Chapter_32.html"><a href="Chapter_32.html#conclusion"><i class="fa fa-check"></i><b>32.9</b> Conclusion</a></li>
</ul></li>
<li class="chapter" data-level="33" data-path="Chapter_33.html"><a href="Chapter_33.html"><i class="fa fa-check"></i><b>33</b> Multiple regression</a>
<ul>
<li class="chapter" data-level="33.1" data-path="Chapter_33.html"><a href="Chapter_33.html#adjusted-coefficient-of-determination"><i class="fa fa-check"></i><b>33.1</b> Adjusted coefficient of determination</a></li>
</ul></li>
<li class="chapter" data-level="34" data-path="Chapter_34.html"><a href="Chapter_34.html"><i class="fa fa-check"></i><b>34</b> <em>Practical</em>. Using regression</a>
<ul>
<li class="chapter" data-level="34.1" data-path="Chapter_34.html"><a href="Chapter_34.html#predicting-pyrogenic-carbon-from-soil-depth"><i class="fa fa-check"></i><b>34.1</b> Predicting pyrogenic carbon from soil depth</a></li>
<li class="chapter" data-level="34.2" data-path="Chapter_34.html"><a href="Chapter_34.html#predicting-pyrogenic-carbon-from-fire-frequency"><i class="fa fa-check"></i><b>34.2</b> Predicting pyrogenic carbon from fire frequency</a></li>
<li class="chapter" data-level="34.3" data-path="Chapter_34.html"><a href="Chapter_34.html#multiple-regression-depth-and-fire-frequency"><i class="fa fa-check"></i><b>34.3</b> Multiple regression depth and fire frequency</a></li>
<li class="chapter" data-level="34.4" data-path="Chapter_34.html"><a href="Chapter_34.html#large-multiple-regression"><i class="fa fa-check"></i><b>34.4</b> Large multiple regression</a></li>
<li class="chapter" data-level="34.5" data-path="Chapter_34.html"><a href="Chapter_34.html#predicting-temperature-from-fire-frequency"><i class="fa fa-check"></i><b>34.5</b> Predicting temperature from fire frequency</a></li>
</ul></li>
<li class="part"><span><b>X Randomisation approaches</b></span></li>
<li class="chapter" data-level="" data-path="Week11.html"><a href="Week11.html"><i class="fa fa-check"></i>Part X Overview</a></li>
<li class="chapter" data-level="35" data-path="Chapter_35.html"><a href="Chapter_35.html"><i class="fa fa-check"></i><b>35</b> Randomisation</a>
<ul>
<li class="chapter" data-level="35.1" data-path="Chapter_35.html"><a href="Chapter_35.html#summary-of-parametric-hypothesis-testing"><i class="fa fa-check"></i><b>35.1</b> Summary of parametric hypothesis testing</a></li>
<li class="chapter" data-level="35.2" data-path="Chapter_35.html"><a href="Chapter_35.html#randomisation-approach"><i class="fa fa-check"></i><b>35.2</b> Randomisation approach</a></li>
<li class="chapter" data-level="35.3" data-path="Chapter_35.html"><a href="Chapter_35.html#randomisation-for-hypothesis-testing"><i class="fa fa-check"></i><b>35.3</b> Randomisation for hypothesis testing</a></li>
<li class="chapter" data-level="35.4" data-path="Chapter_35.html"><a href="Chapter_35.html#randomisation-assumptions"><i class="fa fa-check"></i><b>35.4</b> Randomisation assumptions</a></li>
<li class="chapter" data-level="35.5" data-path="Chapter_35.html"><a href="Chapter_35.html#bootstrapping"><i class="fa fa-check"></i><b>35.5</b> Bootstrapping</a></li>
<li class="chapter" data-level="35.6" data-path="Chapter_35.html"><a href="Chapter_35.html#monte-carlo"><i class="fa fa-check"></i><b>35.6</b> Monte Carlo</a></li>
<li class="chapter" data-level="35.7" data-path="Chapter_35.html"><a href="Chapter_35.html#randomisation-conclusions"><i class="fa fa-check"></i><b>35.7</b> Randomisation conclusions</a></li>
</ul></li>
<li class="chapter" data-level="36" data-path="Chapter_36.html"><a href="Chapter_36.html"><i class="fa fa-check"></i><b>36</b> <em>Practical</em>. Introduction to R</a>
<ul>
<li class="chapter" data-level="36.1" data-path="Chapter_36.html"><a href="Chapter_36.html#getting-used-to-the-r-interface"><i class="fa fa-check"></i><b>36.1</b> Getting used to the R interface</a></li>
<li class="chapter" data-level="36.2" data-path="Chapter_36.html"><a href="Chapter_36.html#assigning-variables-in-the-r-console"><i class="fa fa-check"></i><b>36.2</b> Assigning variables in the R console</a></li>
<li class="chapter" data-level="36.3" data-path="Chapter_36.html"><a href="Chapter_36.html#some-descriptive-statistics"><i class="fa fa-check"></i><b>36.3</b> Some descriptive statistics</a></li>
<li class="chapter" data-level="36.4" data-path="Chapter_36.html"><a href="Chapter_36.html#bootstrapping-confidence-intervals"><i class="fa fa-check"></i><b>36.4</b> Bootstrapping confidence intervals</a></li>
</ul></li>
<li class="part"><span><b>XI Experimental Design and Statistical Reporting</b></span></li>
<li class="chapter" data-level="" data-path="Week12.html"><a href="Week12.html"><i class="fa fa-check"></i>Part XI Overview</a></li>
<li class="chapter" data-level="37" data-path="Chapter_37.html"><a href="Chapter_37.html"><i class="fa fa-check"></i><b>37</b> Experimental design</a>
<ul>
<li class="chapter" data-level="37.1" data-path="Chapter_37.html"><a href="Chapter_37.html#before-collecting-data"><i class="fa fa-check"></i><b>37.1</b> Before collecting data</a></li>
</ul></li>
<li class="chapter" data-level="38" data-path="Chapter_38.html"><a href="Chapter_38.html"><i class="fa fa-check"></i><b>38</b> Reporting statistics</a>
<ul>
<li class="chapter" data-level="38.1" data-path="Chapter_38.html"><a href="Chapter_38.html#statistical-reporting"><i class="fa fa-check"></i><b>38.1</b> Statistical reporting</a>
<ul>
<li class="chapter" data-level="38.1.1" data-path="Chapter_38.html"><a href="Chapter_38.html#abstract"><i class="fa fa-check"></i><b>38.1.1</b> Abstract</a></li>
<li class="chapter" data-level="38.1.2" data-path="Chapter_38.html"><a href="Chapter_38.html#introduction"><i class="fa fa-check"></i><b>38.1.2</b> Introduction</a></li>
<li class="chapter" data-level="38.1.3" data-path="Chapter_38.html"><a href="Chapter_38.html#methods"><i class="fa fa-check"></i><b>38.1.3</b> Methods</a></li>
<li class="chapter" data-level="38.1.4" data-path="Chapter_38.html"><a href="Chapter_38.html#results"><i class="fa fa-check"></i><b>38.1.4</b> Results</a></li>
<li class="chapter" data-level="38.1.5" data-path="Chapter_38.html"><a href="Chapter_38.html#discussion"><i class="fa fa-check"></i><b>38.1.5</b> Discussion</a></li>
</ul></li>
<li class="chapter" data-level="38.2" data-path="Chapter_38.html"><a href="Chapter_38.html#figures-and-tables"><i class="fa fa-check"></i><b>38.2</b> Figures and tables</a>
<ul>
<li class="chapter" data-level="38.2.1" data-path="Chapter_38.html"><a href="Chapter_38.html#figures"><i class="fa fa-check"></i><b>38.2.1</b> Figures</a></li>
<li class="chapter" data-level="38.2.2" data-path="Chapter_38.html"><a href="Chapter_38.html#tables"><i class="fa fa-check"></i><b>38.2.2</b> Tables</a></li>
</ul></li>
<li class="chapter" data-level="38.3" data-path="Chapter_38.html"><a href="Chapter_38.html#statistical-tests"><i class="fa fa-check"></i><b>38.3</b> Statistical tests</a>
<ul>
<li class="chapter" data-level="38.3.1" data-path="Chapter_38.html"><a href="Chapter_38.html#reporting-t-tests"><i class="fa fa-check"></i><b>38.3.1</b> Reporting t-tests</a></li>
<li class="chapter" data-level="38.3.2" data-path="Chapter_38.html"><a href="Chapter_38.html#reporting-anova"><i class="fa fa-check"></i><b>38.3.2</b> Reporting ANOVA</a></li>
<li class="chapter" data-level="38.3.3" data-path="Chapter_38.html"><a href="Chapter_38.html#reporting-a-main-whitney-u-test"><i class="fa fa-check"></i><b>38.3.3</b> Reporting a Main-Whitney U test</a></li>
<li class="chapter" data-level="38.3.4" data-path="Chapter_38.html"><a href="Chapter_38.html#reporting-a-wilcoxon-signed-rank-test"><i class="fa fa-check"></i><b>38.3.4</b> Reporting a Wilcoxon signed-rank test</a></li>
<li class="chapter" data-level="38.3.5" data-path="Chapter_38.html"><a href="Chapter_38.html#reporting-chi-square-tests"><i class="fa fa-check"></i><b>38.3.5</b> Reporting Chi-square tests</a></li>
<li class="chapter" data-level="38.3.6" data-path="Chapter_38.html"><a href="Chapter_38.html#reporting-correlation-coefficients"><i class="fa fa-check"></i><b>38.3.6</b> Reporting correlation coefficients</a></li>
<li class="chapter" data-level="38.3.7" data-path="Chapter_38.html"><a href="Chapter_38.html#reporting-regressions"><i class="fa fa-check"></i><b>38.3.7</b> Reporting regressions</a></li>
</ul></li>
<li class="chapter" data-level="38.4" data-path="Chapter_38.html"><a href="Chapter_38.html#conclusions"><i class="fa fa-check"></i><b>38.4</b> Conclusions</a></li>
</ul></li>
<li class="chapter" data-level="39" data-path="Chapter_39.html"><a href="Chapter_39.html"><i class="fa fa-check"></i><b>39</b> <em>Practical</em>. Statistical techniques in R</a>
<ul>
<li class="chapter" data-level="39.1" data-path="Chapter_39.html"><a href="Chapter_39.html#working-with-a-data-set"><i class="fa fa-check"></i><b>39.1</b> Working with a data set</a></li>
<li class="chapter" data-level="39.2" data-path="Chapter_39.html"><a href="Chapter_39.html#familiar-statistical-tests-in-r"><i class="fa fa-check"></i><b>39.2</b> Familiar statistical tests in R</a>
<ul>
<li class="chapter" data-level="39.2.1" data-path="Chapter_39.html"><a href="Chapter_39.html#one-way-anova-in-r"><i class="fa fa-check"></i><b>39.2.1</b> One-way ANOVA in R</a></li>
<li class="chapter" data-level="39.2.2" data-path="Chapter_39.html"><a href="Chapter_39.html#two-way-anova-in-r"><i class="fa fa-check"></i><b>39.2.2</b> Two-way ANOVA in R</a></li>
<li class="chapter" data-level="39.2.3" data-path="Chapter_39.html"><a href="Chapter_39.html#chi-square-test-in-r"><i class="fa fa-check"></i><b>39.2.3</b> Chi-square test in R</a></li>
<li class="chapter" data-level="39.2.4" data-path="Chapter_39.html"><a href="Chapter_39.html#correlation-test-in-r"><i class="fa fa-check"></i><b>39.2.4</b> Correlation test in R</a></li>
<li class="chapter" data-level="39.2.5" data-path="Chapter_39.html"><a href="Chapter_39.html#simple-linear-regression-in-r"><i class="fa fa-check"></i><b>39.2.5</b> Simple linear regression in R</a></li>
<li class="chapter" data-level="39.2.6" data-path="Chapter_39.html"><a href="Chapter_39.html#multiple-regression-in-r"><i class="fa fa-check"></i><b>39.2.6</b> Multiple regression in R</a></li>
</ul></li>
<li class="chapter" data-level="39.3" data-path="Chapter_39.html"><a href="Chapter_39.html#statistical-test-assumptions-in-r"><i class="fa fa-check"></i><b>39.3</b> Statistical test assumptions in R</a></li>
</ul></li>
<li class="appendix"><span><b>Appendix</b></span></li>
<li class="chapter" data-level="A" data-path="appendexA.html"><a href="appendexA.html"><i class="fa fa-check"></i><b>A</b> Answers to chapter exercises</a>
<ul>
<li class="chapter" data-level="A.1" data-path="appendexA.html"><a href="appendexA.html#chapter-3"><i class="fa fa-check"></i><b>A.1</b> Chapter 3</a>
<ul>
<li class="chapter" data-level="A.1.1" data-path="appendexA.html"><a href="appendexA.html#exercise-3.1"><i class="fa fa-check"></i><b>A.1.1</b> Exercise 3.1:</a></li>
<li class="chapter" data-level="A.1.2" data-path="appendexA.html"><a href="appendexA.html#exercise-3.2"><i class="fa fa-check"></i><b>A.1.2</b> Exercise 3.2</a></li>
<li class="chapter" data-level="A.1.3" data-path="appendexA.html"><a href="appendexA.html#exercise-3.2-1"><i class="fa fa-check"></i><b>A.1.3</b> Exercise 3.2</a></li>
<li class="chapter" data-level="A.1.4" data-path="appendexA.html"><a href="appendexA.html#exercise-3.4"><i class="fa fa-check"></i><b>A.1.4</b> Exercise 3.4</a></li>
</ul></li>
<li class="chapter" data-level="A.2" data-path="appendexA.html"><a href="appendexA.html#chapter-8"><i class="fa fa-check"></i><b>A.2</b> Chapter 8</a>
<ul>
<li class="chapter" data-level="A.2.1" data-path="appendexA.html"><a href="appendexA.html#exercise-8.1"><i class="fa fa-check"></i><b>A.2.1</b> Exercise 8.1</a></li>
<li class="chapter" data-level="A.2.2" data-path="appendexA.html"><a href="appendexA.html#exercise-8.2"><i class="fa fa-check"></i><b>A.2.2</b> Exercise 8.2</a></li>
<li class="chapter" data-level="A.2.3" data-path="appendexA.html"><a href="appendexA.html#exercise-8.3"><i class="fa fa-check"></i><b>A.2.3</b> Exercise 8.3</a></li>
</ul></li>
<li class="chapter" data-level="A.3" data-path="appendexA.html"><a href="appendexA.html#chapter-14"><i class="fa fa-check"></i><b>A.3</b> Chapter 14</a>
<ul>
<li class="chapter" data-level="A.3.1" data-path="appendexA.html"><a href="appendexA.html#exercise-14.1"><i class="fa fa-check"></i><b>A.3.1</b> Exercise 14.1</a></li>
<li class="chapter" data-level="A.3.2" data-path="appendexA.html"><a href="appendexA.html#exercise-14.2"><i class="fa fa-check"></i><b>A.3.2</b> Exercise 14.2</a></li>
<li class="chapter" data-level="A.3.3" data-path="appendexA.html"><a href="appendexA.html#exercise-13.3"><i class="fa fa-check"></i><b>A.3.3</b> Exercise 13.3</a></li>
<li class="chapter" data-level="A.3.4" data-path="appendexA.html"><a href="appendexA.html#exercise-13.4"><i class="fa fa-check"></i><b>A.3.4</b> Exercise 13.4</a></li>
<li class="chapter" data-level="A.3.5" data-path="appendexA.html"><a href="appendexA.html#exercise-13.5"><i class="fa fa-check"></i><b>A.3.5</b> Exercise 13.5</a></li>
</ul></li>
<li class="chapter" data-level="A.4" data-path="appendexA.html"><a href="appendexA.html#chapter-17"><i class="fa fa-check"></i><b>A.4</b> Chapter 17</a>
<ul>
<li class="chapter" data-level="A.4.1" data-path="appendexA.html"><a href="appendexA.html#exercise-17.1"><i class="fa fa-check"></i><b>A.4.1</b> Exercise 17.1</a></li>
<li class="chapter" data-level="A.4.2" data-path="appendexA.html"><a href="appendexA.html#exercise-17.2"><i class="fa fa-check"></i><b>A.4.2</b> Exercise 17.2</a></li>
<li class="chapter" data-level="A.4.3" data-path="appendexA.html"><a href="appendexA.html#exercise-17.3"><i class="fa fa-check"></i><b>A.4.3</b> Exercise 17.3</a></li>
</ul></li>
<li class="chapter" data-level="A.5" data-path="appendexA.html"><a href="appendexA.html#chapter-20"><i class="fa fa-check"></i><b>A.5</b> Chapter 20</a>
<ul>
<li class="chapter" data-level="A.5.1" data-path="appendexA.html"><a href="appendexA.html#exercise-20.1"><i class="fa fa-check"></i><b>A.5.1</b> Exercise 20.1</a></li>
<li class="chapter" data-level="A.5.2" data-path="appendexA.html"><a href="appendexA.html#exercise-20.2"><i class="fa fa-check"></i><b>A.5.2</b> Exercise 20.2</a></li>
<li class="chapter" data-level="A.5.3" data-path="appendexA.html"><a href="appendexA.html#exercise-20.3"><i class="fa fa-check"></i><b>A.5.3</b> Exercise 20.3</a></li>
<li class="chapter" data-level="A.5.4" data-path="appendexA.html"><a href="appendexA.html#exercise-20.4"><i class="fa fa-check"></i><b>A.5.4</b> Exercise 20.4</a></li>
<li class="chapter" data-level="A.5.5" data-path="appendexA.html"><a href="appendexA.html#exercise-20.5"><i class="fa fa-check"></i><b>A.5.5</b> Exercise 20.5</a></li>
</ul></li>
<li class="chapter" data-level="A.6" data-path="appendexA.html"><a href="appendexA.html#chapter-23"><i class="fa fa-check"></i><b>A.6</b> Chapter 23</a>
<ul>
<li class="chapter" data-level="A.6.1" data-path="appendexA.html"><a href="appendexA.html#exercise-23.1"><i class="fa fa-check"></i><b>A.6.1</b> Exercise 23.1</a></li>
<li class="chapter" data-level="A.6.2" data-path="appendexA.html"><a href="appendexA.html#exercise-23.2"><i class="fa fa-check"></i><b>A.6.2</b> Exercise 23.2</a></li>
<li class="chapter" data-level="A.6.3" data-path="appendexA.html"><a href="appendexA.html#exercise-23.3"><i class="fa fa-check"></i><b>A.6.3</b> Exercise 23.3</a></li>
<li class="chapter" data-level="A.6.4" data-path="appendexA.html"><a href="appendexA.html#exercise-23.4"><i class="fa fa-check"></i><b>A.6.4</b> Exercise 23.4</a></li>
<li class="chapter" data-level="A.6.5" data-path="appendexA.html"><a href="appendexA.html#exercise-23.5"><i class="fa fa-check"></i><b>A.6.5</b> Exercise 23.5</a></li>
</ul></li>
<li class="chapter" data-level="A.7" data-path="appendexA.html"><a href="appendexA.html#chapter-28"><i class="fa fa-check"></i><b>A.7</b> Chapter 28</a>
<ul>
<li class="chapter" data-level="A.7.1" data-path="appendexA.html"><a href="appendexA.html#exercise-28.1"><i class="fa fa-check"></i><b>A.7.1</b> Exercise 28.1</a></li>
<li class="chapter" data-level="A.7.2" data-path="appendexA.html"><a href="appendexA.html#exercise-28.2"><i class="fa fa-check"></i><b>A.7.2</b> Exercise 28.2</a></li>
<li class="chapter" data-level="A.7.3" data-path="appendexA.html"><a href="appendexA.html#exercise-28.3"><i class="fa fa-check"></i><b>A.7.3</b> Exercise 28.3</a></li>
<li class="chapter" data-level="A.7.4" data-path="appendexA.html"><a href="appendexA.html#exercise-28.4"><i class="fa fa-check"></i><b>A.7.4</b> Exercise 28.4</a></li>
</ul></li>
<li class="chapter" data-level="A.8" data-path="appendexA.html"><a href="appendexA.html#chapter-31"><i class="fa fa-check"></i><b>A.8</b> Chapter 31</a>
<ul>
<li class="chapter" data-level="A.8.1" data-path="appendexA.html"><a href="appendexA.html#exercise-31.1"><i class="fa fa-check"></i><b>A.8.1</b> Exercise 31.1</a></li>
<li class="chapter" data-level="A.8.2" data-path="appendexA.html"><a href="appendexA.html#exercise-31.2"><i class="fa fa-check"></i><b>A.8.2</b> Exercise 31.2</a></li>
<li class="chapter" data-level="A.8.3" data-path="appendexA.html"><a href="appendexA.html#exercise-31.3"><i class="fa fa-check"></i><b>A.8.3</b> Exercise 31.3</a></li>
</ul></li>
<li class="chapter" data-level="A.9" data-path="appendexA.html"><a href="appendexA.html#exercise-31.4"><i class="fa fa-check"></i><b>A.9</b> Exercise 31.4</a>
<ul>
<li class="chapter" data-level="A.9.1" data-path="appendexA.html"><a href="appendexA.html#exercise-31.5"><i class="fa fa-check"></i><b>A.9.1</b> Exercise 31.5</a></li>
</ul></li>
<li class="chapter" data-level="A.10" data-path="appendexA.html"><a href="appendexA.html#chapter-34"><i class="fa fa-check"></i><b>A.10</b> Chapter 34</a>
<ul>
<li class="chapter" data-level="A.10.1" data-path="appendexA.html"><a href="appendexA.html#exercise-34.1"><i class="fa fa-check"></i><b>A.10.1</b> Exercise 34.1</a></li>
<li class="chapter" data-level="A.10.2" data-path="appendexA.html"><a href="appendexA.html#exercise-34.2"><i class="fa fa-check"></i><b>A.10.2</b> Exercise 34.2</a></li>
<li class="chapter" data-level="A.10.3" data-path="appendexA.html"><a href="appendexA.html#exercise-34.3"><i class="fa fa-check"></i><b>A.10.3</b> Exercise 34.3</a></li>
<li class="chapter" data-level="A.10.4" data-path="appendexA.html"><a href="appendexA.html#exercise-34.4"><i class="fa fa-check"></i><b>A.10.4</b> Exercise 34.4</a></li>
<li class="chapter" data-level="A.10.5" data-path="appendexA.html"><a href="appendexA.html#exercise-33.5"><i class="fa fa-check"></i><b>A.10.5</b> Exercise 33.5</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="B" data-path="uncertainty_derivation.html"><a href="uncertainty_derivation.html"><i class="fa fa-check"></i><b>B</b> Uncertainty derivation</a></li>
<li class="chapter" data-level="" data-path="references.html"><a href="references.html"><i class="fa fa-check"></i>References</a></li>
<li class="divider"></li>
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Fundamental statistical concepts and techniques in the biological and environmental sciences: With jamovi</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal" id="section-">
<div id="Chapter_39" class="section level1 hasAnchor" number="39">
<h1><span class="header-section-number">Chapter 39</span> <em>Practical</em>. Statistical techniques in R<a href="Chapter_39.html#Chapter_39" class="anchor-section" aria-label="Anchor link to header"></a></h1>
<p>This chapter will demonstrate how to run statistical tests in R that have been introduced in jamovi in previous practicals.
The practical will use data of fig wasp wing loadings<a href="#fn90" class="footnote-ref" id="fnref90"><sup>90</sup></a>.</p>
<p><a href="https://allisonhorst.github.io/palmerpenguins/articles/intro.html#package-citation-1">PalmerPenguins</a> dataset <span class="citation">(<a href="#ref-GormanEtAl2014" role="doc-biblioref">Gorman, Williams, and Fraser 2014</a>; <a href="#ref-HorstEtAl2020" role="doc-biblioref">Horst, Hill, and Gorman 2020</a>)</span>.
These data include morphological measurements for 3 species of penguins that inhabit 3 islands in the Palmer Archipelago, Antarctica (Figure 37.1; artwork by <a href="https://allisonhorst.com/">allison_horst</a>, Creative Commons Attribution 4.0 International License).</p>
<div class="figure"><span style="display:block;" id="fig:unnamed-chunk-218"></span>
<img src="img/penguins.png" alt="Cartoon image of three penguins standing in a row, each highlighted by a background of a different colour." width="100%" />
<p class="caption">
Figure 39.1: This practical uses data collected on the morphologies of 3 Antarctic penguin species.
</p>
</div>
<p>The data were collected by Dr Kristen Gorman at the <a href="https://pal.lternet.edu/">Palmer Station</a> Long Term Ecological Research program from 2007-2009.
To complete this lab, download the <a href="https://raw.githubusercontent.com/bradduthie/SCIU4T4/main/data/penguins.csv">penguins.csv</a> dataset (right click and “Save Link As…”, then save it with the extension ‘.csv’).
Data include measurements of bill length (mm), bill depth (mm), flipper length (mm), body mass (g), and sampling year for penguins of 3 species on 3 islands.</p>
<div id="working-with-a-data-set" class="section level2 hasAnchor" number="39.1">
<h2><span class="header-section-number">39.1</span> Working with a data set<a href="Chapter_39.html#working-with-a-data-set" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>First, we need to open Rstudio.
You can do this on your own computer, or within a browser on the <a href="https://posit.cloud/">posit cloud</a>.
Although it is possible to use R in a different environment than Rstudio, Rstudio will make some tasks easier.
To get started, we need to make that we are working in the same directory (i.e., folder, see <a href="Chapter_2.html#managing-data-files">Chapter 2.3</a> on managing data files) that we saved the <a href="https://raw.githubusercontent.com/bradduthie/SCIU4T4/main/data/penguins.csv">penguins.csv</a>.
We could use the <code>setwd()</code> function to do this (e.g., by typing something like <code>setwd("C:\Users\MyName\Documents")</code> in the console on a Windows computer).
But the easiest way in Rstudio is to navigate to the toolbar and select ‘Session’, then ‘Set Working Directory’ from the pulldown, and then ‘Choose Directory’ (Figure 37.2).</p>
<div class="figure"><span style="display:block;" id="fig:unnamed-chunk-219"></span>
<img src="img/Rstudio_setwd.png" alt="Rstudio menu is show with 'Session' selected from the toolbar, then 'Set Working Directory' from the pull down, which opens another pulldown with the highlighted option 'Choose Directory'." width="100%" />
<p class="caption">
Figure 39.2: Rstudio option in the toolbar for setting a working directory.
</p>
</div>
<p>A new window will open that will allow you to navigate to the location in which <a href="https://raw.githubusercontent.com/bradduthie/SCIU4T4/main/data/penguins.csv">penguins.csv</a> was saved.</p>
<p>In the practical from <a href="Chapter_36.html#Chapter_36">Chapter 36</a>, we worked entirely from the R console.
This time, we will will introduce R scripts to make organising the code a bit easier.
To do this, navigate to the Rstudio toolbar and select ‘File’, then ‘New File’ followed by ‘R Script’ (Figure 37.3).</p>
<div class="figure"><span style="display:block;" id="fig:unnamed-chunk-220"></span>
<img src="img/Rstudio_script.png" alt="Rstudio menu is show with 'File' selected from the toolbar, then 'New File' from the pull down, which opens another pulldown with the highlighted option 'R script'." width="100%" />
<p class="caption">
Figure 39.3: Rstudio option in the toolbar for creating a new R script.
</p>
</div>
<p>You should then see an empty script called ‘Untitled1’ open up above the R console.
This will be useful because it will allow us to save the R commands that we run.</p>
<blockquote>
<p>Task 1: Open a new R script by selecting ‘File > New File > R script’.</p>
</blockquote>
<p>Now we need to read in the penguins dataset.
Assuming that we are in the same working directory as the place we saved the file called ‘penguins.csv’, we can use the function <code>read.csv</code> to read in the CSV file.
Type (or copy-paste) the line below into the R script.</p>
<div class="sourceCode" id="cb159"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb159-1"><a href="Chapter_39.html#cb159-1" aria-hidden="true" tabindex="-1"></a>penguins <span class="ot"><-</span> <span class="fu">read.csv</span>(<span class="at">file =</span> <span class="st">"penguins.csv"</span>);</span></code></pre></div>
<p>Put your cursor on the line that you typed (you can also highlight the whole line, but this is not necessary).
Next, find the ‘Run’ button in the toolbar and click it (Figure 37.4).
Rstudio will run whatever line of code your cursor is on, or whatever chunk of code is highlighted (including multiple lines at once; notice the line numbers in the left margin of the script).</p>
<div class="figure"><span style="display:block;" id="fig:unnamed-chunk-223"></span>
<img src="img/Rstudio_run.png" alt="Rstudio toolbar is shown with multiple options, including one that says 'Run' in the upper right." width="100%" />
<p class="caption">
Figure 39.4: An Rstudio toolbar with the ‘Run’ option in the upper right to run a line of code from the script to the console.
</p>
</div>
<p>If that did not work, then double-check to make sure that you are in the correct directory and have the file name correct.
Everything in R is case sensitive, meaning that capitalisation matters, so R will treat ‘Penguins.csv’ and ‘penguins.csv’ as completely different!
It is important to be precise.</p>
<p>Once you have read in the penguins dataset, have a look at the first 6 rows using the function <code>head</code>.</p>
<blockquote>
<p>Task 2: View the first 6 rows of the penguins dataset.</p>
</blockquote>
<p>On the second line of your R script, type the code below, then run it.</p>
<div class="sourceCode" id="cb160"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb160-1"><a href="Chapter_39.html#cb160-1" aria-hidden="true" tabindex="-1"></a><span class="fu">head</span>(penguins);</span></code></pre></div>
<pre><code> species island bill_length bill_depth flipper_length mass year
1 Adelie Torgersen 39.1 18.7 181 3750 Y2007
2 Adelie Torgersen 39.5 17.4 186 3800 Y2007
3 Adelie Torgersen 40.3 18.0 195 3250 Y2007
4 Adelie Torgersen NA NA NA NA Y2007
5 Adelie Torgersen 36.7 19.3 193 3450 Y2007
6 Adelie Torgersen 39.3 20.6 190 3650 Y2007</code></pre>
<p>You should see the first 6 rows of the dataset print out in the console.
Notice that the dataset is already in a tidy format.
Each row is an individual penguin, and each variable is a column.</p>
<p>Unlike jamovi, we cannot change the data in penguins simply by clicking on values.
Like everything else in R, we need to do this using code.
If we wanted to change the value of row one column three to 40, for example (i.e., the first penguin’s bill depth), then we would need to do the following.</p>
<div class="sourceCode" id="cb162"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb162-1"><a href="Chapter_39.html#cb162-1" aria-hidden="true" tabindex="-1"></a>penguins[<span class="dv">1</span>, <span class="dv">3</span>] <span class="ot"><-</span> <span class="dv">40</span></span></code></pre></div>
<p>The square brackets can be used to indicate a specific row and column in the data (i.e., data[row_number, column_number]).
A missing value in the square brackets will be interpreted by R as referring to all elements in the dataset.
For example, if we wanted to have R just print off the fifth row of the penguins dataset, we could run the following.</p>
<div class="sourceCode" id="cb163"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb163-1"><a href="Chapter_39.html#cb163-1" aria-hidden="true" tabindex="-1"></a>penguins[<span class="dv">5</span>, ]</span></code></pre></div>
<p>The absence of any value above in <code>, ]</code> tells R to print all of the columns. We can do the same for the columns.</p>
<blockquote>
<p>Task 3: Print just column 3 of the penguins dataset. What does the code look like?</p>
</blockquote>
<p>Code to return column 3: ______________</p>
<p>Notice that some of the values in the dataset are not numeric, but instead are given as <code>NA</code>.
This is how missing data are indicated in R.
An example of this is shown in the measurements for the penguin in the fourth row.
These <code>NA</code> values can become a nuisance when we try to calculate summary statistics.
Using the <code>mean</code> function introduced in the practical last week, try running the line of code below to get the mean of column 3.</p>
<div class="sourceCode" id="cb164"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb164-1"><a href="Chapter_39.html#cb164-1" aria-hidden="true" tabindex="-1"></a><span class="fu">mean</span>(<span class="at">x =</span> penguins[,<span class="dv">3</span>])</span></code></pre></div>
<p>We get a value of <code>NA</code> instead of the mean of the numbers that are not missing.
This is because we need to tell R explicitly to remove values that are missing when calculating the mean.
We can do this with the <code>na.rm</code> argument in the mean function.</p>
<div class="sourceCode" id="cb165"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb165-1"><a href="Chapter_39.html#cb165-1" aria-hidden="true" tabindex="-1"></a><span class="fu">mean</span>(<span class="at">x =</span> penguins[,<span class="dv">3</span>], <span class="at">na.rm =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
<p>Note that we can also access column three by using the <code>$</code> sign and the name of the relevant column (in this case <code>bill_length</code>).
We could therefore get the same answer as above using the code below.</p>
<div class="sourceCode" id="cb166"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb166-1"><a href="Chapter_39.html#cb166-1" aria-hidden="true" tabindex="-1"></a><span class="fu">mean</span>(<span class="at">x =</span> penguins<span class="sc">$</span>bill_length, <span class="at">na.rm =</span> <span class="cn">TRUE</span>)</span></code></pre></div>
<p>There is usually more than one way of doing the same thing in R (we could also use <code>penguins[["bill_length"]]</code>).</p>
<blockquote>
<p>Task 4: Find the mean bill length of penguins in mm (column 3)</p>
</blockquote>
<p>Mean bill length (mm): ____________________</p>
<p>Now we can try 2 more functions.
The function <code>sd</code> returns the standard deviation of numbers (note that while <code>na.rm</code> is not an argument for every R function, it can also be used as an argument in <code>sd</code>).
The function <code>length</code> returns the length of an object.
Try using these functions to calculate the 95 per cent confidence intervals for mean bill length (you can use a z-score of 1.96).</p>
<blockquote>
<p>Task 5: Calculate lower and upper confidence intervals (CIs) using the R functions <code>mean</code>, <code>sd</code>, and <code>length</code>.</p>
</blockquote>
<p>Lower bill length CI: ______________________</p>
<p>Upper bill length CI: ______________________</p>
<p>Next, we can use the penguins dataset to run a one-way ANOVA, two-way ANOVA, <span class="math inline">\(\chi^{2}\)</span> tests, correlation test, and linear regression.
This practical will walk you through the code so that you can focus on understanding the R output.</p>
</div>
<div id="familiar-statistical-tests-in-r" class="section level2 hasAnchor" number="39.2">
<h2><span class="header-section-number">39.2</span> Familiar statistical tests in R<a href="Chapter_39.html#familiar-statistical-tests-in-r" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>In this exercise, we will use the penguins dataset to run some familiar statistical hypothesis tests.
In R, there is typically more than one way to do something.
We will focus on the simplest way to run a one-way ANOVA, two-way ANOVA, <span class="math inline">\(\chi^{2}\)</span> tests, correlation test, and linear regression.</p>
<div id="one-way-anova-in-r" class="section level3 hasAnchor" number="39.2.1">
<h3><span class="header-section-number">39.2.1</span> One-way ANOVA in R<a href="Chapter_39.html#one-way-anova-in-r" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>We can start by running a one-way ANOVA to test the null hypothesis that all species have the same mean bill length.
Normally we would want to first check the assumptions of the ANOVA.
For now, we will assume that no assumptions are violated, but the Shapiro-Wilk test and Levene’s test of equal variances will be demonstrated later.
To run a one-way ANOVA in R, we can use the code below.</p>
<div class="sourceCode" id="cb167"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb167-1"><a href="Chapter_39.html#cb167-1" aria-hidden="true" tabindex="-1"></a>anova_model <span class="ot"><-</span> <span class="fu">lm</span>(<span class="at">formula =</span> bill_length <span class="sc">~</span> species, <span class="at">data =</span> penguins);</span>
<span id="cb167-2"><a href="Chapter_39.html#cb167-2" aria-hidden="true" tabindex="-1"></a><span class="fu">anova</span>(anova_model);</span></code></pre></div>
<p>The function <code>lm</code> runs a general linear model (we have not discussed it in this module, but t-tests, ANOVA, and linear regression are all based on <a href="https://stirlingcodingclub.github.io/linear_modelling/">the same mathematical framework</a>; see <a href="#Chapter_40">Chapter 40</a> for more explanation).
We can use the column names <code>bill_length</code> and <code>species</code> directly if we specify that we are using the dataset in which these columns are found (<code>penguins</code>).
Inside <code>lm</code>, you will notice the <code>~</code> symbol. This just separates our dependent variable (<code>bill_length</code> on the left) and independent variable (<code>species</code> on the right).</p>
<p>In the above, we are storing this model with a new variable named <code>anova_model</code> (note that we can use <code><-</code> to store more than just lists of numbers; in this case, our object is the whole linear model!).
The function <code>anova</code> then summarises this model.</p>
<blockquote>
<p>Task 6: Use the code above to run an ANOVA to test the null hypothesis that species have the same bill length. Find the F value and p value from the output.</p>
</blockquote>
<p>Note that R uses scientific notation to write very low values. For example <code>5.5e-4</code> would be interpreted as <span class="math inline">\(5.5 \times 10^{-4}\)</span>, which is 0.00055.</p>
<p>F value: _________________</p>
<p>p value: _________________</p>
<p>Since our p-value is less than 0.05, we can also run a Tukey’s Honestly Significant Difference test of multiple comparisons (see <a href="Chapter_25.html#Chapter_25">Chapter 25</a>).
We need to use the <code>aov</code> and <code>TukeyHSD</code> functions to do it.</p>
<div class="sourceCode" id="cb168"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb168-1"><a href="Chapter_39.html#cb168-1" aria-hidden="true" tabindex="-1"></a><span class="fu">TukeyHSD</span>(<span class="fu">aov</span>(anova_model));</span></code></pre></div>
<p>The <code>TukeyHSD</code> function will report a table of post hoc comparisons similar to the ones reported by jamovi.</p>
</div>
<div id="two-way-anova-in-r" class="section level3 hasAnchor" number="39.2.2">
<h3><span class="header-section-number">39.2.2</span> Two-way ANOVA in R<a href="Chapter_39.html#two-way-anova-in-r" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>We can run a two-way ANOVA using the independent variables ‘species’ and ‘year’ with the code below.</p>
<div class="sourceCode" id="cb169"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb169-1"><a href="Chapter_39.html#cb169-1" aria-hidden="true" tabindex="-1"></a>two_way_aov <span class="ot"><-</span> <span class="fu">lm</span>(<span class="at">formula =</span> bill_length <span class="sc">~</span> species <span class="sc">+</span> year <span class="sc">+</span> species<span class="sc">:</span>year, </span>
<span id="cb169-2"><a href="Chapter_39.html#cb169-2" aria-hidden="true" tabindex="-1"></a> <span class="at">data =</span> penguins);</span>
<span id="cb169-3"><a href="Chapter_39.html#cb169-3" aria-hidden="true" tabindex="-1"></a><span class="fu">anova</span>(two_way_aov);</span></code></pre></div>
<p>Note that the code above looks very similar to our one way ANOVA.
Now we are just adding a new independent variable with the <code>+</code> sign, and adding an interaction between species and island, which is written as <code>species:year</code>.</p>
<blockquote>
<p>Task 7: Use the code above to run a two way ANOVA. Determine whether or not the the main effects of the model (species and sex) are significant, and whether the interaction terms are significant.</p>
</blockquote>
<p>Significance:</p>
<p>Species? __________</p>
<p>Sex? _____________</p>
<p>Interaction? _____________</p>
</div>
<div id="chi-square-test-in-r" class="section level3 hasAnchor" number="39.2.3">
<h3><span class="header-section-number">39.2.3</span> Chi-square test in R<a href="Chapter_39.html#chi-square-test-in-r" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>To run a <span class="math inline">\(\chi^{2}\)</span> goodness of fit test, we need to first put the data in a table form.
Suppose that we wanted to test the null hypothesis that penguins were sampled from equal frequencies across all islands.
We can use the <code>table</code> function in R to first build a contingency table of counts of penguins observed on each island.</p>
<div class="sourceCode" id="cb170"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb170-1"><a href="Chapter_39.html#cb170-1" aria-hidden="true" tabindex="-1"></a>island_table <span class="ot"><-</span> <span class="fu">table</span>(penguins<span class="sc">$</span>island);</span>
<span id="cb170-2"><a href="Chapter_39.html#cb170-2" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(island_table);</span></code></pre></div>
<pre><code>
Biscoe Dream Torgersen
168 124 52 </code></pre>
<p>The contingency table generated using the <code>table</code> function reveals that there were 168 penguins observed on the island Biscoe, 124 penguins observed on the island Dream, and 52 penguins observed on the island Torgersen.
To run a <span class="math inline">\(\chi^{2}\)</span> goodness of fit test, we can use the <code>island_table</code> that we just created in the function <code>chisq.test</code>.</p>
<div class="sourceCode" id="cb172"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb172-1"><a href="Chapter_39.html#cb172-1" aria-hidden="true" tabindex="-1"></a><span class="fu">chisq.test</span>(island_table);</span></code></pre></div>
<p>The output of <code>chisq.test</code> will include the <span class="math inline">\(\chi^{2}\)</span> statistic (‘X-squared’), the degrees of freedom (‘df’), and the p-value.</p>
<blockquote>
<p>Task 8: Use the code above to run a Chi-square goodness of fit test. Report the test statistic below.</p>
</blockquote>
<p><span class="math inline">\(\chi^{2}\)</span> test statistic: _____________________</p>
<p>A <span class="math inline">\(\chi^{2}\)</span> test of association also requires counts to be placed in the format of a contingency table.
This can be done by including 2 variables as arguments in <code>table</code>.
We can build a contingency table of penguin counts for each island.</p>
<div class="sourceCode" id="cb173"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb173-1"><a href="Chapter_39.html#cb173-1" aria-hidden="true" tabindex="-1"></a>sp_island_table <span class="ot"><-</span> <span class="fu">table</span>(penguins<span class="sc">$</span>island, penguins<span class="sc">$</span>species);</span>
<span id="cb173-2"><a href="Chapter_39.html#cb173-2" aria-hidden="true" tabindex="-1"></a><span class="fu">print</span>(sp_island_table);</span></code></pre></div>
<pre><code>
Adelie Chinstrap Gentoo
Biscoe 44 0 124
Dream 56 68 0
Torgersen 52 0 0</code></pre>
<p>The <code>chisq.test</code> function can then be run directly with this new table <code>sp_island_table</code> as an argument to run a <span class="math inline">\(\chi^{2}\)</span> test of association.</p>
<div class="sourceCode" id="cb175"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb175-1"><a href="Chapter_39.html#cb175-1" aria-hidden="true" tabindex="-1"></a><span class="fu">chisq.test</span>(sp_island_table);</span></code></pre></div>
<blockquote>
<p>Task 9: Use the code above to run a Chi-square test of association between penguin species and island counts. Report the test statistic below.</p>
</blockquote>
<p><span class="math inline">\(\chi^{2}\)</span> test statistic: _____________________</p>
</div>
<div id="correlation-test-in-r" class="section level3 hasAnchor" number="39.2.4">
<h3><span class="header-section-number">39.2.4</span> Correlation test in R<a href="Chapter_39.html#correlation-test-in-r" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>We can now look at how to find the correlation between two variables in R, and how to test whether or not they are significant.
Suppose that we want to test whether or not bill length and flipper length are correlated in penguins.
We can do this with the <code>cor.test</code> function in R.</p>
<div class="sourceCode" id="cb176"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb176-1"><a href="Chapter_39.html#cb176-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cor.test</span>(<span class="at">x =</span> penguins<span class="sc">$</span>bill_length, <span class="at">y =</span> penguins<span class="sc">$</span>flipper_length, </span>
<span id="cb176-2"><a href="Chapter_39.html#cb176-2" aria-hidden="true" tabindex="-1"></a> <span class="at">alternative =</span> <span class="st">"two.sided"</span>, <span class="at">method =</span> <span class="st">"pearson"</span>);</span></code></pre></div>
<p>Notice that the <code>cor.test</code> function makes it possible to specify the alternative hypothesis (“two.sided”, “less”, and “greater”).
It also is possible to use a Spearman correlation coefficient (method = “spearman”) instead of a Pearson product moment correlation coefficient.</p>
<blockquote>
<p>Task 10: Run a test of the null hypothesis that the Pearson correlation coefficient between bill length and flipper length is zero. Report the correlation coefficient r below.</p>
</blockquote>
<p>r: _________________</p>
<p>Note that the output of the correlation test includes the t statistic, which is used for correlation hypothesis testing (<a href="Chapter_30.html#correlation-hypothesis-testing">Chapter 30.3</a>).
It also includes 95 per cent confidence itnervals around <span class="math inline">\(r\)</span>, degrees of freedom, and the p-value (note that <code>2.2e-16</code> just means <span class="math inline">\(2.2 \times 10^{-16}\)</span>, i.e., a very small number).</p>
</div>
<div id="simple-linear-regression-in-r" class="section level3 hasAnchor" number="39.2.5">
<h3><span class="header-section-number">39.2.5</span> Simple linear regression in R<a href="Chapter_39.html#simple-linear-regression-in-r" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Suppose we want to try to predict penguin body mass from bill length.
How would we run a simple linear regression for this in R?
The code is actually very similar to what we used for running an ANOVA.
We can again use the function <code>lm</code>.
For simplicity, and because the goal here is just to show how to use the R functions, we will just assume that all of the relevant assumptions of regression are true.
In this case, our linear model can be run using the code below.</p>
<div class="sourceCode" id="cb177"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb177-1"><a href="Chapter_39.html#cb177-1" aria-hidden="true" tabindex="-1"></a>lin_mod <span class="ot"><-</span> <span class="fu">lm</span>(<span class="at">formula =</span> mass <span class="sc">~</span> bill_length, <span class="at">data =</span> penguins);</span>
<span id="cb177-2"><a href="Chapter_39.html#cb177-2" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(lin_mod);</span></code></pre></div>
<p>In the above code, the first line defines the model (<code>lin_mod</code>), and the second line summarises it for us with the output we need to make conclusions.
Notice that the first line has the exact same structure as we used in the ANOVA.
In the formula, the dependent variable <code>mass</code> is separated from the independent variable <code>bill_length</code> with the <code>~</code> character, and we specify the dataset for both variables (<code>penguins</code>).</p>
<blockquote>
<p>Task 11: Examine the output of the simple regression of penguin body mass against bill depth from the code above. Find the R-squared value (called ‘Multiple R-squared’), intercept, slope, and p-value for the overall model.</p>
</blockquote>
<p>R-squared: _______________</p>
<p>Intercept: _______________</p>
<p>Slope: ___________________</p>
<p>Model p-value: ___________</p>
<p>Note that the p-value for the model is in the very bottom right of the output.</p>
</div>
<div id="multiple-regression-in-r" class="section level3 hasAnchor" number="39.2.6">
<h3><span class="header-section-number">39.2.6</span> Multiple regression in R<a href="Chapter_39.html#multiple-regression-in-r" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>Now we can add to the complexity of our model by including another independent variable.
Suppose we want to predict body mass from both bill length and flipper length.
Again, assume that all of the assumptions of regression are met; the goal is just to show the R functions at work.
For multiple regression, the code again looks suspiciously similar to what it does for a two-way ANOVA (note, we should really also consider an interaction between our independent variables in multiple regression too, but for now we will just assume that none exists).</p>
<div class="sourceCode" id="cb178"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb178-1"><a href="Chapter_39.html#cb178-1" aria-hidden="true" tabindex="-1"></a>mult_regr <span class="ot"><-</span> <span class="fu">lm</span>(<span class="at">formula =</span> mass <span class="sc">~</span> bill_length <span class="sc">+</span> bill_depth, </span>
<span id="cb178-2"><a href="Chapter_39.html#cb178-2" aria-hidden="true" tabindex="-1"></a> <span class="at">data =</span> penguins);</span>
<span id="cb178-3"><a href="Chapter_39.html#cb178-3" aria-hidden="true" tabindex="-1"></a><span class="fu">summary</span>(mult_regr);</span></code></pre></div>
<p>The output above looks similar to that of our simple linear model, but we now have a coefficient and p-value for an additional independent variable (bill depth).</p>
<blockquote>
<p>Task 12: Examine the output of the multiple regression from the code above. Find the adjusted R-squared value, and write down the equation of the model.</p>
</blockquote>
<p>Adjusted R-squared: ________________</p>
<p>Model equation: ____________________</p>
<p>We have now looked at how to run ANOVAs, Chi-square tests, correlation tests, and regression in R.
These tests rely on assumptions about the data.
If these assumptions are violated, then we need to run a nonparametric alternative test.
The next section will demonstrate how to test whether or not data are normally distributed and if groups have equal variances.</p>
</div>
</div>
<div id="statistical-test-assumptions-in-r" class="section level2 hasAnchor" number="39.3">
<h2><span class="header-section-number">39.3</span> Statistical test assumptions in R<a href="Chapter_39.html#statistical-test-assumptions-in-r" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>In the one-way ANOVA of <a href="Chapter_39.html#one-way-anova-in-r">Chapter 39.2.1</a>, we tested if bill length differed among penguin species.
An assumption of the ANOVA is that the data are normally distributed and groups have equal variances.
We can run a Shapiro-Wilk test to check if data are normally distributed using the <code>shapiro.test</code> function in R.</p>
<div class="sourceCode" id="cb179"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb179-1"><a href="Chapter_39.html#cb179-1" aria-hidden="true" tabindex="-1"></a><span class="fu">shapiro.test</span>(<span class="at">x =</span> penguins<span class="sc">$</span>bill_length);</span></code></pre></div>
<blockquote>
<p>Task 13: Test if penguin bill length is normally distributed.</p>
</blockquote>
<p>Based on this test, is bill length normally distributed? __________</p>
<p>We can also check to see if species bill lengths have equal variances.
We can do this using a Levene’s test of homogeneity of variances, as we have done in jamovi.
The base functions of the R programming language do not include a Levene’s test.
We therefore need to download an R package that has a function for the Levene’s test.
Packages in R include code that people have written and made available to other researchers.
The <a href="https://cran.r-project.org/">Comprehensive R Archive Network</a> (CRAN) includes thousands of R packages that can be used to run all kinds of different functions.
The package that we need is called ‘car’, and we can download it from CRAN using the <code>install.packages</code> function.</p>
<div class="sourceCode" id="cb180"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb180-1"><a href="Chapter_39.html#cb180-1" aria-hidden="true" tabindex="-1"></a><span class="fu">install.packages</span>(<span class="st">"car"</span>);</span>
<span id="cb180-2"><a href="Chapter_39.html#cb180-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(<span class="st">"car"</span>);</span></code></pre></div>
<p>The <code>install.packages("car")</code> installs the ‘car’ package, and the <code>library("car")</code> loads it into R so that the functions in the package can be used.
One of these functions is called <code>leveneTest</code>, which we can use to run the Levene’s test of homogeneity of variances.</p>
<div class="sourceCode" id="cb181"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb181-1"><a href="Chapter_39.html#cb181-1" aria-hidden="true" tabindex="-1"></a><span class="fu">leveneTest</span>(bill_length <span class="sc">~</span> species, <span class="at">data =</span> penguins);</span></code></pre></div>
<blockquote>
<p>Task 14: Use the ‘car’ R package to run a Levene’s test, then report the p-value of the test below.</p>
</blockquote>
<p>P: __________________</p>
<p>Remember that the Levene’s test tests the null hypothesis that group variances are the same.
Hence, if <span class="math inline">\(P > 0.05\)</span>, we should not reject the null hypothesis of equal variances.
Nevertheless, from the earlier Shapiro-Wilk test, it appears that the data are not normally distributed.
Instead of using a one-way ANOVA, we should therefore try the non-parameteric equivalent Kruskall-Wallis H test (<a href="Chapter_26.html#Chapter_26">Chapter 26</a>).
The Kruskall-Wallis H test can be run in R using the <code>kruskal.test</code> function.</p>
<div class="sourceCode" id="cb182"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb182-1"><a href="Chapter_39.html#cb182-1" aria-hidden="true" tabindex="-1"></a><span class="fu">kruskal.test</span>(bill_length <span class="sc">~</span> species, <span class="at">data =</span> penguins);</span></code></pre></div>
<p>Recall from <a href="Chapter_26.html#Chapter_26">Chapter 26</a> that the Kruskall-Wallis H test uses a <span class="math inline">\(\chi^{2}\)</span> test statistic.</p>
<blockquote>
<p>Task 15: Run a Kruskall Wallis H test to see if bill length differs among species, then report the <span class="math inline">\(\chi^{2}\)</span> test statistic of the test below.</p>
</blockquote>
<p><span class="math inline">\(\chi^{2}\)</span>: ___________________</p>
<p>There is much, much more that we could do in R.
But once you understand the general idea of how R works, the best thing to do is play around with R code.
If you want to run a specific statistical test, then it is almost certain that the test can be run in R.
You might just need to search for the relevant function or R package online.</p>
</div>
</div>
<h3>References<a href="references.html#references" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<div id="refs" class="references csl-bib-body hanging-indent">
<div id="ref-GormanEtAl2014" class="csl-entry">
Gorman, Kristen B, Tony D Williams, and William R Fraser. 2014. <span>“Ecological Sexual Dimorphism and Environmental Variability Within a Community of Antarctic Penguins (Genus Pygoscelis).”</span> <em>PloS One</em> 9 (3): e90081.
</div>
<div id="ref-HorstEtAl2020" class="csl-entry">
Horst, Allison Marie, Alison Presmanes Hill, and Kristen B Gorman. 2020. <em>Palmerpenguins: Palmer Archipelago (Antarctica) Penguin Data</em>. <a href="https://doi.org/10.5281/zenodo.3960218">https://doi.org/10.5281/zenodo.3960218</a>.
</div>
</div>
<div class="footnotes">
<hr />
<ol start="90">
<li id="fn90"><p><a href="https://bradduthie.github.io/stats/data/wing_loadings.csv">https://bradduthie.github.io/stats/data/wing_loadings.csv</a><a href="Chapter_39.html#fnref90" class="footnote-back">↩︎</a></p></li>
</ol>
</div>
</section>
</div>
</div>
</div>
<a href="Chapter_38.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="appendexA.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
</div>
</div>
<script src="libs/gitbook-2.6.7/js/app.min.js"></script>
<script src="libs/gitbook-2.6.7/js/clipboard.min.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-clipboard.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": false,
"facebook": true,
"twitter": true,
"linkedin": false,
"weibo": false,
"instapaper": false,
"vk": false,
"whatsapp": false,
"all": ["facebook", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": "https://github.com/rstudio/bookdown-demo/edit/master/11-Statistical_Reporting.Rmd",
"text": "Edit"
},
"history": {
"link": null,
"text": null
},
"view": {
"link": null,
"text": null
},
"download": null,
"search": {
"engine": "fuse",
"options": null
},
"toc": {
"collapse": "subsection"
}
});
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
var src = "true";
if (src === "" || src === "true") src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/latest.js?config=TeX-MML-AM_CHTML";
if (location.protocol !== "file:")
if (/^https?:/.test(src))
src = src.replace(/^https?:/, '');
script.src = src;
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>