|
|
xxi | |
Preface |
|
xxiii | |
Acknowledgments |
|
xxv | |
About the Companion Website |
|
xxvii | |
|
|
1 | (16) |
|
|
1 | (2) |
|
1.1.1 How to use this book |
|
|
1 | (2) |
|
|
3 | (1) |
|
1.3 Installing R and RStudio |
|
|
3 | (1) |
|
|
4 | (3) |
|
1.4.1 Using R directly via the console |
|
|
5 | (1) |
|
|
5 | (2) |
|
1.5 The Comprehensive R Archive Network |
|
|
7 | (1) |
|
|
7 | (1) |
|
1.5.2 Frequently asked questions |
|
|
8 | (1) |
|
1.5.3 Contributed documentation |
|
|
8 | (1) |
|
|
8 | (3) |
|
1.6.1 Contents of packages |
|
|
9 | (1) |
|
|
9 | (1) |
|
1.6.3 Installing packages |
|
|
9 | (2) |
|
|
11 | (2) |
|
1.7.1 Worked examples of functions |
|
|
12 | (1) |
|
1.7.2 Demonstrations of R functions |
|
|
13 | (1) |
|
|
13 | (2) |
|
|
13 | (1) |
|
1.8.2 What's loaded or defined in the current session |
|
|
14 | (1) |
|
1.8.3 Attaching and detaching objects |
|
|
14 | (1) |
|
|
15 | (1) |
|
1.9 Linking to other computer languages |
|
|
15 | (2) |
|
|
15 | (2) |
|
|
17 | (38) |
|
2.1 Mathematical functions |
|
|
17 | (13) |
|
2.1.1 Logarithms and exponentials |
|
|
18 | (1) |
|
2.1.2 Trigonometric functions |
|
|
19 | (1) |
|
|
20 | (2) |
|
2.1.4 Polynomial functions |
|
|
22 | (2) |
|
|
24 | (1) |
|
2.1.6 Asymptotic functions |
|
|
25 | (2) |
|
2.1.7 Sigmoid (S-shaped) functions |
|
|
27 | (1) |
|
2.1.8 Biexponential function |
|
|
28 | (1) |
|
2.1.9 Transformations of model variables |
|
|
29 | (1) |
|
|
30 | (10) |
|
2.2.1 Matrix multiplication |
|
|
31 | (1) |
|
2.2.2 Diagonals of matrices |
|
|
32 | (1) |
|
|
33 | (2) |
|
2.2.4 Inverse of a matrix |
|
|
35 | (1) |
|
2.2.5 Eigenvalues and eigenvectors |
|
|
36 | (3) |
|
2.2.6 Solving systems of linear equations using matrices |
|
|
39 | (1) |
|
|
40 | (5) |
|
|
40 | (1) |
|
|
41 | (1) |
|
2.3.3 Differential equations |
|
|
42 | (3) |
|
|
45 | (5) |
|
2.4.1 The central limit theorem |
|
|
45 | (4) |
|
2.4.2 Conditional probability |
|
|
49 | (1) |
|
|
50 | (5) |
|
|
51 | (1) |
|
|
51 | (2) |
|
|
53 | (2) |
|
3 Essentials of the R Language |
|
|
55 | (152) |
|
|
56 | (8) |
|
|
57 | (1) |
|
|
58 | (1) |
|
|
59 | (2) |
|
|
61 | (1) |
|
|
62 | (1) |
|
|
63 | (1) |
|
|
64 | (1) |
|
|
64 | (3) |
|
|
67 | (7) |
|
|
68 | (1) |
|
3.4.2 Testing for equality of real numbers |
|
|
69 | (1) |
|
3.4.3 Testing for equality of non-numeric objects |
|
|
70 | (2) |
|
3.4.4 Evaluation of combinations of TRUE and false |
|
|
72 | (1) |
|
|
73 | (1) |
|
|
74 | (4) |
|
|
76 | (1) |
|
3.5.2 Generating factor levels |
|
|
77 | (1) |
|
|
78 | (4) |
|
3.7 Missing values, infinity, and things that are not numbers |
|
|
82 | (4) |
|
|
83 | (3) |
|
3.8 Vectors and subscripts |
|
|
86 | (5) |
|
3.8.1 Extracting elements of a vector using subscripts |
|
|
87 | (2) |
|
|
89 | (1) |
|
3.8.3 Naming elements within vectors |
|
|
90 | (1) |
|
3.9 Working with logical subscripts |
|
|
91 | (2) |
|
|
93 | (16) |
|
3.10.1 Obtaining tables using tapply () |
|
|
95 | (2) |
|
3.10.2 Applying functions to vectors using sapply () |
|
|
97 | (2) |
|
3.10.3 The aggregate () function for grouped summary statistics |
|
|
99 | (1) |
|
3.10.4 Parallel minima and maxima: pmin and pmax |
|
|
100 | (1) |
|
3.10.5 Finding closest values |
|
|
101 | (1) |
|
3.10.6 Sorting, ranking, and ordering |
|
|
102 | (2) |
|
3.10.7 Understanding the difference between unique () and duplicated () |
|
|
104 | (2) |
|
3.10.8 Looking for runs of numbers within vectors |
|
|
106 | (2) |
|
3.10.9 Sets: union (), intersect (), and setdiff () |
|
|
108 | (1) |
|
|
109 | (17) |
|
|
111 | (1) |
|
3.11.2 Naming the rows and columns of matrices |
|
|
112 | (1) |
|
3.11.3 Calculations on rows or columns of matrices |
|
|
113 | (2) |
|
3.11.4 Adding rows and columns to matrices |
|
|
115 | (2) |
|
3.11.5 The sweep () function |
|
|
117 | (2) |
|
3.11.6 Applying functions to matrices |
|
|
119 | (1) |
|
|
120 | (1) |
|
3.11.8 Using the max. col () function |
|
|
121 | (2) |
|
3.11.9 Restructuring a multi-dimensional array using aperm () |
|
|
123 | (3) |
|
3.12 Random numbers, sampling, and shuffling |
|
|
126 | (2) |
|
3.12.1 The sample () function |
|
|
127 | (1) |
|
|
128 | (10) |
|
3.13.1 More complicated while () loops |
|
|
131 | (2) |
|
|
133 | (1) |
|
3.13.3 The slowness of loops |
|
|
134 | (1) |
|
3.13.4 Do not `grow' data sets by concatenation or recursive function calls |
|
|
135 | (1) |
|
3.13.5 Loops for producing time series |
|
|
136 | (2) |
|
|
138 | (9) |
|
3.14.1 Summarising lists and lapply () |
|
|
140 | (2) |
|
3.14.2 Manipulating and saving lists |
|
|
142 | (5) |
|
3.15 Text, character strings, and pattern matching |
|
|
147 | (17) |
|
3.15.1 Pasting character strings together |
|
|
149 | (1) |
|
3.15.2 Extracting parts of strings |
|
|
150 | (1) |
|
3.15.3 Counting things within strings |
|
|
151 | (2) |
|
3.15.4 Upper and lower case text |
|
|
153 | (1) |
|
3.15.5 The match () function and relational databases |
|
|
153 | (2) |
|
|
155 | (4) |
|
3.15.7 Substituting text within character strings |
|
|
159 | (1) |
|
3.15.8 Locations of a pattern within a vector |
|
|
160 | (2) |
|
3.15.9 Comparing vectors using %in% and which () |
|
|
162 | (1) |
|
3.15.10 Stripping patterned text out of complex strings |
|
|
163 | (1) |
|
3.16 Dates and times in R |
|
|
164 | (13) |
|
3.16.1 Reading time data from files |
|
|
165 | (3) |
|
3.16.2 Calculations with dates and times |
|
|
168 | (2) |
|
3.16.3 Generating sequences of dates |
|
|
170 | (3) |
|
3.16.4 Calculating time differences between the rows of a dataframe |
|
|
173 | (2) |
|
3.16.5 Regression using dates and times |
|
|
175 | (2) |
|
|
177 | (4) |
|
3.17.1 Using attach () or not! |
|
|
178 | (2) |
|
3.17.2 Using attach () in this book |
|
|
180 | (1) |
|
|
181 | (19) |
|
3.18.1 Arithmetic mean of a single sample |
|
|
181 | (1) |
|
3.18.2 Median of a single sample |
|
|
182 | (1) |
|
|
183 | (1) |
|
|
184 | (2) |
|
|
186 | (1) |
|
3.18.6 Variance ratio test |
|
|
187 | (2) |
|
3.18.7 Using the variance |
|
|
189 | (2) |
|
3.18.8 Plots and deparsing in functions |
|
|
191 | (1) |
|
3.18.9 The switch () function |
|
|
192 | (1) |
|
3.18.10 Arguments in our function |
|
|
193 | (2) |
|
3.18.11 Errors in our functions |
|
|
195 | (1) |
|
3.18.12 Outputs from our function |
|
|
196 | (4) |
|
3.19 Structure of R objects |
|
|
200 | (3) |
|
3.20 Writing from R to a file |
|
|
203 | (3) |
|
3.20.1 Saving data objects |
|
|
203 | (1) |
|
3.20.2 Saving command history |
|
|
204 | (1) |
|
3.20.3 Saving graphics or plots |
|
|
204 | (1) |
|
3.20.4 Saving data for a spreadsheet |
|
|
204 | (1) |
|
3.20.5 Saving output from functions to a file |
|
|
205 | (1) |
|
3.21 Tips for writing R code |
|
|
206 | (1) |
|
|
206 | (1) |
|
4 Data Input and Dataframes |
|
|
207 | (42) |
|
|
207 | (1) |
|
4.2 Data input from files |
|
|
208 | (7) |
|
4.2.1 Data input using read, table () and read.csv () |
|
|
208 | (2) |
|
4.2.2 Input from files using scan () |
|
|
210 | (3) |
|
4.2.3 Reading data from a file using readLines () |
|
|
213 | (2) |
|
4.3 Data input directly from the web |
|
|
215 | (1) |
|
|
215 | (1) |
|
|
216 | (25) |
|
4.5.1 Subscripts and indices |
|
|
220 | (2) |
|
4.5.2 Selecting rows from the dataframe at random |
|
|
222 | (1) |
|
|
223 | (6) |
|
4.5.4 Using logical conditions to select rows from the dataframe |
|
|
229 | (3) |
|
4.5.5 Omitting rows containing missing values, NA |
|
|
232 | (3) |
|
4.5.6 A dataframe with row names instead of row numbers |
|
|
235 | (1) |
|
4.5.7 Creating a dataframe from another kind of object |
|
|
236 | (3) |
|
4.5.8 Eliminating duplicate rows from a dataframe |
|
|
239 | (1) |
|
4.5.9 Dates in dataframes |
|
|
239 | (2) |
|
4.6 Using the match () function in dataframes |
|
|
241 | (4) |
|
4.6.1 Merging two dataframes |
|
|
243 | (2) |
|
4.7 Adding margins to a dataframe |
|
|
245 | (4) |
|
4.7.1 Summarising the contents of dataframes |
|
|
247 | (2) |
|
|
249 | (48) |
|
|
249 | (6) |
|
5.1.1 Axes labels and titles |
|
|
251 | (1) |
|
5.1.2 Plotting symbols and colours |
|
|
251 | (3) |
|
|
254 | (1) |
|
5.2 Plots for single variables |
|
|
255 | (10) |
|
5.2.1 Histograms vs. bar charts |
|
|
255 | (1) |
|
|
256 | (4) |
|
|
260 | (1) |
|
|
261 | (1) |
|
|
262 | (1) |
|
|
263 | (1) |
|
|
264 | (1) |
|
5.3 Plots for showing two numeric variables |
|
|
265 | (7) |
|
|
265 | (5) |
|
5.3.2 Plots with many identical values |
|
|
270 | (2) |
|
5.4 Plots for numeric variables by group |
|
|
272 | (5) |
|
|
272 | (2) |
|
|
274 | (1) |
|
5.4.3 An inferior (but popular) option |
|
|
275 | (2) |
|
5.5 Plots showing two categorical variables |
|
|
277 | (2) |
|
|
277 | (1) |
|
|
277 | (2) |
|
5.6 Plots for three (or more) variables |
|
|
279 | (4) |
|
5.6.1 Plots of all pairs of variables |
|
|
279 | (1) |
|
5.6.2 Incorporating a third variable on a scatterplot |
|
|
280 | (1) |
|
|
281 | (2) |
|
|
283 | (10) |
|
|
285 | (1) |
|
|
286 | (3) |
|
|
289 | (1) |
|
5.7.4 Panels for conditioning plots |
|
|
290 | (1) |
|
|
291 | (1) |
|
5.7.6 More panel functions |
|
|
292 | (1) |
|
|
293 | (4) |
|
5.8.1 Two-dimensional plots |
|
|
293 | (2) |
|
5.8.2 Three-dimensional plots |
|
|
295 | (1) |
|
|
295 | (2) |
|
6 Graphics in More Detail |
|
|
297 | (62) |
|
|
297 | (11) |
|
6.1.1 Colour palettes with categorical data |
|
|
297 | (2) |
|
6.1.2 The RColorBrewer package |
|
|
299 | (3) |
|
|
302 | (1) |
|
|
302 | (1) |
|
6.1.5 Background colour for legends |
|
|
303 | (1) |
|
6.1.6 Different colours for different parts of the graph |
|
|
304 | (1) |
|
6.1.7 Full control of colours in plots |
|
|
305 | (2) |
|
6.1.8 Cross-hatching and grey scale |
|
|
307 | (1) |
|
6.2 Changing the look of graphics |
|
|
308 | (3) |
|
6.2.1 Shape and size of plot |
|
|
308 | (1) |
|
6.2.2 Multiple plots on one screen |
|
|
309 | (1) |
|
6.2.3 Tickmarks and associated labels |
|
|
309 | (2) |
|
|
311 | (1) |
|
6.3 Adding items to plots |
|
|
311 | (15) |
|
|
311 | (2) |
|
6.3.2 Adding smooth parametric curves to a scatterplot |
|
|
313 | (1) |
|
6.3.3 Fitting non-parametric curves through a scatterplot |
|
|
314 | (2) |
|
6.3.4 Connecting observations |
|
|
316 | (5) |
|
|
321 | (1) |
|
6.3.6 Adding mathematical and other symbols |
|
|
322 | (4) |
|
6.4 The grammar of graphics and ggplot2 |
|
|
326 | (4) |
|
|
327 | (1) |
|
|
327 | (3) |
|
|
330 | (29) |
|
6.5.1 Text justification, adj |
|
|
332 | (1) |
|
6.5.2 Annotation of graphs, ann |
|
|
332 | (1) |
|
6.5.3 Delay moving on to the next in a series of plots, ask |
|
|
332 | (1) |
|
6.5.4 Control over the axes, axis |
|
|
332 | (1) |
|
6.5.5 Background colour for plots, bg |
|
|
333 | (1) |
|
6.5.6 Boxes around plots, bty |
|
|
334 | (1) |
|
6.5.7 Size of plotting symbols using the character expansion function, cex |
|
|
334 | (1) |
|
6.5.8 Changing the shape of the plotting region, plt |
|
|
335 | (1) |
|
6.5.9 Locating multiple graphs in non-standard layouts using fig |
|
|
336 | (1) |
|
6.5.10 Two graphs with a common X scale but different Y scales using fig |
|
|
336 | (2) |
|
6.5.11 The layout function |
|
|
338 | (2) |
|
6.5.12 Creating and controlling multiple screens on a single device |
|
|
340 | (1) |
|
6.5.13 Orientation of numbers on the tick marks, 1as |
|
|
341 | (1) |
|
6.5.14 Shapes for the ends and joins of lines, lend and ljoin |
|
|
342 | (1) |
|
|
343 | (1) |
|
|
343 | (1) |
|
6.5.17 Several graphs on the same page, mf row and mfcol |
|
|
344 | (1) |
|
6.5.18 Margins around the plotting area, mar |
|
|
345 | (1) |
|
6.5.19 Plotting more than one graph on the same axes, new |
|
|
346 | (1) |
|
6.5.20 Outer margins, oma |
|
|
347 | (1) |
|
6.5.21 Packing graphs closer together |
|
|
348 | (2) |
|
6.5.22 Square plotting region, pty |
|
|
350 | (1) |
|
6.5.23 Character rotation, srt |
|
|
350 | (1) |
|
6.5.24 Rotating the axis labels |
|
|
351 | (1) |
|
6.5.25 Tick marks on the axes |
|
|
351 | (2) |
|
|
353 | (1) |
|
|
353 | (4) |
|
|
357 | (2) |
|
|
359 | (14) |
|
7.1 Tabulating categorical or discrete data |
|
|
359 | (3) |
|
|
359 | (1) |
|
7.1.2 Tables of proportions |
|
|
360 | (2) |
|
7.2 Tabulating summaries of numeric data |
|
|
362 | (5) |
|
7.2.1 General summaries by group |
|
|
362 | (2) |
|
7.2.2 Bespoke summaries by group |
|
|
364 | (3) |
|
7.3 Converting between tables and dataframes |
|
|
367 | (6) |
|
7.3.1 From a table to a dataframe |
|
|
367 | (3) |
|
7.3.2 From a dataframe to a table |
|
|
370 | (1) |
|
|
371 | (2) |
|
8 Probability Distributions in R |
|
|
373 | (32) |
|
8.1 Probability distributions: the basics |
|
|
374 | (2) |
|
8.1.1 Discrete and continuous probability distributions |
|
|
374 | (1) |
|
8.1.2 Describing probability distributions mathematically |
|
|
374 | (1) |
|
|
375 | (1) |
|
8.2 Probability distributions in R |
|
|
376 | (1) |
|
8.3 Continuous probability distributions |
|
|
377 | (15) |
|
8.3.1 The Normal (or Gaussian) distribution |
|
|
377 | (3) |
|
8.3.2 The Uniform distribution |
|
|
380 | (1) |
|
8.3.3 The Chi-squared distribution |
|
|
381 | (1) |
|
|
382 | (1) |
|
8.3.5 Student's T Distribution |
|
|
383 | (2) |
|
8.3.6 The Gamma distribution |
|
|
385 | (1) |
|
8.3.7 The Exponential distribution |
|
|
386 | (1) |
|
8.3.8 The Beta distribution |
|
|
387 | (1) |
|
8.3.9 The Lognormal distribution |
|
|
388 | (1) |
|
8.3.10 The Logistic distribution |
|
|
389 | (1) |
|
8.3.11 The Weibull distribution |
|
|
390 | (1) |
|
8.3.12 Multivariate Normal distribution |
|
|
390 | (2) |
|
8.4 Discrete probability distributions |
|
|
392 | (10) |
|
8.4.1 The Bernoulli distribution |
|
|
392 | (1) |
|
8.4.2 The Binomial distribution |
|
|
392 | (3) |
|
8.4.3 The Geometric distribution |
|
|
395 | (2) |
|
8.4.4 The Hypergeometric distribution |
|
|
397 | (1) |
|
8.4.5 The Multinomial distribution |
|
|
398 | (1) |
|
8.4.6 The Poisson distribution |
|
|
399 | (1) |
|
8.4.7 The Negative Binomial distribution |
|
|
400 | (2) |
|
8.5 The central limit theorem |
|
|
402 | (3) |
|
|
404 | (1) |
|
|
405 | (34) |
|
|
406 | (4) |
|
9.1.1 Defining the question to be tested |
|
|
406 | (2) |
|
|
408 | (1) |
|
9.1.3 Interpreting results |
|
|
408 | (2) |
|
|
410 | (11) |
|
9.2.1 Single population average |
|
|
410 | (2) |
|
9.2.2 Two population averages |
|
|
412 | (2) |
|
9.2.3 Multiple population averages |
|
|
414 | (1) |
|
9.2.4 Population distribution |
|
|
415 | (2) |
|
9.2.5 Checking and testing for normality |
|
|
417 | (2) |
|
9.2.6 Comparing variances |
|
|
419 | (2) |
|
9.3 Discrete and categorical data |
|
|
421 | (10) |
|
|
421 | (2) |
|
9.3.2 Test to compare proportions |
|
|
423 | (4) |
|
|
427 | (2) |
|
9.3.4 Testing contingency tables |
|
|
429 | (2) |
|
|
431 | (2) |
|
|
433 | (1) |
|
9.6 Power and sample size calculations |
|
|
434 | (2) |
|
|
436 | (3) |
|
|
437 | (2) |
|
|
439 | (60) |
|
10.1 The simple linear regression model |
|
|
440 | (6) |
|
10.1.1 Model format and assumptions |
|
|
440 | (3) |
|
10.1.2 Building a simple linear regression model |
|
|
443 | (3) |
|
10.2 The multiple linear regression model |
|
|
446 | (12) |
|
10.2.1 Model format and assumptions |
|
|
446 | (1) |
|
10.2.2 Building a multiple linear regression model |
|
|
447 | (2) |
|
10.2.3 Categorical covariates |
|
|
449 | (5) |
|
10.2.4 Interactions between covariates |
|
|
454 | (4) |
|
10.3 Understanding the output |
|
|
458 | (7) |
|
|
458 | (1) |
|
10.3.2 Estimates of coefficients |
|
|
459 | (1) |
|
10.3.3 Testing individual coefficients |
|
|
459 | (1) |
|
10.3.4 Residual standard error |
|
|
460 | (1) |
|
10.3.5 R2 and its variants |
|
|
460 | (1) |
|
10.3.6 The regression F-test |
|
|
460 | (1) |
|
10.3.7 ANOVA: Same model, different output |
|
|
461 | (3) |
|
10.3.8 Extracting model information |
|
|
464 | (1) |
|
|
465 | (8) |
|
10.4.1 The principle of parsimony |
|
|
465 | (2) |
|
10.4.2 First plot the data |
|
|
467 | (1) |
|
10.4.3 Comparing nested models |
|
|
468 | (2) |
|
10.4.4 Comparing non-nested models |
|
|
470 | (1) |
|
10.4.5 Dealing with large numbers of covariates |
|
|
471 | (2) |
|
10.5 Checking model assumptions |
|
|
473 | (18) |
|
10.5.1 Residuals and standardised residuals |
|
|
473 | (1) |
|
10.5.2 Checking for linearity |
|
|
474 | (2) |
|
10.5.3 Checking for homoscedasticity of errors |
|
|
476 | (1) |
|
10.5.4 Checking for normality of errors |
|
|
476 | (2) |
|
10.5.5 Checking for independence of errors |
|
|
478 | (1) |
|
10.5.6 Checking for influential observations |
|
|
479 | (2) |
|
10.5.7 Checking for collinearity |
|
|
481 | (2) |
|
|
483 | (8) |
|
|
491 | (6) |
|
10.6.1 Interpretation of model |
|
|
491 | (4) |
|
10.6.2 Making predictions |
|
|
495 | (2) |
|
10.7 Further types of regression modelling |
|
|
497 | (2) |
|
|
498 | (1) |
|
11 Generalised Linear Models |
|
|
499 | (80) |
|
|
499 | (8) |
|
|
499 | (1) |
|
|
500 | (1) |
|
|
501 | (1) |
|
|
502 | (4) |
|
11.1.5 Interpretation and prediction |
|
|
506 | (1) |
|
|
507 | (15) |
|
11.2.1 A straightforward example |
|
|
508 | (3) |
|
|
511 | (5) |
|
11.2.3 An alternative to Poisson counts |
|
|
516 | (6) |
|
11.3 Count table data and GLMs |
|
|
522 | (15) |
|
|
522 | (1) |
|
11.3.2 All covariates might be useful |
|
|
522 | (12) |
|
|
534 | (3) |
|
11.4 Proportion data and GLMs |
|
|
537 | (23) |
|
11.4.1 Theoretical background |
|
|
538 | (3) |
|
11.4.2 Logistic regression with binomial errors |
|
|
541 | (3) |
|
11.4.3 Predicting x from y |
|
|
544 | (1) |
|
11.4.4 Proportion data with categorical explanatory variables |
|
|
545 | (5) |
|
11.4.5 Binomial GLM with ordered categorical covariates |
|
|
550 | (6) |
|
11.4.6 Binomial GLM with categorical and continuous covariates |
|
|
556 | (3) |
|
11.4.7 Revisiting lizards |
|
|
559 | (1) |
|
11.5 Binary Response Variables and GLMs |
|
|
560 | (14) |
|
11.5.1 A straightforward example |
|
|
562 | (2) |
|
11.5.2 Graphical tests of the fit of the logistic curve to data |
|
|
564 | (3) |
|
11.5.3 Mixed covariate types with a binary response |
|
|
567 | (3) |
|
11.5.4 Spine plot and logistic regression |
|
|
570 | (4) |
|
|
574 | (5) |
|
|
577 | (2) |
|
12 Generalised Additive Models |
|
|
579 | (22) |
|
|
580 | (3) |
|
12.2 Straightforward examples of GAMs |
|
|
583 | (5) |
|
12.3 Background to using GAMs |
|
|
588 | (1) |
|
|
588 | (1) |
|
12.3.2 Suggestions for using gam () |
|
|
588 | (1) |
|
12.4 More complex GAM examples |
|
|
589 | (12) |
|
|
590 | (2) |
|
12.4.2 An example with strongly humped data |
|
|
592 | (4) |
|
12.4.3 GAMs with binary data |
|
|
596 | (2) |
|
12.4.4 Three-dimensional graphic output from gam |
|
|
598 | (1) |
|
|
599 | (2) |
|
|
601 | (26) |
|
13.1 Regression with categorical covariates |
|
|
601 | (1) |
|
13.2 An alternative method: random effects |
|
|
602 | (1) |
|
13.3 Common data structures where random effects are useful |
|
|
603 | (2) |
|
13.3.1 Nested (hierarchical) structures |
|
|
604 | (1) |
|
13.3.2 Non-nested structures |
|
|
604 | (1) |
|
13.3.3 Longitudinal structures |
|
|
605 | (1) |
|
13.4 R packages to deal with mixed effects models |
|
|
605 | (2) |
|
|
605 | (1) |
|
|
606 | (1) |
|
13.4.3 Methods for fitting mixed models |
|
|
606 | (1) |
|
13.5 Examples of implementing random effect models |
|
|
607 | (15) |
|
13.5.1 Multilevel data (two levels) |
|
|
607 | (4) |
|
13.5.2 Multilevel data (three levels) |
|
|
611 | (3) |
|
13.5.3 Designed experiment: split-plot |
|
|
614 | (3) |
|
|
617 | (5) |
|
13.6 Generalised linear mixed models |
|
|
622 | (3) |
|
13.6.1 Logistic mixed model |
|
|
622 | (3) |
|
13.7 Alternatives to mixed models |
|
|
625 | (2) |
|
|
625 | (2) |
|
|
627 | (22) |
|
14.1 Example: modelling deer jaw bone length |
|
|
628 | (6) |
|
14.1.1 An exponential model for the deer data |
|
|
629 | (3) |
|
14.1.2 A Michaelis-Menten model for the deer data |
|
|
632 | (2) |
|
14.1.3 Comparison of the exponential and the Michaelis-Menten model |
|
|
634 | (1) |
|
14.2 Example: grouped data |
|
|
634 | (4) |
|
14.3 Self-starting functions |
|
|
638 | (7) |
|
14.3.1 Self-starting Michaelis--Menten model |
|
|
638 | (2) |
|
14.3.2 Self-starting asymptotic exponential model |
|
|
640 | (2) |
|
14.3.3 Self-starting logistic |
|
|
642 | (1) |
|
14.3.4 Self-starting four-parameter logistic |
|
|
643 | (2) |
|
14.4 Further considerations |
|
|
645 | (4) |
|
|
645 | (2) |
|
14.4.2 Confidence intervals |
|
|
647 | (1) |
|
|
648 | (1) |
|
|
649 | (18) |
|
15.1 Handling survival data |
|
|
649 | (3) |
|
15.1.1 Structure of a survival dataset |
|
|
649 | (3) |
|
15.1.2 Survival data in R |
|
|
652 | (1) |
|
15.2 The survival and hazard functions |
|
|
652 | (3) |
|
15.2.1 Non-parametric estimation of the survival function |
|
|
653 | (1) |
|
15.2.2 Parametric estimation of the survival function |
|
|
654 | (1) |
|
15.3 Modelling survival data |
|
|
655 | (12) |
|
|
657 | (1) |
|
15.3.2 The Cox proportional hazard model |
|
|
658 | (2) |
|
15.3.3 Accelerated failure time models |
|
|
660 | (5) |
|
15.3.4 Cox proportional hazard or a parametric model? |
|
|
665 | (1) |
|
|
665 | (2) |
|
|
667 | (32) |
|
16.1 Factorial experiments |
|
|
667 | (6) |
|
|
672 | (1) |
|
|
673 | (4) |
|
16.2.1 Split-plot effects |
|
|
673 | (2) |
|
16.2.2 Removing pseudo-replication |
|
|
675 | (1) |
|
16.2.3 Derived variable analysis |
|
|
676 | (1) |
|
|
677 | (22) |
|
16.3.1 Contrast coefficients |
|
|
678 | (1) |
|
16.3.2 An example of contrasts using R |
|
|
679 | (5) |
|
16.3.3 Model simplification for contrasts |
|
|
684 | (4) |
|
|
688 | (1) |
|
|
689 | (2) |
|
16.3.6 Polynomial contrasts |
|
|
691 | (3) |
|
16.3.7 Contrasts with multiple covariates |
|
|
694 | (4) |
|
|
698 | (1) |
|
|
699 | (16) |
|
17.1 Elements of a meta-analysis |
|
|
699 | (4) |
|
17.1.1 Choosing studies for a meta-analysis |
|
|
700 | (1) |
|
17.1.2 Effects and effect size |
|
|
700 | (1) |
|
|
701 | (1) |
|
17.1.4 Fixed vs. random effect models |
|
|
701 | (2) |
|
|
703 | (4) |
|
17.2.1 Formatting information from studies |
|
|
703 | (1) |
|
17.2.2 Computing the inputs of a meta-analysis |
|
|
703 | (3) |
|
17.2.3 Conducting the meta-analysis |
|
|
706 | (1) |
|
|
707 | (4) |
|
17.3.1 Meta-analysis Of scaled differences |
|
|
707 | (4) |
|
17.4 Meta-analysis of categorical data |
|
|
711 | (4) |
|
|
714 | (1) |
|
|
715 | (26) |
|
|
715 | (2) |
|
|
717 | (6) |
|
|
723 | (6) |
|
|
724 | (1) |
|
18.3.2 Built in ts () functions |
|
|
724 | (2) |
|
|
726 | (2) |
|
18.3.4 Testing for a time series trend |
|
|
728 | (1) |
|
18.4 Multiple time series |
|
|
729 | (1) |
|
18.5 Some theoretical background |
|
|
730 | (3) |
|
|
731 | (1) |
|
18.5.2 Autoregressive models |
|
|
732 | (1) |
|
18.5.3 Partial autocorrelation |
|
|
732 | (1) |
|
18.5.4 Moving average models |
|
|
732 | (1) |
|
18.5.5 More general models: ARMA and ARIMA |
|
|
733 | (1) |
|
|
733 | (2) |
|
18.7 Simulation of time series |
|
|
735 | (6) |
|
|
739 | (2) |
|
19 Multivartate Statistics |
|
|
741 | (20) |
|
|
742 | (1) |
|
19.2 Multivariate analysis of variance |
|
|
743 | (2) |
|
19.3 Principal component analysis |
|
|
745 | (3) |
|
|
748 | (3) |
|
|
751 | (3) |
|
|
751 | (3) |
|
19.6 Hierarchical cluster analysis |
|
|
754 | (2) |
|
19.7 Discriminant analysis |
|
|
756 | (2) |
|
|
758 | (3) |
|
|
760 | (1) |
|
20 Classification and Regression Trees |
|
|
761 | (18) |
|
|
763 | (1) |
|
|
764 | (7) |
|
|
764 | (1) |
|
|
765 | (2) |
|
20.2.3 Comparison with linear regression |
|
|
767 | (2) |
|
20.2.4 Model simplification |
|
|
769 | (2) |
|
20.3 Classification trees |
|
|
771 | (4) |
|
20.3.1 Classification trees with categorical explanatory variables |
|
|
771 | (2) |
|
20.3.2 Classification trees for replicated data |
|
|
773 | (2) |
|
20.4 Looking for patterns |
|
|
775 | (4) |
|
|
777 | (2) |
|
|
779 | (20) |
|
21.1 Spatial point processes |
|
|
779 | (14) |
|
21.1.1 How can we check for randomness? |
|
|
781 | (4) |
|
|
785 | (5) |
|
|
790 | (3) |
|
21.2 Geospatial statistics |
|
|
793 | (6) |
|
|
794 | (4) |
|
|
798 | (1) |
|
|
799 | (24) |
|
22.1 Components of a Bayesian Analysis |
|
|
800 | (6) |
|
22.1.1 The likelihood (the model and data) |
|
|
800 | (1) |
|
|
801 | (1) |
|
|
802 | (1) |
|
22.1.4 Markov chain Monte Carlo (MCMC) |
|
|
803 | (1) |
|
22.1.5 Considerations for MCMC |
|
|
803 | (2) |
|
|
805 | (1) |
|
22.1.7 The Pros and Cons of going Bayesian |
|
|
806 | (1) |
|
22.2 Bayesian analysis in R |
|
|
806 | (4) |
|
|
807 | (1) |
|
|
807 | (1) |
|
22.2.3 Writing BUGS models |
|
|
808 | (2) |
|
|
810 | (8) |
|
22.3.1 MCMC for a simple linear regression |
|
|
810 | (4) |
|
22.3.2 MCMC for longitudinal data |
|
|
814 | (4) |
|
22.4 MCMC for a model with binomial errors |
|
|
818 | (5) |
|
|
821 | (2) |
|
|
823 | (16) |
|
|
823 | (3) |
|
23.1.1 Chaotic dynamics in population size |
|
|
823 | (2) |
|
23.1.2 Investigating the route to chaos |
|
|
825 | (1) |
|
23.2 Spatial simulation models |
|
|
826 | (11) |
|
23.2.1 Meta-population dynamics |
|
|
826 | (3) |
|
23.2.2 Coexistence resulting from spatially explicit (local) density dependence |
|
|
829 | (5) |
|
23.2.3 Pattern generation resulting from dynamic interactions |
|
|
834 | (3) |
|
23.3 Temporal and spatial dynamics: random walk |
|
|
837 | (2) |
|
|
838 | (1) |
Index |
|
839 | |