list of exemplary papers is given: These papers have been selected on the basis of
how well they explain and illustrate the techniques discussed in the chapter.
1.1.2 Why R and MATLAB?
Both R and MATLAB are readily available and extensively used. The program R has
two major advantages over MATLAB: first it is free, and second it is a highly
sophisticated statistical package. Thus a student who learns R can use it to do
modeling and to address the statistical questions that will arise following experi-
ments to test such models. MATLAB appears to be generally faster than R, except
perhaps in the complex statistical analyses. On the other hand, MATLAB is not
cheap and although it has statistical routines, these are not its forte and I would
not recommend it as a general means of statistical analysis. Although the symbols
of the two languages are different (e.g., “< -” in R vs. “=” in MATLAB), in most cases
the basic structures are very similar and it is not difficult to navigate between the
two, once the general concepts are understood. While I personally prefer R,
MATLAB does have some significance: Therefore, in Chapters 2 and 6 I provide
coding in both R and MATLAB and in the other chapters I give the coding only in R.
The problems addressed in Chapter 2 typically involve the calculus for which
MATLAB is particularly useful and may involve somewhat different coding to that
of R. In contrast, the problems addressed in Chapter 6 use coding that is essentially
the same, and the MATLAB code can be obtained from the R code in large measure
by relatively little editing (see later). This is the case for the other chapters, which,
in the interests of clarity, is why I have omitted the MATLAB code (the primary
coding changes generally involve graphical output). Throughout the book com-
puter code is given in courier font to distinguish it from the rest of the text.
Appendix 1 lists all the R functions used in this book and, where available, the
MATLAB equivalents. In general, R code can be largely converted to MATLAB code
by global editing in a text-editor such as Word. The general changes that will have
to be made are as follows:
1. Replace the assignment symbol “< –” with “¼”.
2. Replace the comment symbol “#” with “%”.
3. For ease of reading I frequently use a “.” in my variable names, as for example,
X.Matrix. This is not permitted in MATLAB and so I replace “.” with the
underscore character “_”.
4. Matrices in R use square brackets, for example, X[1,1]; replace these with
parentheses, that is, X(1,1).
5. Concatenation uses the symbol c(variables); in MATLAB use square brackets
[variables].
6. Loops in R use the brackets “{‘ and ’}”. MATLAB does not use these, so delete
them and replace “}” with “end”.
7. In MATLAB, functions go in separate files. See Appendix 1 and Section 3
(Step 10) for differences in construction of functions.
2 MODELING EVOLUTION