Skip to the content.

Exam PA, worked in the open

These notes are an open-source record of preparing for the Society of Actuaries Predictive Analytics exam, written for the June 2019 sitting. The written notes are a PDF and a OneNote package dated June 30, 2019, covering exam content, strategy, modeling methods, and code snippets. Exam PA was a five-hour computer-based project. A candidate received a business problem and a data set, then had to explore the data, fit and compare models in R, and write a report a non-modeler could use. The modules behind that sitting covered data types and graphics, principal components and clustering, generalized linear models, trees and random forests, and how to validate a model and explain it. The notes come from a first attempt that scored 7, about 100 hours of study, taken in the same window as a first sitting of STAM.

The code uses the exam stack. dplyr and ggplot2 handle cleaning and graphics. ggplot2 is the graphics tool in Healy (2018), the visualization text on the current syllabus, and the R the modules expect is in Lander (2017). caret builds stratified train and test splits (Kuhn 2008). rpart fits trees from the CART procedure (Breiman et al. 1984). glm, and glmnet on the student-success solution, fit generalized linear models (Nelder and Wedderburn 1972; Friedman, Hastie, and Tibshirani 2010). Factor coding is part of the model. Reference levels move to the most common category so the intercept is a real baseline. Thin levels are collapsed before they become dummy variables. caret::dummyVars is run at full rank when a factor is expanded, so the design matrix does not pick up a redundant column.

Hospital readmissions is a binary classification. The target is Readmission.Status. The problem states that the LACE index has an AUC of 0.70, and the task is to beat it with a GLM on patient-level data. Three submissions clean length of stay, age, emergency-room use, and HCC risk score, then fit binomial GLMs. The last submission compares logit, probit, cauchit, and complementary log-log links, with a Gender-by-Race interaction as a worked example. Logit and probit are the binomial links in Nelder and Wedderburn (1972). Complementary log-log and cauchit are the other links in R’s binomial family. Discrimination is read from an ROC curve and AUC (Fawcett 2006). The cost task prices a missed readmission at 25 and an intervention at 2. The code in submission 3 starts from a cutoff of 0.075. On the sample solution’s cost table, 0.08 is lower than 0.075. That comparison is the one that matters when the two errors have different prices (Fawcett 2006).

The December 2018 Miners Union practice predicts injury counts, with employee hours as exposure. That sitting used a less structured project format than June 2019. Poisson trees go through rpart’s poisson method, with cbind(EMP_HRS_TOTAL/2000, NUM_INJURIES) on the left-hand side, then pruning on cross-validated error. The Poisson GLM uses a log link and an offset of log(hours/2000), so the coefficients are log injury rates and a response-scale prediction is an expected count. An offset of log exposure is the usual way to turn a Poisson GLM into a rate model (Goldburd et al. 2025). Fit is scored with RMSE, MAE, and a Poisson loglikelihood that replaces nonpositive tree predictions before the log is taken.

Student academic success is the first form of the June 2019 sample project, before the report structure was tightened. The file starts with 585 students, flagged pass or fail from final grade G3, with pass at 10 or above. In the official solution and the template, period grades G1 and G2, and absences, are dropped so they cannot leak the outcome. Submission 1’s GLM still uses absences. The comparison is a classification tree (Breiman et al. 1984), a caret random forest (Breiman 2001; Kuhn 2008), and a binomial logit GLM (James et al. 2021). The solution file also fits an L1-penalized logistic regression in glmnet (alpha = 1), with the penalty chosen by cross-validation (Friedman, Hastie, and Tibshirani 2010). Tay, Narasimhan, and Hastie (2023) later extended that coordinate-descent path to the rest of the GLM family. The syllabus has moved since 2019 (Society of Actuaries 2026). Check the SOA Exam PA page before using these notes for a current sitting.

Recent articles

These notes record the June 2019 sitting. The current exam is the April 2026 syllabus: a three-hour-and-thirty-minute written exam on a computer with Word and Excel. Starting with the April 2023 administration, R and RStudio are not available, and the exam supplies the code and output each task needs (Society of Actuaries 2026). Required reading is still James, Witten, Hastie, and Tibshirani, either the 2013 first edition or the 2021 second edition, plus Frees (2010), Lander (2017), and Healy (2018). The syllabus table is the list of assigned sections for a current sitting.

The reference list also covers the public files compared with the three practice projects under What the files show.

