A First Course in Statistical Programming with R
W. J. Braun and D. J. Murdoch
January 5, 2016
Preface to the Second Edition
A lot of things have happened in the R community since we wrote the first edition of this text. Millions of new
users have started

7
Numerical Optimization
In many areas of statistics and applied mathematics one has to solve the following problem: given a function f (),
which value of x makes f (x) as large or as small as possible?
For example, in financial modelling f (x) might be t

4
Programming with R
Programming involves writing relatively complex systems of instructions. There are two broad styles of programming: the imperative style (used in R, for example) involves stringing together instructions telling the computer
what to do

6
Computational Linear Algebra
Linear algebra deals with vector spaces and linear operations on them. In mathematics, we usually represent
vectors as column vectors of numbers, and linear operations as matrices. Applying a linear operation to a vector
bec

5
Simulation
Much of statistics relies on being able to evaluate expectations of random variables, and finding quantiles of
distributions.1 For example:
In hypothesis testing, the p-value of a sample is defined as the probability of observing data at lea