A First Course in Statistical Programming with R

A First Course in Statistical Programming with R

3.4 5
by W. John Braun, Duncan J. Murdoch
     
 

This is the only introduction you'll need to start programming in R, the open-source language that is free to download and lets you adapt the source code for your own requirements. Co-written by one of the R Core Development Team, and by an established R author, this book comes with real R code that complies with the standards of the language: Self-contained first… See more details below

Overview

This is the only introduction you'll need to start programming in R, the open-source language that is free to download and lets you adapt the source code for your own requirements. Co-written by one of the R Core Development Team, and by an established R author, this book comes with real R code that complies with the standards of the language: Self-contained first course in statistical computing, Accessible to any student familiar with university-level calculus, The basics of R syntax and statistical graphics are explained, and elementary programming is discussed, Programming applications in simulation and optimization as well as numerical linear algebra are introduced, Many worked examples with notes on "understanding the code", All examples are drawn from statistical applications, End-of-chapter review questions plus over 150 exercises; data sets and solutions all available on web.

Product Details

ISBN-13:
9780521694247
Publisher:
Cambridge University Press
Publication date:
10/31/2007
Edition description:
New Edition
Pages:
174
Product dimensions:
7.44(w) x 9.69(h) x 0.39(d)

Table of Contents

Preface     ix
Getting started     1
What is statistical programming?     1
Outline of the book     2
The R package     3
Why use a command line?     3
Font conventions     4
Installation of R     4
Introduction to the R language     5
Starting and quitting R     5
Recording your work     6
Basic features of R     7
Calculating with R     7
Named storage     7
Functions     9
Exact or approximate?     9
R is case-sensitive     12
Listing the objects in the workspace     12
Vectors     12
Extracting elements from vectors     13
Vector arithmetic     14
Simple patterned vectors     15
Missing values and other special values     16
Character vectors     16
Factors     17
More on extracting elements from vectors     18
Matrices and arrays     18
Data frames     19
Dates and times     21
Built-in functions and online help     21
Built-in examples     22
Finding help when you don't know the function name     23
Built-in graphics functions     23
Additional elementary built-in functions     25
Logical vectors and relational operators     26
Boolean algebra     26
Logical operations in R     27
Relational operators     28
Data input and output     29
Changing directories     29
dump () and source ()     29
Redirecting R output     30
Saving and retrieving image files     31
Data frames and the read.table function     31
Lists     31
Chapter exercises     32
Programming statistical graphics     33
High-level plots     33
Bar charts and dot charts     34
Pie charts     35
Histograms     35
Box plots     36
Scatterplots     38
QQ plots     39
Choosing a high-level graphic     41
Low-level graphics functions     42
The plotting region and margins     42
Adding to plots     43
Setting graphical parameters     45
Chapter exercises      46
Programming with R     47
Flow control     47
The for () loop     47
The if () statement     50
The while () loop     54
Newton's method for root finding     55
The repeat loop, and the break and next statements     57
Managing complexity through functions     59
What are functions?     59
Scope of variables     62
Miscellaneous programming tips     63
Using fix ()     63
Documentation using #     64
Some general programming guidelines     65
Top-down design     67
Debugging and maintenance     72
Recognizing that a bug exists     72
Make the bug reproducible     73
Identify the cause of the bug     73
Fixing errors and testing     75
Look for similar errors elsewhere     75
The browser () and debug () functions     75
Efficient programming     77
Learn your tools     77
Use efficient algorithms     78
Measure the time your program takes     79
Be willing to use different tools     80
Optimize with care     80
Chapter exercises     80
Simulation     82
Monte Carlo simulation     82
Generation of pseudorandom numbers     83
Simulation of other random variables     88
Bernoulli random variables     88
Binomial random variables     89
Poisson random variables     93
Exponential random numbers     97
Normal random variables     99
Monte Carlo integration     101
Advanced simulation methods     104
Rejection sampling     104
Importance sampling     107
Chapter exercises     109
Computational linear algebra     112
Vectors and matrices in R     113
Constructing matrix objects     113
Accessing matrix elements; row and column names     115
Matrix properties     117
Triangular matrices     118
Matrix arithmetic     118
Matrix multiplication and inversion     119
Matrix inversion     120
The LU decomposition     121
Matrix inversion in R     122
Solving linear systems     123
Eigenvalues and eigenvectors     124
Advanced topics      125
The singular value decomposition of a matrix     125
The Choleski decomposition of a positive definite matrix     126
The QR decomposition of a matrix     127
The condition number of a matrix     128
Outer products     129
Kronecker products     129
apply ()     129
Chapter exercises     130
Numerical optimization     132
The golden section search method     132
Newton-Raphson     135
The Nelder-Mead simplex method     138
Built-in functions     142
Linear programming     142
Solving linear programming problems in R     145
Maximization and other kinds of constraints     145
Special situations     146
Unrestricted variables     149
Integer programming     150
Alternatives to lp ()     151
Quadratic programming     151
Chapter exercises     157
Review of random variables and distributions     158
Index     161

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >