Advanced Data Analysis

Advanced statistical modeling and machine learning in R: GAMs, boosting, random forests, deep learning, clustering, and reinforcement learning — with reproducible code.
Author
Published

November 20, 2026

Preface

This is the second book in the Data Analysis series. Like its companion, it is an effort to simplify and demystify data analysis, making it accessible to a wide audience. Writing it has been as much a learning journey for me as I hope it will be for you.

The first book, A Guide on Data Analysis, is concerned with interpretation and causal inference: understanding why, and estimating effects we can defend. This book turns to the other half of the discipline, prediction. The principles and philosophy are the same; the goal is different.


This book differs from the first one in emphasis: it is about building models that predict well, whereas the first book is about interpreting relationships and defending causal claims. The opening chapters develop that distinction (prediction versus estimation) in full; the preface only needs to flag it.


How to cite this book

This is the open online edition. If you reference it, please also consider citing the companion volume, Foundations of Data Analysis (Springer Cham, 2025).

  1. APA (7th edition)

Nguyen, M. Advanced data analysis. Retrieved from https://advanced-data-analysis.netlify.app/

  1. MLA (8th edition)

Nguyen, Mike. Advanced Data Analysis. https://advanced-data-analysis.netlify.app/.

  1. Chicago (17th edition)

Nguyen, Mike. Advanced Data Analysis. https://advanced-data-analysis.netlify.app/.

  1. Harvard

Nguyen, M. Advanced Data Analysis. Available at: https://advanced-data-analysis.netlify.app/

@book{Nguyen_AdvancedDataAnalysis,
  author = {Nguyen, Mike},
  title  = {Advanced Data Analysis},
  url    = {https://advanced-data-analysis.netlify.app/}
}

Use this book in your AI assistant

This book is indexed by the Research Methods Library, a Model Context Protocol (MCP) server that makes it available to AI assistants. Given a research question, an assistant connected to the server recommends candidate study designs, states their identifying assumptions, returns runnable R and Python code, and cites the sections of this book and of the author’s other works on which each answer draws. Access is free and requires no account or API key.

Endpoint: https://research-methods-mcp.vercel.app/mcp?src=book-advanced-data-analysis

  • Claude (web, desktop, and mobile): Settings → Connectors → Add custom connector; enter the endpoint.
  • Claude Code: claude mcp add --transport http research-methods "https://research-methods-mcp.vercel.app/mcp?src=book-advanced-data-analysis"
  • ChatGPT: Settings → enable developer mode → add a custom connector of type MCP server with the endpoint and no authentication.
  • Cursor and Visual Studio Code: Add to Cursor or Install in VS Code.

Configuration for other MCP clients is described on the server’s website.


Code Replication

This book was built with R version 4.4.3 (2025-02-28 ucrt) and the following packages:


#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.3 (2025-02-28 ucrt)
#>  os       Windows 11 x64 (build 26300)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.utf8
#>  ctype    English_United States.utf8
#>  tz       America/Los_Angeles
#>  date     2026-11-18
#>  pandoc   3.6.3 @ C:\\Program Files\\Quarto\\bin\\tools/ (via rmarkdown)
#>  quarto   NA @ C:\\PROGRA~1\\Quarto\\bin\\quarto.exe
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cachem        1.1.0   2024-05-16 [1] CRAN (R 4.4.2)
#>  cli           3.6.5   2025-04-23 [1] CRAN (R 4.4.3)
#>  devtools      2.4.6   2025-10-03 [1] CRAN (R 4.4.3)
#>  digest        0.6.37  2024-08-19 [1] CRAN (R 4.4.2)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.4.2)
#>  evaluate      1.0.5   2025-08-27 [1] CRAN (R 4.4.3)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.2)
#>  fs            1.6.6   2025-04-12 [1] CRAN (R 4.4.3)
#>  glue          1.8.0   2024-09-30 [1] CRAN (R 4.4.2)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.2)
#>  htmlwidgets   1.6.4   2023-12-06 [1] CRAN (R 4.4.2)
#>  jsonlite      2.0.0   2025-03-27 [1] CRAN (R 4.4.3)
#>  knitr         1.50    2025-03-16 [1] CRAN (R 4.4.3)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.2)
#>  magrittr      2.0.4   2025-09-12 [1] CRAN (R 4.4.3)
#>  memoise       2.0.1   2021-11-26 [1] CRAN (R 4.4.2)
#>  pkgbuild      1.4.8   2025-05-26 [1] CRAN (R 4.4.3)
#>  pkgload       1.4.1   2025-09-23 [1] CRAN (R 4.4.3)
#>  purrr         1.1.0   2025-07-10 [1] CRAN (R 4.4.3)
#>  R6            2.6.1   2025-02-15 [1] CRAN (R 4.4.3)
#>  remotes       2.5.0   2024-03-17 [1] CRAN (R 4.4.2)
#>  rlang         1.1.6   2025-04-11 [1] CRAN (R 4.4.3)
#>  rmarkdown     2.30    2025-09-28 [1] CRAN (R 4.4.3)
#>  sessioninfo   1.2.3   2025-02-05 [1] CRAN (R 4.4.3)
#>  usethis       3.2.1   2025-09-06 [1] CRAN (R 4.4.3)
#>  vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.4.2)
#>  xfun          0.52    2025-04-02 [1] CRAN (R 4.4.3)
#> 
#>  [1] C:/Program Files/R/R-4.4.3/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────