References

  1. Adams, Philip L., Cynthia Edwalds, Brian Holland, Michael Niemerg, and Haofeng Yu. 2024. “A Predictive Analytics Framework: A Reusable Workflow for Experience Analysis.” Society of Actuaries Research Institute, November. https://www.soa.org/resources/research-reports/2024/predictive-analytics-framework/
  2. Agency for Healthcare Research and Quality. 2026. “Introduction to the HCUP Nationwide Readmissions Database (NRD) 2023.” Issued September 2026. The 2023 NRD was released September 16, 2026. https://hcup-us.ahrq.gov/db/nation/nrd/NRDIntroduction2023.pdf. Release note: https://hcup-us.ahrq.gov/
  3. Almeida, Tiago, Plinio Moreno, and Catarina Barata. 2025. “Prediction of 30-day Hospital Readmission with Clinical Notes and EHR Information.” arXiv:2503.23050. https://arxiv.org/abs/2503.23050
  4. Breiman, Leo. 2001. “Random Forests.” Machine Learning 45 (1): 5–32. https://doi.org/10.1023/A:1010933404324
  5. Breiman, Leo, Jerome Friedman, Richard Olshen, and Charles Stone. 1984. Classification and Regression Trees. Belmont, CA: Wadsworth International Group.
  6. Centers for Medicare & Medicaid Services. 2026. “Hospital Readmissions Reduction Program.” Provider Data Catalog, dataset 9n3s-kdb3. Released August 13, 2026. https://data.cms.gov/provider-data/dataset/9n3s-kdb3. Performance period: https://data.cms.gov/provider-data/topics/hospitals/linking-quality-to-payment
  7. Cortez, Paulo. 2008. “Student Performance.” Dataset. UCI Machine Learning Repository. https://doi.org/10.24432/C5TG7T
  8. Cortez, Paulo, and Alice Silva. 2008. “Using Data Mining to Predict Secondary School Student Performance.” In Proceedings of the 5th Future Business Technology Conference (FUBUTEC 2008), edited by A. Brito and J. Teixeira, 5–12. Porto: EUROSIS. ISBN 978-9077381-39-7. https://hdl.handle.net/1822/8024
  9. El Kharoua, Rabie. 2024. “Students Performance Dataset.” Kaggle. https://doi.org/10.34740/KAGGLE/DS/5195702. OpenML data set 46255: https://www.openml.org/d/46255
  10. Fawcett, Tom. 2006. “An Introduction to ROC Analysis.” Pattern Recognition Letters 27 (8): 861–874. https://doi.org/10.1016/j.patrec.2005.10.010
  11. Frees, Edward W. 2010. Regression Modeling with Actuarial and Financial Applications. New York: Cambridge University Press. ISBN 978-0-521-13596-2.
  12. Friedman, Jerome, Trevor Hastie, and Robert Tibshirani. 2010. “Regularization Paths for Generalized Linear Models via Coordinate Descent.” Journal of Statistical Software 33 (1): 1–22. https://doi.org/10.18637/jss.v033.i01
  13. Goldburd, Mark, Anand Khare, Dan Tevet, and Dmitriy Guller. 2025. Generalized Linear Models for Insurance Rating. 2nd ed. (2025 revision). CAS Monograph Series Number 5. Arlington, VA: Casualty Actuarial Society. https://www.casact.org/monograph/cas-monograph-no-5
  14. Healy, Kieran. 2018. Data Visualization: A Practical Introduction. Princeton, NJ: Princeton University Press. ISBN 978-0-691-18162-2. https://socviz.co/
  15. James, Gareth, Daniela Witten, Trevor Hastie, and Robert Tibshirani. 2021. An Introduction to Statistical Learning: With Applications in R. 2nd ed. New York: Springer. The 2013 first edition remains acceptable on the exam. https://www.statlearning.com/
  16. krishal07. n.d. “Student Performance.” Dataset. Hugging Face. https://huggingface.co/datasets/krishal07/student-performance
  17. Kuhn, Max. 2008. “Building Predictive Models in R Using the caret Package.” Journal of Statistical Software 28 (5): 1–26. https://doi.org/10.18637/jss.v028.i05
  18. Lander, Jared P. 2017. R for Everyone: Advanced Analytics and Graphics. 2nd ed. Boston: Addison-Wesley. ISBN 978-0-13-454692-6.
  19. Mine Safety and Health Administration. 2026a. “Accident, Injuries and Illnesses Data Set.” Collected on Form 7000-1. https://www.msha.gov/data-and-reports/data-sources-and-calculators/data-resources/mdsrg/accident-injuries-and-illnesses-data-set. Field definitions: https://arlweb.msha.gov/OpenGovernmentData/DataSets/Accidents_Definition_File.txt
  20. Mine Safety and Health Administration. 2026b. “Employment Production (Yearly) Data Set.” Collected on Form 7000-2. https://www.msha.gov/data-and-reports/data-sources-and-calculators/data-resources/mdsrg/employment-production-yearly-data-set
  21. Mine Safety and Health Administration. 2026c. “Part 50 Data: Accident, Injury and Illness Information.” Self-extracting files. https://arlweb.msha.gov/STATS/PART50/p50y2k/AITABLE.HTM
  22. Nelder, J. A., and R. W. M. Wedderburn. 1972. “Generalized Linear Models.” Journal of the Royal Statistical Society, Series A 135 (3): 370–384. https://doi.org/10.2307/2344614
  23. Patil, Sandeep, Michael Descy, and Tricia Matson. 2025. “Predictive Analytics in Life and Annuity Reinsurance.” Society of Actuaries Research Institute, June. https://www.soa.org/globalassets/assets/files/resources/research-report/2025/predictive-life-reinsurance/2025-06-ml242.pdf
  24. Society of Actuaries. 2026. “Predictive Analytics Exam—April 2026.” Syllabus. https://www.soa.org/globalassets/assets/files/edu/2026/spring/syllabi/2026-04-exam-pa-syllabus.pdf
  25. Tay, J. Kenneth, Balasubramanian Narasimhan, and Trevor Hastie. 2023. “Elastic Net Regularization Paths for All Generalized Linear Models.” Journal of Statistical Software 106 (1): 1–31. https://doi.org/10.18637/jss.v106.i01

