-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathR4PDE.net.tex
13184 lines (10824 loc) · 625 KB
/
R4PDE.net.tex
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
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
letterpaper,
]{book}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
% xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\usepackage[paperwidth=8.00in,paperheight=10.00in,left=1.25in,textwidth=
5.25in,top=1.00in,textheight=8.25in]{geometry}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{5}
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{241,243,245}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.40,0.45,0.13}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\BuiltInTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\ExtensionTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.28,0.35,0.67}{#1}}
\newcommand{\ImportTok}[1]{\textcolor[rgb]{0.00,0.46,0.62}{#1}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\NormalTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.07,0.07,0.07}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslentryspacingunit} % times entry-spacing
\setlength{\cslentryspacingunit}{\parskip}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
{% don't indent paragraphs
\setlength{\parindent}{0pt}
% turn on hanging indent if param 1 is 1
\ifodd #1
\let\oldpar\par
\def\par{\hangindent=\cslhangindent\oldpar}
\fi
% set entry spacing
\setlength{\parskip}{#2\cslentryspacingunit}
}%
{}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage[normalem]{ulem}
\usepackage{makecell}
\usepackage{xcolor}
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[skins,breakable]{tcolorbox}}
\@ifpackageloaded{fontawesome5}{}{\usepackage{fontawesome5}}
\definecolor{quarto-callout-color}{HTML}{909090}
\definecolor{quarto-callout-note-color}{HTML}{0758E5}
\definecolor{quarto-callout-important-color}{HTML}{CC1914}
\definecolor{quarto-callout-warning-color}{HTML}{EB9113}
\definecolor{quarto-callout-tip-color}{HTML}{00A047}
\definecolor{quarto-callout-caution-color}{HTML}{FC5300}
\definecolor{quarto-callout-color-frame}{HTML}{acacac}
\definecolor{quarto-callout-note-color-frame}{HTML}{4582ec}
\definecolor{quarto-callout-important-color-frame}{HTML}{d9534f}
\definecolor{quarto-callout-warning-color-frame}{HTML}{f0ad4e}
\definecolor{quarto-callout-tip-color-frame}{HTML}{02b875}
\definecolor{quarto-callout-caution-color-frame}{HTML}{fd7e14}
\makeatother
\makeatletter
\makeatother
\makeatletter
\@ifpackageloaded{bookmark}{}{\usepackage{bookmark}}
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\AtBeginDocument{%
\ifdefined\contentsname
\renewcommand*\contentsname{Table of contents}
\else
\newcommand\contentsname{Table of contents}
\fi
\ifdefined\listfigurename
\renewcommand*\listfigurename{List of Figures}
\else
\newcommand\listfigurename{List of Figures}
\fi
\ifdefined\listtablename
\renewcommand*\listtablename{List of Tables}
\else
\newcommand\listtablename{List of Tables}
\fi
\ifdefined\figurename
\renewcommand*\figurename{Figure}
\else
\newcommand\figurename{Figure}
\fi
\ifdefined\tablename
\renewcommand*\tablename{Table}
\else
\newcommand\tablename{Table}
\fi
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\@ifpackageloaded{subcaption}{}{\usepackage{subcaption}}
\makeatother
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[skins,breakable]{tcolorbox}}
\makeatother
\makeatletter
\@ifundefined{shadecolor}{\definecolor{shadecolor}{rgb}{.97, .97, .97}}
\makeatother
\makeatletter
\makeatother
\makeatletter
\makeatother
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
pdftitle={R4PDE.net},
pdfauthor={Emerson M. Del Ponte},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\title{R4PDE.net}
\usepackage{etoolbox}
\makeatletter
\providecommand{\subtitle}[1]{% add subtitle to \maketitle
\apptocmd{\@title}{\par {\large #1 \par}}{}{}
}
\makeatother
\subtitle{R for Plant Disease Epidemiology}
\author{Emerson M. Del Ponte}
\date{October 23, 2023}
\begin{document}
\frontmatter
\maketitle
\ifdefined\Shaded\renewenvironment{Shaded}{\begin{tcolorbox}[enhanced, boxrule=0pt, borderline west={3pt}{0pt}{shadecolor}, breakable, interior hidden, sharp corners, frame hidden]}{\end{tcolorbox}}\fi
\renewcommand*\contentsname{Table of contents}
{
\setcounter{tocdepth}{2}
\tableofcontents
}
\mainmatter
\bookmarksetup{startatroot}
\hypertarget{welcome}{%
\chapter*{Welcome}\label{welcome}}
\addcontentsline{toc}{chapter}{Welcome}
\markboth{Welcome}{Welcome}
\textbf{R for Plant Disease Epidemiology} (R4PDE) is a dynamic online
book rooted in the teachings of the annual graduate course, FIP 602 -
Plant Disease Epidemiology, a key part of the curriculum in the
\href{http://www.dfp.ufv.br/grad/}{Graduate Program in Plant Pathology}
at Universidade Federal de Viçosa.
Designed for those passionate about studying and modeling plant disease
epidemics with \href{https://www.r-project.org/}{R}, the book offers an
exploration of diverse methods for describing, visualizing, and
analyzing epidemic data collected over time and space. Readers should
ideally have a foundational knowledge of R to best utilize the examples.
However, R4PDE is not a resource for learning data science through R, as
there are already well-established books such as
\href{https://r4ds.had.co.nz/}{R for data science} for that purpose.
This book draws on multiple sources, but in certain sections, it
utilizes data and replicates (with permission) some of the analyses
(presented in SAS codes) from
\href{https://apsjournals.apsnet.org/doi/book/10.1094/9780890545058}{\emph{The
Study of Plant Disease Epidemics}} (Madden et al. 2007d), a highly
recommended textbook for anyone wishing to delve deeply into plant
disease epidemiology.
A mix of general and specific R packages are utilized to conduct common
plant disease epidemiology data analysis, notably
\href{https://alvesks.github.io/epifitter/}{\{epifitter\}} and
\href{https://chgigot.github.io/epiphy/}{\{epiphy\}}, both designed by
plant pathologists. In conjunction with this book, a new R package
\href{https://github.com/emdelponte/r4pde}{\{r4pde\}} has been developed
and can be installed from GitHub using:
\begin{verbatim}
#install.packages("remotes")
remotes::install_github("emdelponte/r4pde")
\end{verbatim}
This online book is frequently updated and edited. It content is free to
use, licensed under a
\href{https://creativecommons.org/licenses/by-nc/4.0/}{Creative Commons
licence}, and the code for all analyses can be found on
\href{https://github.com/emdelponte/epidemiology-R}{GitHub}.
Contributions are subject to a
\href{https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html}{Contributor
Code of Conduct}, and by contributing, you agree to adhere to its terms.
\href{https://r4pde.net/}{R for Plant Disease Epidemiology~}©
2023~by~\href{http://emersondelponte.netlify.app/}{Emerson Medeiros Del
Ponte} is licensed under CC BY-NC 4.0
\bookmarksetup{startatroot}
\hypertarget{how-to-cite}{%
\chapter*{How to cite}\label{how-to-cite}}
\addcontentsline{toc}{chapter}{How to cite}
\markboth{How to cite}{How to cite}
The author has opted for self-publishing this book to ensure its
accessibility and updatability, reflecting the dynamic nature of the
field and the R programming environment. Readers are encouraged to cite
this work when referencing or utilizing the methodologies and insights
provided in the book. Ensure the accuracy of the details while citing,
especially the URL, to direct readers to the correct online source.
Below one suggestion of citation style:
\begin{quote}
Del Ponte, E. M. (2023). \emph{R for Plant Disease Epidemiology
(R4PDE)}. Author. \href{https://r4pde.net/}{https://r4pde.net}
\end{quote}
Cataloguing-in-Publication data prepared by the library of the Federal
University of Viçosa, Brazil.
\includegraphics[width=5.78125in,height=\textheight]{imgs/ficha_cip.png}
\bookmarksetup{startatroot}
\hypertarget{about-the-author}{%
\chapter*{About the author}\label{about-the-author}}
\addcontentsline{toc}{chapter}{About the author}
\markboth{About the author}{About the author}
\href{https://emersondelponte.netlify.app/}{Emerson M. Del Ponte} is a
Professor at the
\href{http://www.dfp.ufv.br/graduate/faculty/}{Departamento de
Fitopatologia}, Universidade Federal de Viçosa in Brazil. His academic
journey includes a DSc in Plant Pathology, obtained from Universidade
Federal de Pelotas in 2004, and a year-long visit to Cornell University
in the Bergstrom Lab. Following this, he spent nearly two years as a
postdoctoral associate working on a project related to disease risk
assessment and prediction at the Yang Lab, Iowa State University. This
experience led him to the Universidade Federal do Rio Grande do Sul,
Brazil, where he joined as an assistant professor of plant pathology.
Emerson Del Ponte is a fervent advocate for an open and reproducible
research model and culture, which he believes can lead to more
accessible, transparent, and reliable scientific knowledge. This belief
inspired him co-founding the
\href{http://www.openplantpathology.org/}{Open Plant Pathology}
initiative alongside \href{http://adamhsparks.netlify.app/}{Adam
Sparks}. In his Lab, students use the R language for all statistics and
data science-related activities. All data and computational codes
generated during the research are made accessible before the peer-review
process. The code can be located on
\href{https://github.com/emdelponte}{GitHub}.
\bookmarksetup{startatroot}
\hypertarget{acknowledgements}{%
\chapter*{Acknowledgements}\label{acknowledgements}}
\addcontentsline{toc}{chapter}{Acknowledgements}
\markboth{Acknowledgements}{Acknowledgements}
Embarking on the journey of authoring ``R for Plant Disease Epidemiology
(R4PDE)'' has been an enlightening voyage. This endeavor would not have
been possible without the unwavering support and intellectual generosity
of many individuals and institutions.
First, my heartfelt gratitude goes to Helen Pennington, who generously
granted permission to use her beautiful painting of coffee leaf rust for
the book cover. Helen's artwork encapsulates the essence of plant
disease epidemiology, providing a visual narrative that complements the
academic discourse.
I am equally indebted to Prof.~Laurence V. Madden, whose generosity in
allowing the use of data showcased in the book ``The Study of Plant
Disease Epidemics'' has enriched the analytical content of this
publication.
The collaborative spirit of the open-source community has been a
cornerstone in refining and augmenting the content of ``R for Plant
Disease Epidemiology (R4PDE)''. I am immensely thankful to those who
took the time and effort to contribute fixes and improvements. Their
engagements, whether through pull requests or other forms of contact,
have been invaluable: Adam Sparks
(\href{https://github.com/adamhsparks}{@adamhsparks}), Remco Stam
(\href{https://github.com/remco-stam}{@remco-stam}), Tiago Olivoto
(\href{https://github.com/TiagoOlivoto}{@TiagoOlivoto}), Monalisa De Cól
(\href{https://github.com/Monalisacdc}{@Monalisacdc}), and Juan Edwards
Molina (\href{https://github.com/juanchiem}{@juanchiem}).
\bookmarksetup{startatroot}
\hypertarget{introduction}{%
\chapter{Introduction}\label{introduction}}
\hypertarget{defining-plant-disease}{%
\section{Defining plant disease}\label{defining-plant-disease}}
Disease in plants can be defined as \emph{any malfunctioning of host
cells and tissues that results from continuous irritation by a
pathogenic agent or environmental factor and leads to development of
symptoms} (Agrios 2005a). When caused by pathogenic agent, the disease
results from the combination of three elements: susceptible host plant,
a virulent pathogen, and favorable environmental conditions - the famous
disease triangle. When a pathogen population establishes and causes
\emph{disease} in a host population, the phenomenon is called an
\emph{epidemic}, or the disease in populations. Among several
definitions of epidemic, a comprehensive one is the \emph{change in
disease intensity in a host population over time and space} (Madden et
al. 2007d).
There exist numerous iterations of the disease triangle, incorporating
additional elements (e.g., human intervention and time) as points and/or
dimensions to provide a more comprehensive representation of an epidemic
(Agrios 2005b). We find the disease prism particularly illustrative,
where a sequence of stacked triangles represent the evolution of a plant
disease through time (Francl 2001).
\begin{figure}
{\centering \includegraphics[width=3.92708in,height=\textheight]{imgs/prism.png}
}
\caption{\label{fig-prism}The plant disease prism as a model of plant
disease epidemics}
\end{figure}
\hypertarget{importance-of-epidemics}{%
\section{Importance of epidemics}\label{importance-of-epidemics}}
Epidemics bear significant economic importance due to their potential to
decrease crop yields, diminish product quality, and escalate control
costs, contingent on their intensity level. Numerous historical examples
of widespread epidemics, reaching pandemic levels and resulting in
catastrophic effects on crops, have been documented (Agrios 2005b). The
Irish potato famine of 1845--1847, caused by the late blight pathogen
(\emph{Phytophthora infestans}), is a famous example of a
well-documented pandemic. This disease notably altered the course of
history in Europe and the United States, and was pivotal in the
evolution of the science of plant pathology. During the 1840s, the
pathogen ravaged potato crops, which were a dietary staple for the
Irish. The disease outbreak was triggered by the introduction of a
novel, virulent pathogen population that found suitable environmental
conditions (cool and wet weather) for infection and development within a
dense population of susceptible hosts.
However, there are several reasons why devastating epidemics may
continue to unfold. Recent history has seen severe epidemics reaching
pandemic levels due to the incursion of pathogens into regions where
they had previously been absent (refer to Box 1). Alternatively, new
pathogenic strains might emerge as a result of factors driving genetic
diversity within the local pathogen population. A case in point is the
Ug99 strain of the wheat stem rust, which poses a significant threat to
global wheat production. First identified in Uganda in 1998, an asexual
lineage has propagated through Africa and the Middle East, causing
catastrophic epidemics. Research suggests that Ug99 emerged via somatic
hybridization and nuclear exchange between isolates from different
lineages (Li et al. 2019). Finally, disease emergence or re-emergence
can be influenced by shifts in climatic patterns. For instance, the
Fusarium head blight of wheat caused by the fungus \emph{Fusarium
graminearum}. In Southern Brazil, the increased frequency of severe
epidemics resulting in greater yield loss since the early 1990s has been
linked to alterations in rainfall patterns across decades (Duffeck et
al. 2020).
\begin{tcolorbox}[enhanced jigsaw, coltitle=black, colbacktitle=quarto-callout-note-color!10!white, colframe=quarto-callout-note-color-frame, title=\textcolor{quarto-callout-note-color}{\faInfo}\hspace{0.5em}{Box 1: Diseases on the move}, arc=.35mm, bottomrule=.15mm, breakable, opacitybacktitle=0.6, toptitle=1mm, titlerule=0mm, bottomtitle=1mm, rightrule=.15mm, opacityback=0, leftrule=.75mm, colback=white, toprule=.15mm, left=2mm]
In Brazil, the soybean rust pathogen (\emph{Phakopsora pachyrhizi})
first reached southern Brazil in 2002 (Yorinori et al. 2005). The
disease spread to all production regions of the country in the following
few years, severely reducing yields. To overcome the problem, farmers
have relied on massive applications of fungicides on soybeans, which
dramatically increased the production costs with the need for sequential
fungicide sprays to combat the disease. Total economic loss have been
estimated at around US\$ 2 billion yearly (Godoy et al. 2016). More
recently, wheat blast, a disease that originated in the south of Brazil
in 1984, and have been restricted to South America, was firstly spotted
in South Asia, Bangladesh, in 2016. Blast epidemics in that occasion
devastated more than 15,000 ha of wheat and reduced yield of wheat in
the affected field up to 100\% (Malaker et al. 2016; Islam et al. 2019).
The disease was later found in Zambia, thus also becoming a threat to
wheat production in Africa (Tembo et al. 2020). In Brazil, the wheat
blast disease is a current threat to expansion of wheat cultivation in
the tropics(Cruz and Valent 2017).
\end{tcolorbox}
\hypertarget{history-of-epidemiology}{%
\section{History of Epidemiology}\label{history-of-epidemiology}}
Botanical epidemiology, or the study of plant disease epidemics, is a
discipline with roots tracing back to the early 1960s. However, its
origins can be linked to events from centuries and decades prior. For
instance, in 1728, Duhamel de Monceau presented the earliest known
epidemiological work on a disease, referred to as `Death,' that
afflicted saffron crocus (\emph{Rhizoctonia violacea}). Fast forward to
1858, a textbook detailing plant diseases, written by Julius Kuhn, made
its debut, introducing the concept of an epidemic as illustrated by the
Irish late blight epidemics of 1845-46. Subsequently, in 1901, H.M. Ward
adopted an ecological perspective to the study of plant diseases in his
seminal book, Disease in Plants. By 1946, Gäumann penned the first book
exclusively devoted to plant disease epidemiology.
Further evolution of this field was marked by the publication of a
chapter titled ``Analysis of Epidemics'' by J.E. Vanderplank in Plant
Pathology, vol.~3, edited by Horsfall and Dimond, in 1960. Vanderplank
elaborated on his pioneering ideas in his 1963 book, ``Plant Diseases:
Epidemics and Control''(Vanderplank 1963). He is universally recognized
as the foundational figure of plant disease epidemiology (Zadoks and
Schein 1988; Thresh 1998), his landmark book being the first to
comprehensively describe and quantify plant disease epidemics, and
offering a theoretical framework for epidemic analysis.
In the same year, the first International Epidemiology Workshop was
convened in Pau, France. This event constitutes an important milestone
in the historical narrative, significantly contributing to the molding
of this emergent discipline.
\begin{figure}
{\centering \includegraphics[width=5.38542in,height=\textheight]{imgs/iew1.png}
}
\caption{\label{fig-iew1}Group photo of the First International
Epidemiology Workshop}
\end{figure}
The \textbf{International Epidemiology Workshop (IEW)} is the principal
working group of plant disease epidemiology. This is an organization
with a rich history whose members have met approximately every 5 years
since 1963. Thus far, \href{https://iew13.net/about.html}{13 meetings}
have been organized/planned:
1963 - Pau, France\\
1971 - Wageningen, The Netherlands\\
1979 - Penn State, United States\\
1983 - NC State, Raleigh, United States\\
1986 - Jerusalem, Israel\\
1990 - Giessen, Germany\\
1994 - Papendal, The Netherlands\\
2001 - Ouro Preto, Brazil\\
2005 - Landerneau, France\\
2009 - Cornell, Geneva, United States\\
2013 - Beijing, China\\
2018 - Lillehammer, Norway\\
2024 - Iguassu Falls, Brazil
\hypertarget{other-resources}{%
\section{Other resources}\label{other-resources}}
\hypertarget{books}{%
\subsection{Books}\label{books}}
2006 - \href{https://link.springer.com/book/10.1007/1-4020-4581-6}{The
Epidemiology of Plant Diseases}\\
2007 -
\href{https://apsjournals.apsnet.org/doi/book/10.1094/9780890545058}{The
Study of Plant Disease Epidemics}\\
2017 -
\href{https://apsjournals.apsnet.org/doi/book/10.1094/9780890544426}{Exercises
in Plant Disease Epidemiology}\\
2017 -
\href{https://apsjournals.apsnet.org/doi/book/10.1094/9780890544877}{Application
of Information Theory to Epidemiology}\\
2020 -
\href{https://apsjournals.apsnet.org/doi/book/10.1094/9780890546383}{Emerging
Plant Diseases and Global Security}\\
\hypertarget{online-tutorials}{%
\subsection{Online tutorials}\label{online-tutorials}}
\href{https://www.apsnet.org/edcenter/disimpactmngmnt/topc/EcologyAndEpidemiologyInR/Pages/default.aspx}{Ecology
and Epidemiology in R}\\
\href{https://www.apsnet.org/edcenter/disimpactmngmnt/topc/EpidemiologyTemporal/Pages/default.aspx}{Plant
Disease Epidemiology - Temporal aspects}\\
\href{https://www.apsnet.org/edcenter/disimpactmngmnt/topc/BotanicalEpidemiology/Pages/default.aspx}{Simulation
Modeling in Plant Disease Epidemiology and Crop Loss Analysis}
\hypertarget{software}{%
\subsection{Software}\label{software}}
\href{http://adamhsparks.github.io/epicrop/}{Epicrop - Simulation
Modeling of Crop Diseases using a SEIR model}
\part{Epidemic data}
\hypertarget{disease-variables}{%
\chapter{Disease variables}\label{disease-variables}}
\hypertarget{disease-quantification}{%
\section{Disease quantification}\label{disease-quantification}}
Studies on the temporal progression or spatial spread of epidemics
cannot be conducted without field-collected data, or, in some cases,
simulated data. The study of plant disease quantification, termed
Phytopathometry, is a subdivision of plant pathology concerned with the
science of disease measurement. It has strong ties to the field of
epidemiology (Bock et al. 2021b).
Traditionally, disease quantification has been executed through visual
evaluation. However, the past few decades have witnessed significant
advancements in imaging and remote sensing technologies (which don't
necessitate contact with the object), leaving a profound impact on this
field. As such, disease quantity can now be gauged through estimation
(visually, by the human eye) or measurement (through remote sensing
technologies such as RGB, MSI, and HSI)
Figure~\ref{fig-disease_measure}.
While the utilization of digital or remote sensing technology for
disease measurement or estimation provides a more objective approach,
visual assessment is largely subjective. It is known to vary among human
raters, as these raters differ in their innate abilities, training, and
how they are influenced by the chosen method (e.g., scales). Disease is
estimated or measured on a specimen within a population, or on a sample
of specimens drawn from that population. The specimen in question can be
a plant organ, an individual plant, a group of plants, a field, or a
farm. The specific specimen type also determines the terminology used to
describe disease quantity.
\begin{figure}
{\centering \includegraphics[width=5.10417in,height=\textheight]{imgs/disease_measure.png}
}
\caption{\label{fig-disease_measure}Different approaches used to obtain
estimates or measures of plant disease. RGB = red, green, blue; MSI =
multispectral imaging; HSI = hyperspectral imaging.}
\end{figure}
inally, while developing new or refining existing disease assessment
methods, it is crucial to evaluate the reliability of the assessments
made by different raters or instruments, as well as their
accuracy---specifically, how close the estimations or measurements are
to the reference (or gold standard) values. Several methods are
available for assessing the reliability, precision, and accuracy of
these estimates or measurements (see
\href{data-accuracy.html}{definitions}). The choice of methods depends
on the objective of the work, but largely on the type or nature of the
data. These considerations will be further discussed.
\hypertarget{disease-variables-1}{%
\section{Disease variables}\label{disease-variables-1}}
A common term used to reference the quantity of disease, irrespective of
how it is expressed, is `disease intensity'. This term, however, has
minimal practical value as it only implies that the disease is more or
less ``intense''. We require more specific terminology to standardize
the reference to disease quantity and methodology. One of the primary
tasks in disease assessment is classifying each specimen, often in a
sample or within a population, as diseased or not diseased. This binary
(yes/no or 1/0) evaluation may sufficiently express disease intensity if
the goal is to ascertain the number or proportion of diseased specimens
in a sample or a population.
This discussion brings us to two terms: disease incidence and
prevalence. Incidence is typically used to denote the proportion or
number (count) of plants (or their organs) deemed as observational units
at the field scale or below. On the other hand, prevalence refers to the
proportion or number of fields or farms with diseased plants within a
larger production area or region (Nutter et al. 2006)
Figure~\ref{fig-prevalence_incidence}. Therefore, prevalence is
analogous to incidence, with the only difference being the spatial scale
of the sampling unit.
\begin{figure}
{\centering \includegraphics[width=5in,height=\textheight]{imgs/prevalence_incidence.png}
}
\caption{\label{fig-prevalence_incidence}Schematic representation of how
prevalence and incidence of plant diseases are calculated depending on
the spatial scale of the assessment}
\end{figure}
In many instances, it's necessary to determine the degree to which a
specimen is diseased, a concept defined as disease severity. In certain
contexts, severity is narrowly defined as the proportion of the unit
that exhibits symptoms (Nutter et al. 2006). However, a more expansive
view of severity includes additional metrics such as nominal or ordinal
scores, lesion count, and percent area affected (ratio scale). Ordinal
scales are broken down into rank-ordered classes (see specific
\href{data-ordinal.html}{section}), defined based on either a percentage
scale or descriptions of symptoms (Bock et al. 2021b). Occasionally,
disease is expressed in terms of (average) lesion size or area, which
could be regarded as a measure of severity. These variables represent
different levels of measurements that provide varying degrees of
information about the disease quantity - from low (nominal scale) to
high (ratio scale) Figure~\ref{fig-severity}.
\begin{figure}
{\centering \includegraphics[width=5.32292in,height=\textheight]{imgs/severity.png}
}
\caption{\label{fig-severity}Scales and associated levels of measurement
used to describe severity of plant diseases}
\end{figure}
\hypertarget{data-types}{%
\section{Data types}\label{data-types}}
The data used to express disease as incidence or any form of severity
measurements can be discrete or continuous in nature.
Discrete variables are countable (involving integers) at a particular
point in time. In other words, only a finite number of values (nominal
or ordinal) is possible, and these cannot be subdivided. For instance, a
plant or plant part can be either diseased or not diseased (nominal
data). It's not possible to count 1.5 diseased plants. Furthermore, a
plant classified as diseased may exhibit a certain number of lesions
(count data), or be categorized into a specific severity class (ordinal
data, common in ordinal scales, e.g., 1-9). Disease data in the form of
counts often relates to the number of infections per sampling units.
Most commonly, these counts refer to the assessed pathogen population,
such as the number of airborne or soilborne propagules.
In contrast to discrete variables, continuous variables can be measured
on a scale and can assume any numeric value between two points. For
example, the size of a lesion on a plant can be measured at a very
precise scale (cm or mm). An estimate of severity on a percent scale (\%
diseased area) can take any value between non-zero and 100\%. Although
incidence at the individual level is discrete, at the sample level it
can be treated as continuous, as it can assume any value in proportion
or percentage.
Disease variables can also be characterized by a statistical
distribution, which are models that provide the probability of a
specific value (or a range of values) being drawn from a particular
distribution. Understanding statistical or mathematical distributions is
a crucial step in improving our grasp of data collection methods,
experiment design, and data analysis processes such as data
summarization or hypothesis testing.
\hypertarget{statistical-distributions-and-simulation}{%
\section{Statistical distributions and
simulation}\label{statistical-distributions-and-simulation}}
\hypertarget{binomial-distribution}{%
\subsection{Binomial distribution}\label{binomial-distribution}}
For incidence (and prevalence), the data is binary at the individual
level, as there are only two possible outcomes in a \emph{trial}: the
plant or plant part is disease or not diseased. The statistical
distribution that best describe the incidence data at the individual
level is the \emph{binomial distribution}.
Let's simulate the binomial outcomes for a range of probabilities in a
sample of 100 units, using the \texttt{rbinom()} function in R. For a
single trial (e.g., status of plants in a single plant row), the
\texttt{size} argument is set to 1.
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{library}\NormalTok{(tidyverse)}
\FunctionTok{library}\NormalTok{(r4pde)}
\FunctionTok{set.seed}\NormalTok{(}\DecValTok{123}\NormalTok{) }\CommentTok{\# for reproducibility}
\NormalTok{P}\FloatTok{.1} \OtherTok{\textless{}{-}} \FunctionTok{rbinom}\NormalTok{(}\DecValTok{100}\NormalTok{, }\AttributeTok{size =} \DecValTok{1}\NormalTok{, }\AttributeTok{prob =} \FloatTok{0.1}\NormalTok{)}
\NormalTok{P}\FloatTok{.3} \OtherTok{\textless{}{-}} \FunctionTok{rbinom}\NormalTok{(}\DecValTok{100}\NormalTok{, }\AttributeTok{size =} \DecValTok{1}\NormalTok{, }\AttributeTok{prob =} \FloatTok{0.3}\NormalTok{)}
\NormalTok{P}\FloatTok{.7} \OtherTok{\textless{}{-}} \FunctionTok{rbinom}\NormalTok{(}\DecValTok{100}\NormalTok{, }\AttributeTok{size =} \DecValTok{1}\NormalTok{, }\AttributeTok{prob =} \FloatTok{0.7}\NormalTok{)}
\NormalTok{P}\FloatTok{.9} \OtherTok{\textless{}{-}} \FunctionTok{rbinom}\NormalTok{(}\DecValTok{100}\NormalTok{, }\AttributeTok{size =} \DecValTok{1}\NormalTok{, }\AttributeTok{prob =} \FloatTok{0.9}\NormalTok{)}
\NormalTok{binomial\_data }\OtherTok{\textless{}{-}} \FunctionTok{data.frame}\NormalTok{(P}\FloatTok{.1}\NormalTok{, P}\FloatTok{.3}\NormalTok{, P}\FloatTok{.7}\NormalTok{, P}\FloatTok{.9}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
We can then visualize the plots.
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{binomial\_data }\SpecialCharTok{|\textgreater{}}
\FunctionTok{pivot\_longer}\NormalTok{(}\DecValTok{1}\SpecialCharTok{:}\DecValTok{4}\NormalTok{, }\AttributeTok{names\_to =} \StringTok{"P"}\NormalTok{,}
\AttributeTok{values\_to =} \StringTok{"value"}\NormalTok{) }\SpecialCharTok{|\textgreater{}}
\FunctionTok{ggplot}\NormalTok{(}\FunctionTok{aes}\NormalTok{(value)) }\SpecialCharTok{+}
\FunctionTok{geom\_histogram}\NormalTok{(}\AttributeTok{fill =} \StringTok{"\#339966"}\NormalTok{,}
\AttributeTok{bins =} \DecValTok{10}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{facet\_wrap}\NormalTok{( }\SpecialCharTok{\textasciitilde{}}\NormalTok{ P) }\SpecialCharTok{+}
\FunctionTok{theme\_r4pde}\NormalTok{()}
\end{Highlighting}
\end{Shaded}
\begin{figure}
{\centering \includegraphics{data-terminology_files/figure-latex/fig-binomial-1.pdf}
}
\caption{\label{fig-binomial}Binomial distribution to describe binary
data}
\end{figure}
\hypertarget{beta-distribution}{%
\subsection{Beta distribution}\label{beta-distribution}}
In many studies, it's often useful to express these quantities as a
proportion of the total population or sample size, rather than absolute
numbers. This helps standardize the data, making it easier to compare
between different populations or different time periods.
For example, if we're studying a plant disease, we could express disease
incidence as the proportion of plants that are newly diseased during a
given time period. Similarly, disease severity could be expressed as the
proportion of each plant's organ area that is affected by the disease.
These proportions are ratio variables, as they can take on any value
between 0 and 1, and ratios of these variables are meaningful.
The Beta distribution is a probability distribution that is defined
between 0 and 1, which makes it ideal for modeling data that represents
proportions. It's a flexible distribution, as its shape can take many
forms depending on the values of its two parameters, often denoted as
alpha and beta.
Let's simulate some data using the \texttt{rbeta()} function.
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{beta1}\FloatTok{.5} \OtherTok{\textless{}{-}} \FunctionTok{rbeta}\NormalTok{(}\AttributeTok{n =} \DecValTok{1000}\NormalTok{, }\AttributeTok{shape1 =} \DecValTok{1}\NormalTok{, }\AttributeTok{shape2 =} \DecValTok{5}\NormalTok{)}
\NormalTok{beta5}\FloatTok{.5} \OtherTok{\textless{}{-}} \FunctionTok{rbeta}\NormalTok{(}\AttributeTok{n =} \DecValTok{1000}\NormalTok{, }\AttributeTok{shape1 =} \DecValTok{5}\NormalTok{, }\AttributeTok{shape2 =} \DecValTok{5}\NormalTok{)}
\NormalTok{beta\_data }\OtherTok{\textless{}{-}} \FunctionTok{data.frame}\NormalTok{(beta1}\FloatTok{.5}\NormalTok{, beta5}\FloatTok{.5}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
Notice that there are two shape parameters in the beta distribution:
\texttt{shape1} and \texttt{shape2} to be defined. This makes the
distribution very flexible and with different potential shapes as we can
see below.
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{beta\_data }\SpecialCharTok{|\textgreater{}}
\FunctionTok{pivot\_longer}\NormalTok{(}\DecValTok{1}\SpecialCharTok{:}\DecValTok{2}\NormalTok{, }\AttributeTok{names\_to =} \StringTok{"P"}\NormalTok{,}
\AttributeTok{values\_to =} \StringTok{"value"}\NormalTok{) }\SpecialCharTok{|\textgreater{}}
\FunctionTok{ggplot}\NormalTok{(}\FunctionTok{aes}\NormalTok{(value)) }\SpecialCharTok{+}
\FunctionTok{geom\_histogram}\NormalTok{(}\AttributeTok{fill =} \StringTok{"\#339966"}\NormalTok{,}
\AttributeTok{color =} \StringTok{"white"}\NormalTok{,}
\AttributeTok{bins =} \DecValTok{15}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{scale\_x\_continuous}\NormalTok{(}\AttributeTok{limits =} \FunctionTok{c}\NormalTok{(}\DecValTok{0}\NormalTok{, }\DecValTok{1}\NormalTok{)) }\SpecialCharTok{+}
\FunctionTok{facet\_wrap}\NormalTok{( }\SpecialCharTok{\textasciitilde{}}\NormalTok{ P)}\SpecialCharTok{+}
\FunctionTok{theme\_r4pde}\NormalTok{()}
\end{Highlighting}
\end{Shaded}
\begin{figure}
{\centering \includegraphics{data-terminology_files/figure-latex/fig-betabin-1.pdf}
}
\caption{\label{fig-betabin}Binomial distribution to describe proportion
data}
\end{figure}
\hypertarget{beta-binomial-distribution}{%
\subsection{Beta-binomial
distribution}\label{beta-binomial-distribution}}
The Beta-Binomial distribution is a mixture of the Binomial distribution
with the Beta distribution acting as a prior on the probability
parameter of the binomial. Disease probabilities can vary across trials
due to a number of unobserved or unmeasured factors. This variability
can result in overdispersion, a phenomenon where the observed variance
in the data is greater than what the binomial distribution expects.
This is where the Beta-Binomial distribution comes in handy. By
combining the Beta distribution's flexibility in modeling probabilities
with the Binomial distribution's discrete event modeling, it provides an
extra layer of variability to account for overdispersion. The
Beta-Binomial distribution treats the probability of success (disease
occurrence in this context) as a random variable itself, following a
Beta distribution. This means the probability can vary from trial to
trial.
Therefore, when we observe data that shows more variance than the Beta
distribution can account for, or when we believe there are underlying
factors causing variability in the probability of disease occurrence,
the Beta-Binomial distribution is a more appropriate model. It captures
both the variability in success probability as well as the occurrence of
the discrete event (disease incidence).
When combined with the Binomial distribution, which handles discrete
events (e.g.~whether an individual is diseased or not), the
Beta-Binomial distribution allows us to make probabilistic predictions
about these events. For example, based on prior data (the Beta
distribution), we can estimate the likelihood of a particular individual
being diseased (the Binomial distribution).
In R, the \texttt{rBetaBin} function of the \emph{FlexReg} package
generates random values from the beta-binomial distribution. The
arguments of the function are \texttt{n}, or the number of values to
generate; if length(\texttt{n}) \textgreater{} 1, the length is taken to
be the number required. \texttt{size} is he total number of trials.
\texttt{mu} is the mean parameter. It must lie in (0, 1). \texttt{theta}
is the overdispersion parameter. It must lie in (0, 1). \texttt{phi} the
precision parameter. It is an alternative way to specify the theta
parameter. It must be a positive real value.
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{library}\NormalTok{(FlexReg) }
\NormalTok{betabin3}\FloatTok{.6} \OtherTok{\textless{}{-}} \FunctionTok{rBetaBin}\NormalTok{(}\AttributeTok{n =} \DecValTok{100}\NormalTok{, }\AttributeTok{size =} \DecValTok{40}\NormalTok{, }\AttributeTok{mu =}\NormalTok{ .}\DecValTok{3}\NormalTok{, }\AttributeTok{theta =}\NormalTok{ .}\DecValTok{6}\NormalTok{)}
\NormalTok{betabin7}\FloatTok{.3} \OtherTok{\textless{}{-}} \FunctionTok{rBetaBin}\NormalTok{(}\AttributeTok{n =} \DecValTok{100}\NormalTok{, }\AttributeTok{size =} \DecValTok{40}\NormalTok{, }\AttributeTok{mu =}\NormalTok{ .}\DecValTok{7}\NormalTok{, }\AttributeTok{theta =}\NormalTok{ .}\DecValTok{3}\NormalTok{)}
\NormalTok{betabin\_data }\OtherTok{\textless{}{-}} \FunctionTok{data.frame}\NormalTok{(betabin3}\FloatTok{.6}\NormalTok{, betabin7}\FloatTok{.3}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{betabin\_data }\SpecialCharTok{|\textgreater{}}
\FunctionTok{pivot\_longer}\NormalTok{(}\DecValTok{1}\SpecialCharTok{:}\DecValTok{2}\NormalTok{, }\AttributeTok{names\_to =} \StringTok{"P"}\NormalTok{,}
\AttributeTok{values\_to =} \StringTok{"value"}\NormalTok{) }\SpecialCharTok{|\textgreater{}}
\FunctionTok{ggplot}\NormalTok{(}\FunctionTok{aes}\NormalTok{(value)) }\SpecialCharTok{+}
\FunctionTok{geom\_histogram}\NormalTok{(}\AttributeTok{fill =} \StringTok{"\#339966"}\NormalTok{,}
\AttributeTok{color =} \StringTok{"white"}\NormalTok{,}
\AttributeTok{bins =} \DecValTok{15}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{facet\_wrap}\NormalTok{( }\SpecialCharTok{\textasciitilde{}}\NormalTok{ P) }\SpecialCharTok{+}
\FunctionTok{theme\_r4pde}\NormalTok{()}
\end{Highlighting}
\end{Shaded}
\begin{figure}
{\centering \includegraphics{data-terminology_files/figure-latex/fig-beta-1.pdf}
}
\caption{\label{fig-beta}Beta-binomial distribution to describe
proportion data}
\end{figure}
\hypertarget{poisson-distribution}{%
\subsection{Poisson distribution}\label{poisson-distribution}}
When conducting studies in epidemiology, specifically plant diseases,
researchers often collect data on the number of diseased plants,
infected plant parts, or individual symptoms, such as lesions. These
variables are counted in whole numbers - 1, 2, 3, etc., making them
discrete variables. Discrete variables contrast with continuous
variables that can take any value within a defined range and can include
fractions or decimals. In addition to being discrete, these variables
are also non-negative, meaning they cannot take negative values. After
all, you can't have a negative number of diseased plants or lesions.
Given these characteristics, a suitable distribution to model such data
is the Poisson distribution. This distribution is particularly suitable
for counting the number of times an event occurs in a given time or
space.
In R, we can used the \texttt{rpois()} function to obtain 100 random
observations following a Poisson distribution. For such, we need to
inform the number of observation (n = 100) and \texttt{lambda}, the
vector of means.
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{poisson5 }\OtherTok{\textless{}{-}} \FunctionTok{rpois}\NormalTok{(}\DecValTok{100}\NormalTok{, }\AttributeTok{lambda =} \DecValTok{10}\NormalTok{)}
\NormalTok{poisson35 }\OtherTok{\textless{}{-}} \FunctionTok{rpois}\NormalTok{(}\DecValTok{100}\NormalTok{, }\AttributeTok{lambda =} \DecValTok{35}\NormalTok{)}
\NormalTok{poisson\_data }\OtherTok{\textless{}{-}} \FunctionTok{data.frame}\NormalTok{(poisson5, poisson35)}
\end{Highlighting}
\end{Shaded}
\begin{Shaded}
\begin{Highlighting}[]
\NormalTok{poisson\_data }\SpecialCharTok{|\textgreater{}}
\FunctionTok{pivot\_longer}\NormalTok{(}\DecValTok{1}\SpecialCharTok{:}\DecValTok{2}\NormalTok{, }\AttributeTok{names\_to =} \StringTok{"P"}\NormalTok{,}
\AttributeTok{values\_to =} \StringTok{"value"}\NormalTok{) }\SpecialCharTok{|\textgreater{}}