Tidy Finance with R
Kaup valmöguleikar
This textbook shows how to bring theoretical concepts from finance and econometrics to the data. Focusing on coding and data analysis with R, we show how to conduct research in empirical finance from scratch. We start by introducing the concepts of tidy data and coding principles using the tidyverse family of R packages. Code is provided to prepare common open-source and proprietary financial data sources (CRSP, Compustat, Mergent FISD, TRACE) and organize them in a database.
We reuse these data in all the subsequent chapters, which we keep as self-contained as possible. The empirical applications range from key concepts of empirical asset pricing (beta estimation, portfolio sorts, performance analysis, Fama-French factors) to modeling and machine learning applications (fixed effects estimation, clustering standard errors, difference-in-difference estimators, ridge regression, Lasso, Elastic net, random forests, neural networks) and portfolio optimization techniques.
Highlights Self-contained chapters on the most important applications and methodologies in finance, which can easily be used for the reader’s research or as a reference for courses on empirical finance Each chapter is reproducible in the sense that the reader can replicate every single figure, table, or number by simply copying and pasting the code we provide A full-fledged introduction to machine learning with tidymodels based on tidy principles to show how factor selection and option pricing can benefit from Machine Learning methods Chapter 2 on accessing and managing financial data shows how to retrieve and prepare the most important datasets financial economics: CRSP and Compustat.
Nánar um bókina
- Taylor & Francis
- 9781000858785
- 9781032389332
- ePub
- 1
- Christoph Scheuch; Stefan Voigt; Patrick Weiss
- English
- 2023-04-05
- 100
- 2
- 2
Kaflar
- Cover Page
- Half-Title Page
- Series Page
- Title Page
- Copyright Page
- Contents
- Preface
- Author biographies
- I Getting Started
- 1 Introduction to Tidy Finance
- 1.1 Working with Stock Market Data
- 1.2 Scaling Up the Analysis
- 1.3 Other Forms of Data Aggregation
- 1.4 Portfolio Choice Problems
- 1.5 The Efficient Frontier
- 1.6 Exercises
- II Financial Data
- 2 Accessing & Managing Financial Data
- 2.1 Fama-French Data
- 2.2 q-Factors
- 2.3 Macroeconomic Predictors
- 2.4 Other Macroeconomic Data
- 2.5 Setting Up a Database
- 2.6 Managing SQLite Databases
- 2.7 Exercises
- 3 WRDS, CRSP, and Compustat
- 3.1 Accessing WRDS
- 3.2 Downloading and Preparing CRSP
- 3.3 First Glimpse of the CRSP Sample
- 3.4 Daily CRSP Data
- 3.5 Preparing Compustat Data
- 3.6 Merging CRSP with Compustat
- 3.7 Some Tricks for PostgreSQL Databases
- 3.8 Exercises
- 4 TRACE and FISD
- 4.1 Bond Data from WRDS
- 4.2 Mergent FISD
- 4.3 TRACE
- 4.4 Insights into Corporate Bonds
- 4.5 Exercises
- 5 Other Data Providers
- 5.1 Exercises
- III Asset Pricing
- 6 Beta Estimation
- 6.1 Estimating Beta using Monthly Returns
- 6.2 Rolling-Window Estimation
- 6.3 Parallelized Rolling-Window Estimation
- 6.4 Estimating Beta using Daily Returns
- 6.5 Comparing Beta Estimates
- 6.6 Exercises
- 7 Univariate Portfolio Sorts
- 7.1 Data Preparation
- 7.2 Sorting by Market Beta
- 7.3 Performance Evaluation
- 7.4 Functional Programming for Portfolio Sorts
- 7.5 More Performance Evaluation
- 7.6 The Security Market Line and Beta Portfolios
- 7.7 Exercises
- 8 Size Sorts and p-Hacking
- 8.1 Data Preparation
- 8.2 Size Distribution
- 8.3 Univariate Size Portfolios with Flexible Breakpoints
- 8.4 Weighting Schemes for Portfolios
- 8.5 P-hacking and Non-standard Errors
- 8.6 The Size-Premium Variation
- 8.7 Exercises
- 9 Value and Bivariate Sorts
- 9.1 Data Preparation
- 9.2 Book-to-Market Ratio
- 9.3 Independent Sorts
- 9.4 Dependent Sorts
- 9.5 Exercises
- 10 Replicating Fama and French Factors
- 10.1 Data Preparation
- 10.2 Portfolio Sorts
- 10.3 Fama and French Factor Returns
- 10.4 Replication Evaluation
- 10.5 Exercises
- 11 Fama-MacBeth Regressions
- 11.1 Data Preparation
- 11.2 Cross-sectional Regression
- 11.3 Time-Series Aggregation
- 11.4 Exercises
- IV Modeling & Machine Learning
- 12 Fixed Effects and Clustered Standard Errors
- 12.1 Data Preparation
- 12.2 Fixed Effects
- 12.3 Clustering Standard Errors
- 12.4 Exercises
- 13 Difference in Differences
- 13.1 Data Preparation
- 13.2 Panel Regressions
- 13.3 Visualizing Parallel Trends
- 13.4 Exercises
- 14 Factor Selection via Machine Learning
- 14.1 Brief  Theoretical Background
- 14.1.1 Ridge regression
- 14.1.2 Lasso
- 14.1.3 Elastic Net
- 14.2 Data Preparation
- 14.3 The Tidymodels Workflow
- 14.3.1 Pre-process data
- 14.3.2 Build a model
- 14.3.3 Fit a model
- 14.3.4 Tune a model
- 14.3.5 Parallelized workflow
- 14.4 Exercises
- 15 Option Pricing via Machine Learning
- 15.1 Regression Trees and Random Forests
- 15.2 Neural Networks
- 15.3 Option Pricing
- 15.4 Learning Black-Scholes
- 15.4.1 Data simulation
- 15.4.2 Single layer networks and random forests
- 15.4.3 Deep neural networks
- 15.4.4 Universal approximation
- 15.5 Prediction Evaluation
- 15.6 Exercises
- V Portfolio Optimization
- 16 Parametric Portfolio Policies
- 16.1 Data Preparation
- 16.2 Parametric Portfolio Policies
- 16.3 Computing Portfolio Weights
- 16.4 Portfolio Performance
- 16.5 Optimal Parameter Choice
- 16.6 More Model Specifications
- 16.7 Exercises
- 17 Constrained Optimization and Backtesting
- 17.1 Data Preparation
- 17.2 Recap of Portfolio Choice
- 17.3 Estimation Uncertainty and Transaction Costs
- 17.4 Optimal Portfolio Choice
- 17.5 Constrained Optimization
- 17.6 Out-of-Sample Backtesting
- 17.7 Exercises
- A Cover Design
- B Clean Enhanced TRACE with R
- Bibliography
- Index