What the files show

The three projects are not one answer copied three times. Counts, cutoffs, and fit statistics below come from the problem statements, the sample solutions, and the R files in this repository. Each project then records what the public data file for that subject contains.

Hospital readmissions

The problem statement reports the LACE index at an AUC of 0.70 and asks for a GLM that does better. The sample solution’s first logit has a test AUC of 0.7324. After a thin factor level is collapsed, the final model’s AUC is 0.7334, which that write-up treats as better than LACE on this data.

The cost arithmetic is small and explicit. A missed readmission costs 25. An intervention costs 2. The sample solution counts 8,409 readmissions, so doing nothing costs 210,225. Intervening on every discharge costs 2 × 66,776 = 133,552. The task code in submission 3 starts the cutoff at 0.075. On the sample solution’s table, a cutoff of 0.08 costs 106,002 and a cutoff of 0.075 costs 106,100. At 0.08 the solution predicts 39,301 readmissions, 59% of discharges, and says spending 2 to save 25 is a reason to flag more patients than the base rate. Of the 8,409 who were readmitted, 7,313 receive the intervention. Submission 2 chooses a probit (test AUC 0.7446) over a logit (test AUC 0.7447) and also sets the cutoff at 0.08, where the cost is $105,844. Submission 1 prices the intervention at 4 and tries a cutoff of 0.30. The cutoff is an input, not a property of the GLM.

The practice file is one row per discharge, with a binary readmission flag. CMS publishes the Hospital Readmissions Reduction Program as a hospital-level table. Dataset 9n3s-kdb3, released August 13, 2026, has 18,330 rows and 12 columns. Each row is a hospital and one measure: heart attack, heart failure, pneumonia, COPD, hip or knee replacement, or coronary artery bypass. The excess readmission ratio on that row is the hospital’s predicted 30-day rate divided by the rate expected at an average hospital with similar patients. The FY 2026 performance period is July 1, 2021, through June 30, 2024 (Centers for Medicare & Medicaid Services 2026). The practice logit is fit to patient rows, and that CMS file has none.

The all-payer discharge file is the AHRQ HCUP Nationwide Readmissions Database. AHRQ released the 2023 NRD on September 16, 2026. From that year the file is limited to adults age 18 and older. The core file has 13,201,031 unweighted discharges from 2,152 hospitals in 28 states. The discharge weight brings the national estimate to 28,777,345 discharges (Agency for Healthcare Research and Quality 2026). A 30-day readmission flag has to be built from those rows. The file does not arrive with the practice problem’s Readmission.Status column.

Almeida, Moreno, and Barata (2025) fit a graph neural network to MIMIC-IV discharge notes and structured records and report an AUROC of 0.72 and a balanced accuracy of 66.7% for 30-day readmission. That score is for Beth Israel Deaconess admissions. It is a different model from the binomial GLM in this repository, and it is a different quantity from a hospital excess readmission ratio.

Miners Union

The December 2018 problem asks for the injury rate per 2,000 employee hours. Submission 2’s tree uses cbind(EMP_HRS_TOTAL/2000, NUM_INJURIES) with method = "poisson", and the Poisson GLM uses offset = log(EMP_HRS_TOTAL/2000). The same file multiplies every PCT_ column by EMP_HRS_TOTAL, turning a share of hours into hours. The notes in that file record a rank-deficient fit and huge coefficients on the hours variables, and they tie that to the shares summing to 1 while the offset already carries exposure. The metric table in the submission PDF gives the tree an RMSE of 1.47, an R2 of 0.66, and an MAE of 0.41. The row that log-transforms hours for every mine type has the same RMSE, an R2 of 0.69, and an MAE of 0.39.

