Regression with R and Python: Description, Prediction, and Causal Analysis in Social Science and Medicine
Forthcoming with Springer, 2026
This forthcoming textbook introduces regression analysis through three connected goals: description, prediction, and causal analysis. It combines statistical foundations with practical implementation in both R and Python, and is designed for readers who want to connect regression theory with modern empirical practice in social science and medicine.
The book is forthcoming in Springer Texts in Statistics, with publication scheduled for 2027.
Publisher and ISBNs
- Springer book page
- Hardcover ISBN: 978-3-032-40087-1
- eBook ISBN: 978-3-032-40088-8
- Softcover ISBN: 978-3-032-40090-1 (scheduled for 2028)
Related Chinese Textbook and Course
appliedeconometricsbook.com — Applied Econometrics with R and Python
The Chinese-language companion course for Applied Econometrics, by Jiajing Sun and Per Johansson, provides thirteen chapters of teaching materials, page-by-page slides, video lectures, and links to code and data. It is a related Chinese-language resource, alongside this book’s English companion website, regressionbook.com.
Endorsements
“This is a comprehensive and up-to-date introduction to regression, one of our most powerful econometric tools.”
Joshua Angrist
“A timely book that teaches not only how to analyse data, but how data become knowledge.”
Wolfgang Karl Härdle
“This is a rare regression textbook that treats description, prediction, and causal inference as genuinely distinct tasks requiring different assumptions, rather than three flavours of the same exercise.”
Oliver Linton
Read the full endorsements on the official companion website.
Companion Website, Code, and Resources
The official companion website for the book is now live:
Official companion website: regressionbook.com
The website provides structured learning materials for all 14 chapters, including chapter guides, core concepts and formulas, empirical applications, diagnostic methods, exercises, and accompanying R and Python code. It will continue to be refined and expanded as the book moves towards publication.
The book has a companion GitHub repository with chapter workbooks and reproducible code examples:
GitHub repository: Regression_with_R_and_Python
The repository includes chapter-level RMarkdown/HTML workbooks, runnable R examples, Python appendix code, and dependency notes for readers who want to reproduce examples or use the book in teaching.
Book Structure
The book is organized around the progression from descriptive regression to predictive modeling and causal analysis:
- Introduction: description, prediction, causality, and how these goals differ in empirical work.
- Covariation in data: Pearson correlation, Spearman rank correlation, and simple linear regression.
- Basic probability theory and statistical inference: probability, random variables, estimators, hypothesis testing, and confidence intervals.
- Correlation and inference about a population: sampling, population inference, and dependence beyond simple correlation.
- The simple linear regression model: coefficient interpretation, uncertainty, finite-sample inference, and asymptotic inference.
- Multiple linear regression: the general model, regression anatomy, partial regression plots, R-squared, F-tests, conditional expectation uncertainty, and residual analysis.
- Nonlinear functional form: qualitative regressors, collinearity, logarithms, interactions, and an applied example on weather and air pollution.
- Regression analysis with dependent error terms: clustered data, panel data, fixed effects, and presentation of regression results.
- Binary dependent variables: logistic regression, maximum likelihood estimation, inference, and comparison with the linear probability model.
- Prediction: overfitting, train-test splits, cross-validation, high-dimensional predictors, tree-based regression, and a housing-price application.
- Nonparametric regression methods: regressograms and regression discontinuity as a nonparametric application.
- Time series analysis: components of macroeconomic time series, stationarity, and autoregressive regression.
- Causal analysis: randomized experiments, quasi-experiments, Rubin’s causal model, difference-in-differences, instrumental variables, and regression discontinuity.
- Key concepts: a synthesis of the central empirical and statistical ideas used throughout the book.
Appendices
The appendices provide supporting material for computation, mathematics, and econometric foundations:
- Appendix A: The R Programming Language covers R fundamentals, probability distributions, tidyverse tools, and API-based data access.
- Appendix B: The Python Programming Language covers Python fundamentals, probability distributions, the Python data ecosystem, and API-based data access.
- Appendix C: Mathematical appendix covers matrix algebra, probability theory, large-sample theory, and optimization basics.
- Appendix D: Ordinary Least Squares (OLS) develops OLS algebra, inference with experimental data, stochastic covariates, and dependent error terms.
- Appendix E: Generalized Least Squares (GLS) covers GLS for cross-sectional data, panel and clustered data, and weighting under stratified probability sampling.
- Appendix F: Instrumental variables and 2SLS covers endogeneity, instruments, first-stage relevance, reduced forms, two-stage least squares, inference, and weak instruments.
Full book materials are not hosted on this website due to copyright restrictions.
Recommended citation: Johansson, P., & Sun, J. (forthcoming 2027). "Regression with R and Python: Description, Prediction, and Causal Analysis in Social Science and Medicine." Springer Texts in Statistics. Springer. Hardcover ISBN 978-3-032-40087-1; eBook ISBN 978-3-032-40088-8.
