This repository contains a collection of R scripts inspired by "Tidy Finance" concepts. These scripts are designed to serve as a cheat sheet for various financial calculations and analyses using R. Each script corresponds to a specific topic or methodology commonly employed in empirical finance studies.
The repository includes the following R scripts:
Accessing_Managing_Financial_Data.R
: Demonstrates how to access and manage financial data, focusing on data handling and preprocessing techniques.Beta_Estimation.R
: Provides a methodology for estimating market betas of stocks, crucial in asset pricing and risk management.Univariate_Portfolio_Sorts.R
: Shows how to perform univariate portfolio sorts, a key method in empirical asset pricing to explore the relationship between stock characteristics and returns.Size_Sorts_and_pHacking.R
: Focuses on constructing portfolios based on firm size and addresses the concept of p-hacking in empirical finance.Replicating_Fama_and_French_Factors.R
: Illustrates how to replicate the famous Fama and French factor models, which are central to understanding risk and return in financial markets.Fama_MacBeth_Regressions.R
: Implements the Fama-MacBeth regression approach, widely used in academic research to estimate risk premiums.Fixed_Effects_Clustered_SE.R
: Demonstrates fixed effects regression models and the application of clustered standard errors, commonly used in panel data analysis.
Each script is standalone and can be executed in an R environment. Ensure that you have the necessary R packages installed as indicated at the top of each script. The scripts are meant to provide practical examples and can be modified or extended based on specific research or analysis requirements.
- R environment (version 3.6.0 or later recommended).
- Necessary R packages (e.g.,
tidyverse
,RSQLite
,fixest
) as specified in each script.
Contributions to this repository are welcome. Please feel free to fork the repository, make changes, and submit pull requests. If you find any issues or have suggestions for improvements, please submit them through the issue tracker.
This project is open-source and available under the MIT License.
This repository is inspired by the methodologies and techniques presented in "Tidy Finance with R" and similar empirical finance literature.
Cheers Yaron.