The chunk that is supposed to score the final GLM does not score it. glm_final is fit on every row, df_glm. The next line calls predict on the previous object, glm, with newdata = df_glm, and eval_model then pairs those predictions with df_glm_test$NUM_INJURIES. The two vectors are not the same length, so that chunk is not a test-set score for the final model. The MAE figures above are the ones printed in the submission PDF.

MSHA publishes the two pieces of that file as separate tables. The Accidents, Injuries and Illnesses data set is Form 7000-1: one reported incident per row from January 1, 2000, keyed by DOCUMENT_NO. NO_INJURIES may be zero when the incident had no reportable injury. The definition file says to join that table to annual employment and production on mine ID and calendar year (Mine Safety and Health Administration 2026a). Hours are Form 7000-2. The yearly file stores ANNUAL_HOURS by calendar year, mine ID, and subunit, and it keeps a subunit only when average quarterly employment is greater than zero (Mine Safety and Health Administration 2026b). Those subunit codes are the PCT_ columns in submission 2: underground (01), surface at an underground mine (02), strip, quarry, or open pit (03), auger (04), culm bank or refuse pile (05), dredge (06), other surface (12), independent shop or yard (17), mill or preparation plant (30), and office (99). The practice CSV has already summed the hours into EMP_HRS_TOTAL and stored the subunit split as shares. The offset log(EMP_HRS_TOTAL/2000) is the rate per 2,000 hours after the hours have been attached. The shares sum to 1, so they repeat information the offset already carries.

The Part 50 self-extracting accident files are another extract of the same reports. MSHA refreshes them about six weeks after each quarter, and a raw file can include injuries past the closed quarter and can disagree with the published quarter total. The second-quarter 2026 files were updated September 1, 2026. The 2025 year-end files were updated September 25, 2026 (Mine Safety and Health Administration 2026c).

Student academic success

The official solution starts from 585 students and drops records whose final grade G3 is outside 0 to 20, leaving 568. It keeps 38 students with a grade of 0, and notes that none have grades 1 through 3, so 0 may mean something other than a poor mark. Pass is G3 of 10 or above. Because 64% pass, predicting that everyone passes is already right 64% of the time. On a held-out sample of 140 students, of whom 64% also passed, the solution’s prediction is right 73% of the time. The official solution and the template delete G1, G2, and absences before any model is fit. Submission 1 leaves that deletion as a comment. It keeps rows with absences under 40 and with positive G1, G2, and G3, which drops the zero final grades the official solution keeps, and its logit still uses absences as a predictor. A model that sees mid-course grades, or absences accumulated during the term, is answering a different question from one that only sees what was known at the start.

The names in the official solution, G1, G2, G3, absences, age, Medu, Fedu, and Dalc, are the names in Cortez and Silva (2008). G3 is the final grade on a 0 to 20 scale. Their binary outcome is pass when G3 is 10 or above, the same cut the official solution uses. The records are the 2005–2006 school year at two public schools in the Alentejo region of Portugal, built from paper school reports (the three period grades and the absences) and a questionnaire. The questionnaire was answered by 788 students. 111 answers were dropped because they could not be matched to a report. The published course files contain 395 mathematics students and 649 Portuguese-language students. UCI dataset 320 is that Portuguese file: 649 rows and 30 features (Cortez 2008). The UCI note says G3 is strongly correlated with G1 and G2, and that predicting G3 without those two grades is harder and more useful. Their setup A uses every predictor except G3. Setup B drops G2. Setup C drops G2 and G1 and still keeps absences. In that last setup, past failures and absences are among the variables a random forest ranks highest. student_grades.csv in this repository has 585 rows. The mathematics file has 395 and the Portuguese file has 649, so a fit on this CSV is a fit on a different extract. The official solution then drops absences as well as G1 and G2. Setup C in the paper still uses absences.

Later tables that reuse the name “student performance” are different files. OpenML data set 46255, uploaded June 30, 2024, has a GPA, a grade class, weekly study hours, and yes-or-no flags for tutoring, sports, music, and volunteering (El Kharoua 2024). It has no G1, G2, or G3. The Hugging Face dataset krishal07/student-performance contains 10,000,000 rows the card describes as synthetically generated, split 8,000,774, 999,229, and 999,997, with a 0 to 4 GPA and an attendance rate. The card states that the file contains no real students (krishal07 n.d.).

Videos

Sam Castillo's Exam PA videos: study tips, a live webinar, and worked practice-exam solutions, including the hospital readmissions project in this repository.