Exam PA Study Manual
2020
1 What’s in this book 5
1.1 About the author . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 The exam 6
3 Prometric Demo 7
4 You already know what learning is 8
5 Getting started 9
5.1 Download the data . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5.2 Download ISLR . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.3 New users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
6 R programming 11
6.1 Notebook chunks . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.2 Basic operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6.3 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
6.4 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
6.5 Data frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
6.6 Pipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6.7 The SOA’s code doesn’t use pipes or dplyr, so can I skip learning
this? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7 Data manipulation 25
7.1 Look at the data . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
7.2 Transform the data . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
8 Visualization 35
8.1 Create a plot object (ggplot) . . . . . . . . . . . . . . . . . . . . 35
8.2 Add a plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
8.3 Data manipulation chaining . . . . . . . . . . . . . . . . . . . . . 39
9 Introduction to Modeling 41
9.1 Model Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
9.2 Ordinary least squares (OLS) . . . . . . . . . . . . . . . . . . . . 42
9.3 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
10 Generalized linear models (GLMs) 49
10.1 The generalized linear model . . . . . . . . . . . . . . . . . . . . 50
10.2 Interpretation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
10.3 Residuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
10.4 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
10.5 Combinations of Link and Response Family Examples . . . . . . 55
10.6 Log transforms of continuous predictors . . . . . . . . . . . . . . 70
10.7 Reference levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
10.8 Interactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
10.9 Poisson Regression . . . . . . . . . . . . . . . . . . . . . . . . . . 72
10.10Offsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
10.11Tweedie regression . . . . . . . . . . . . . . . . . . . . . . . . . . 74
10.12Stepwise subset selection . . . . . . . . . . . . . . . . . . . . . . . 74
10.13Advantages and disadvantages . . . . . . . . . . . . . . . . . . . . 76
11 Logistic Regression 77
11.1 Model form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
11.2 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
11.3 Classification metrics . . . . . . . . . . . . . . . . . . . . . . . . . 83
12 Penalized Linear Models 88
12.1 Ridge Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
12.2 Lasso . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
12.3 Elastic Net . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
12.4 Advantages and disadvantages . . . . . . . . . . . . . . . . . . . . 90
12.5 Example: Ridge Regression . . . . . . . . . . . . . . . . . . . . . 90
12.6 Example: The Lasso . . . . . . . . . . . . . . . . . . . . . . . . . 97
12.7 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
13 Tree-based models 101
13.1 Decision Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
13.2 Ensemble learning . . . . . . . . . . . . . . . . . . . . . . . . . . 108
13.3 Random Forests . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
13.4 Gradient Boosted Trees . . . . . . . . . . . . . . . . . . . . . . . 115
13.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
14 Unsupervised Learning 125
14.1 Principal Componant Analysis (PCA) . . . . . . . . . . . . . . . 125
14.2 Clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
14.3 Hierarchical Clustering . . . . . . . . . . . . . . . . . . . . . . . . 142


雷达卡



京公网安备 11010802022788号







