Online Resources |
|
xi | |
About the Authors |
|
xiii | |
Preface |
|
xv | |
Acknowledgements |
|
xvi | |
How to Use This Book |
|
xvi | |
Common Error Messages in R to Know About |
|
xviii | |
Regression Approach to ANOVA |
|
xxi | |
Authors' Contact |
|
xxii | |
|
|
1 | (22) |
|
1.1 What Is R and Why Should You Use It? |
|
|
2 | (4) |
|
|
6 | (1) |
|
1.3 How to Install R and RStudio? |
|
|
7 | (2) |
|
|
7 | (1) |
|
|
7 | (1) |
|
|
8 | (1) |
|
1.3.4 RStudio for Windows, Mac OS, and Linux |
|
|
8 | (1) |
|
1.4 Getting to Know RStudio |
|
|
9 | (4) |
|
|
10 | (1) |
|
|
11 | (1) |
|
|
12 | (1) |
|
|
13 | (1) |
|
1.5 Internet Resources for R |
|
|
13 | (3) |
|
1.6 Contributed R Packages |
|
|
16 | (2) |
|
1.7 Updating R, RStudio, and Contributed Packages |
|
|
18 | (1) |
|
|
19 | (4) |
|
2 Importing and Working With Data in R |
|
|
23 | (22) |
|
2.1 How Is a Dataset Represented in R? |
|
|
24 | (1) |
|
2.2 Importing Data Into R |
|
|
25 | (7) |
|
|
32 | (4) |
|
2.4 How Do We Work With a Dataset in R? |
|
|
36 | (3) |
|
|
39 | (3) |
|
|
42 | (3) |
|
|
45 | (24) |
|
|
46 | (1) |
|
|
47 | (3) |
|
|
50 | (15) |
|
|
53 | (2) |
|
|
55 | (2) |
|
Extracting rows and columns from data frames |
|
|
57 | (2) |
|
Adding observations and variables |
|
|
59 | (2) |
|
|
61 | (1) |
|
|
62 | (1) |
|
|
63 | (2) |
|
|
65 | (4) |
|
|
69 | (40) |
|
4.1 Data Management of Variables |
|
|
71 | (19) |
|
4.1.1 Generating new variables |
|
|
71 | (3) |
|
|
74 | (2) |
|
|
76 | (3) |
|
|
79 | (1) |
|
4.1.5 Exploring missing values |
|
|
80 | (4) |
|
4.1.6 Generating dummy variables |
|
|
84 | (2) |
|
4.1.7 Changing the data types of variables |
|
|
86 | (2) |
|
4.1.8 Labelling variables |
|
|
88 | (1) |
|
4.1.9 Tidying up categorical variables |
|
|
88 | (2) |
|
4.2 Data Management of Datasets |
|
|
90 | (14) |
|
4.2.1 Selecting and excluding variables |
|
|
90 | (2) |
|
4.2.2 Selecting observations |
|
|
92 | (2) |
|
4.2.3 Merging datasets by variables |
|
|
94 | (2) |
|
4.2.4 Merging datasets by observations |
|
|
96 | (1) |
|
|
97 | (1) |
|
4.2.6 Reshaping a dataset |
|
|
98 | (2) |
|
|
100 | (1) |
|
4.2.8 Drawing random samples from a dataset |
|
|
101 | (1) |
|
|
102 | (2) |
|
|
104 | (5) |
|
5 Data Visualization With ggplot2 |
|
|
109 | (40) |
|
5.1 The Role of Visualization in Data Analysis |
|
|
110 | (2) |
|
5.2 Understanding ggplot2 |
|
|
112 | (20) |
|
5.2.1 Structure of a layer |
|
|
113 | (1) |
|
|
114 | (1) |
|
|
114 | (1) |
|
|
115 | (3) |
|
Statistical transformations |
|
|
118 | (4) |
|
|
122 | (2) |
|
5.2.2 Additional components affecting all layers |
|
|
124 | (1) |
|
|
124 | (1) |
|
|
125 | (2) |
|
|
127 | (1) |
|
|
128 | (3) |
|
|
131 | (1) |
|
|
132 | (12) |
|
|
133 | (1) |
|
|
133 | (5) |
|
|
138 | (2) |
|
|
140 | (1) |
|
One categorical x and one continuous y |
|
|
140 | (2) |
|
One continuous x and one continuous y |
|
|
142 | (1) |
|
|
143 | (1) |
|
Continuous X, and Y and one categorical X2 |
|
|
143 | (1) |
|
|
144 | (5) |
|
|
149 | (34) |
|
6.1 Describing a Single Variable |
|
|
151 | (19) |
|
6.1.1 Central tendency of a distribution |
|
|
153 | (3) |
|
|
156 | (4) |
|
|
160 | (2) |
|
6.1.4 Discrete distributions |
|
|
162 | (3) |
|
6.1.5 Quick descriptive analysis |
|
|
165 | (1) |
|
|
166 | (2) |
|
|
168 | (2) |
|
6.2 Describing Relationships Between Variables |
|
|
170 | (6) |
|
6.2.1 Correlation coefficient |
|
|
171 | (3) |
|
|
174 | (2) |
|
6.3 Summarizing Variables Across Groups |
|
|
176 | (3) |
|
|
179 | (4) |
|
7 Simple (Bivariate) Regression |
|
|
183 | (20) |
|
7.1 What Is Regression Analysis? |
|
|
184 | (1) |
|
7.2 Simple Linear Regression Analysis |
|
|
185 | (11) |
|
7.2.1 Ordinary least squares |
|
|
188 | (2) |
|
|
190 | (1) |
|
Residual standard deviation |
|
|
190 | (1) |
|
Coefficient of determination (R2) |
|
|
191 | (2) |
|
7.2.3 Hypothesis test for slope coefficient |
|
|
193 | (1) |
|
|
193 | (2) |
|
The confidence interval approach |
|
|
195 | (1) |
|
7.2.4 Prediction in linear regression |
|
|
195 | (1) |
|
|
196 | (4) |
|
|
200 | (3) |
|
8 Multiple Linear Regression |
|
|
203 | (26) |
|
8.1 Multiple Regression Analysis |
|
|
204 | (9) |
|
|
205 | (1) |
|
8.1.2 Goodness of fit and the F test |
|
|
206 | (1) |
|
|
207 | (1) |
|
8.1.4 Partial slope coefficient |
|
|
208 | (1) |
|
8.1.5 Prediction in multiple regression |
|
|
209 | (1) |
|
8.1.6 Standardization and relative importance |
|
|
210 | (1) |
|
8.1.7 Regression assumptions and diagnostics |
|
|
211 | (2) |
|
|
213 | (12) |
|
|
225 | (4) |
|
9 Dummy-Variable Regression |
|
|
229 | (30) |
|
9.1 Why Dummy-Variable Regression? |
|
|
230 | (3) |
|
9.1.1 Creating dummy variables |
|
|
231 | (2) |
|
9.1.2 The logic behind dummy-variable regression |
|
|
233 | (1) |
|
9.2 Regression With One Dummy Variable |
|
|
233 | (3) |
|
|
234 | (2) |
|
9.3 Regression With One Dummy Variable and a Covariate |
|
|
236 | (3) |
|
|
237 | (2) |
|
9.4 Regression With More Than One Dummy Variable |
|
|
239 | (10) |
|
|
241 | (1) |
|
9.4.2 Comparing the included groups |
|
|
242 | (1) |
|
Changing the reference group |
|
|
243 | (1) |
|
|
244 | (3) |
|
9.4.3 Pairwise multiple comparison adjustment |
|
|
247 | (2) |
|
9.5 Regression With More Than One Dummy Variable and a Covariate |
|
|
249 | (2) |
|
|
250 | (1) |
|
9.6 Regression With Two Separate Sets of Dummy Variables |
|
|
251 | (5) |
|
|
253 | (3) |
|
|
256 | (3) |
|
10 Moderation/Interaction Analysis Using Regression |
|
|
259 | (28) |
|
10.1 Interaction/Moderation Effects |
|
|
260 | (2) |
|
10.2 Product-Term Approach |
|
|
262 | (2) |
|
10.3 Interaction Between a Continuous Predictor and a Dummy Moderator |
|
|
264 | (4) |
|
|
266 | (2) |
|
10.4 Interaction Between a Continuous Predictor and a Continuous Moderator |
|
|
268 | (5) |
|
|
269 | (4) |
|
10.5 Interaction Between a Dummy Predictor and a Dummy Moderator |
|
|
273 | (3) |
|
|
273 | (3) |
|
10.6 Interaction Between a Continuous Predictor and a Polytomous Moderator |
|
|
276 | (6) |
|
|
277 | (5) |
|
10.7 Additional Considerations |
|
|
282 | (1) |
|
10.7.1 Significant versus non-significant interactions |
|
|
282 | (1) |
|
10.7.2 Centring and standardization |
|
|
282 | (1) |
|
|
283 | (4) |
|
|
287 | (34) |
|
11.1 Simple Logistic Regression in R |
|
|
292 | (9) |
|
11.1.1 Interpretation of coefficients in logistic regression |
|
|
295 | (4) |
|
11.1.2 Goodness-of-fit and model selection |
|
|
299 | (2) |
|
11.2 Multiple Logistic Regression |
|
|
301 | (10) |
|
11.3 Logistic Regression for Classification |
|
|
311 | (6) |
|
|
317 | (4) |
|
12 Multilevel and Longitudinal Analysis |
|
|
321 | (30) |
|
12.1 Representation of Nested Data Structures |
|
|
324 | (5) |
|
12.1.1 Converting between wide and long format |
|
|
326 | (3) |
|
12.2 Complete, Partial, and No Pooling |
|
|
329 | (7) |
|
12.3 Significance Testing for Linear Mixed Models |
|
|
336 | (7) |
|
12.3.1 Mixing fixed and random effects |
|
|
340 | (3) |
|
12.4 Model Comparison for Longitudinal Mixed Models |
|
|
343 | (5) |
|
|
348 | (3) |
|
|
351 | (24) |
|
13.1 What Is Factor Analysis? |
|
|
352 | (3) |
|
13.1.1 What is factor analysis used for? |
|
|
354 | (1) |
|
13.2 The Factor Analysis Process |
|
|
355 | (8) |
|
13.2.1 Determining the number of factors |
|
|
355 | (1) |
|
|
356 | (1) |
|
|
356 | (1) |
|
|
356 | (1) |
|
|
356 | (1) |
|
13.2.2 Extracting the factors |
|
|
357 | (2) |
|
13.2.3 Rotating the factors |
|
|
359 | (3) |
|
13.2.4 Refining and interpreting the factors |
|
|
362 | (1) |
|
13.3 Composite Scores and Reliability Tests |
|
|
363 | (1) |
|
|
364 | (7) |
|
13.4.1 Determining the number of factors |
|
|
365 | (2) |
|
13.4.2 Extracting with rotation |
|
|
367 | (4) |
|
|
371 | (4) |
|
14 Structural Equation Modelling |
|
|
375 | (32) |
|
14.1 What Is Structural Equation Modelling? |
|
|
376 | (3) |
|
14.1.1 Types of structural equation modelling |
|
|
377 | (2) |
|
14.2 Confirmatory Factor Analysis |
|
|
379 | (15) |
|
14.2.1 Model specification |
|
|
379 | (2) |
|
14.2.2 Model identification |
|
|
381 | (2) |
|
14.2.3 Parameter estimation |
|
|
383 | (1) |
|
|
383 | (1) |
|
Interpreting parameter estimates |
|
|
383 | (4) |
|
|
387 | (1) |
|
|
387 | (2) |
|
Standardized root mean square residual |
|
|
389 | (1) |
|
Root mean squared error of approximation |
|
|
390 | (1) |
|
|
390 | (1) |
|
|
391 | (1) |
|
14.2.5 Model modification |
|
|
392 | (2) |
|
14.3 Latent Path Analysis |
|
|
394 | (8) |
|
14.3.1 Specification of the LPA model |
|
|
395 | (1) |
|
|
395 | (4) |
|
|
399 | (3) |
|
|
402 | (5) |
|
|
407 | (30) |
|
15.1 Bayesian Data Analysis |
|
|
410 | (2) |
|
15.2 Bayesian Data Analysis in R |
|
|
412 | (2) |
|
15.3 Example Analysis in R |
|
|
414 | (18) |
|
|
415 | (2) |
|
15.3.2 Bayesian estimation of regression coefficients |
|
|
417 | (5) |
|
15.3.3 Bayesian model selection |
|
|
422 | (5) |
|
|
427 | (2) |
|
15.3.5 Choice of prior distribution |
|
|
429 | (3) |
|
|
432 | (5) |
Bibliography |
|
437 | (6) |
Index |
|
443 | |