# Preface

Note: This book has been published by Chapman & Hall/CRC in its R-Series. It is available for purchase from Routledge, as well as from such vendors as Amazon.

This new book, Using R for Modelling and Quantitative Methods in Fisheries, has evolved and been adapted from my earlier book Modelling and Quantitative Methods in Fisheries (Haddon, 2001, 2011). The new book aims to introduce an array of analytical methods useful when conducting fisheries stock assessments, but at the same time, many of those methodologies are more generally applicable in ecology. By concentrating on general analytical methods, while retaining some of the earlier focus on fisheries modelling, the idea was to make the new volume applicable, and hopefully useful, to a wider ecological audience rather than just fisheries scientists. Like the original book there is still a mixture of text and worked examples. However, time has passed and software tools that are easily and freely available for such analyses, such as R (R Core Team, 2019), have moved along in their development, as has the background knowledge of many students of the natural sciences. When that was considered, and having received numerous email requests for R versions of the earlier example boxes, it occurred to me that writing a new book focussed upon many of the analytical techniques, and using R for those analyses, might be a useful contribution.

The earlier book was supposed to be an introductory text, however, as stated in the Preface to the second edition (Haddon, 2011) “… keeping it an introductory text that is accessible to the majority is something of a challenge when covering some of the more important though intrinsically complex methods.” The challenge at that time came from trying to implement such advanced methods using Microsoft Excel, which required such things as worksheet maps, macros, and related strategies (most would hopefully agree that implementing a Markov Chain Monte Carlo analysis in Excel is not really a sensible undertaking). It is far more sensible to attempt to implement such things in a programming language such as R. This remains an introductory book and the intent is to illustrate how such methods work and provide a framework with which one can experiment and learn. The hope is that this will provide a foundation from where the reader can move to more production based methods.

Some examples from the earlier book have been re-used but I have taken the opportunity to expand and generate new ones for implementation in R. I have attempted to include more practical details and example code needed to conduct the work. To complement and streamline the code sections in this book I have also developed an R package, MQMF, available at both https://www.github.com/haddonm/MQMF, and published to CRAN, https://cran.r-project.org/. This is required for the examples in the book to work. The example R-code chunks are all provided in the help sections of six functions called chapter2, chapter3, …, chapter7. Each example is in the sequence it is found in each chapter along with section headings to simplify finding the particular example of interest. Within RStudio one just has to select the section of code wanted and press {ctrl}{enter}, as usual. Otherwise, select the code and paste it into the R console or into an editor to adjust each script according to your own wishes.

I have no pretensions about being a computer programmer but am rather a scientific programmer. This means that the code I write is likely not as efficient or as well structured as it could be. Hopefully, however, its intent is clear and relatively simple to understand. One very nice aspect of R code is that it is usually open source so you must feel free to modify or improve the code found here in any way you wish.

As with all introductory books the question arises of what to include and where to stop. The survey of methods included remains relatively broad and the depth with which each is treated varies. My primary hope is that the reader finds something in here that they consider to be useful to them in their work and their understanding of the analyses.

Hobart, January 2020

## Acknowledgements

I would especially like to thank Oceans and Atmosphere, CSIRO, Hobart, for giving me the opportunity of being a CSIRO Honorary Fellow. Continued access to the library and the office has facilitated the writing of this book immensely. Besides the practicalities, it is also valuable to remain within such an active working environment with so many fine people with whom I have mixed and collaborated while working in fisheries science. In addition, I would like to thank the University of Tasmania for appointing me an Adjunct Professor with the Institute of Marine and Antarctic Studies. Even after I left the University of Tasmania, late in 2008, I continued to work with and collaborate with the many excellent staff there, particular Dr Craig Mundy, who I also thank for the permissions to use various data from the abalone research program in a number of data-sets included in the MQMF R package.

I would like also to thank the many people who have contacted me through email and who have asked interesting questions. They help me identify the areas that I have not made as clear as I could.

Finally, I would like to thank Rob Calver, my editor at Chapman & Hall/CRC, who arranged to let me publish an online git-book version of this book for free, either on github pages or at www.bookdown.org. It seems to me that one of the great advantages of bookdown is that it can facilitate such a diversity of publishing options. The Open Source community, of which R, CRAN, and parts of RStudio constitute some of the best examples, is a remarkable achievement and one which we should all celebrate and applaud the people involved.

## Production Details

This book was written using Bookdown (Xie, 2017) within RStudio (RStudio, 2019) and I have used the Chapman & Hall/CRC LaTeX class (kranz.cls) as modified by Yihui Xie and with some very minor trial and error edits to the page fractions by myself. The code chunks are written using the Consolas font and will appear in slightly grey boxes. Package names will be bolded (MQMF) and function names, function(), will end in round brackets when they are merely being referred to in the text. The brackets are to distinguish them from other code text, which will generally refer to variables, parameters and function arguments. The code chunks relating to figures will generally refer to colours but the book is printed in black and white so different patterns or spewcific orders are also used to distinguish different lines. Elsewhere one would generally use colour or pattern but not both. I have kept the references to colour in the code blocks and in the figure legends so that the code remains general, but hopefully not confusing.

Console output from a code chunk will generally be pre-fixed with #, while whole line comments within code chunks will always be indented by a single space. No matter what the code chunks try to impose (font=7 implies a serif font), the LaTeX class used to define how the pdfengine renders the figures is set up to use sans serif fonts. If the code chunks are used separately they will therefore render the plots differently.