Author Archives: Kai Chen

Calculate idiosyncratic stock return volatility

I have noted two slightly different definitions of idiosyncratic stock return volatility in: Campbell, J. Y. and Taksler, G. B. (2003), Equity Volatility and Corporate Bond Yields. The Journal of Finance, 58: 2321–2350. doi:10.1046/j.1540-6261.2003.00607.x Rajgopal, S. and Venkatachalam, M. (2011), … Continue reading

Posted in SAS | Leave a comment

Commonly used Stata commands to deal with potential outliers

In accounting archival research, we often take it for granted that we must do something to deal with potential outliers before we run a regression. The commonly used methods are: truncate, winsorize, studentized residuals, and Cook’s distance. I discuss in … Continue reading

Posted in Stata | Leave a comment

Use Python to extract URLs to HTML-format SEC filings on EDGAR

I wrote two posts to describe how to download TXT-format SEC filings on EDGAR: Use Python to download TXT-format SEC filings on EDGAR (Part I) Use Python to download TXT-format SEC filings on EDGAR (Part II) Although TXT-format files have … Continue reading

Posted in Python | 7 Comments

Sample code for “outreg” command in Stata

outreg is very powerful and time-saving command in Stata. The following code generates a ready-for-use results table:

Please change x1, x2, x3 and x4 to variables that you want to report.

Posted in Stata | Leave a comment

Use Python to download data from the DTCC’s Swap Data Repository

I helped my friend to download data from the DTCC’s Swap Data Repository. I am not familiar with the data and just use this as a programming practice. This article gives an introduction to the origin of the data: http://www.dtcc.com/news/2013/january/03/swap-data-repository-real-time The … Continue reading

Posted in Data, Python | Leave a comment

Download FR Y-9C data from WRDS

WRDS currently populates FR Y-9C data quarter by quarter in individual datasets, like BHCF200803, BHCF200806, BHCF200809 and so on. WRDS has not stacked those individual datasets to formulate a single time-series dataset like COMPUSTAT. There are two ways to overcome … Continue reading

Posted in Data, SAS | Leave a comment

TAR-Style Word Template

I create a Word template that complies with The Accounting Review editorial style. My design philosophy is “simple but sufficient”. I do not like those templates that are heavy and fancy (e.g., macros everywhere). This is just version 1. It … Continue reading

Posted in Uncategorized | 1 Comment

Use Python to download TXT-format SEC filings on EDGAR (Part II)

As I said in the post entitled “Part I“, we have to do two steps in order to download SEC filings on EDGAR: Find paths to raw text filings; Select what we want and bulk download from the EDGAR FTP server using … Continue reading

Posted in Data, Python | 33 Comments

Use Python to extract Intelligence Indexing fields in Factiva articles

First of all, I acknowledge that I benefit a lot from Neal Caren’s blog post Cleaning up LexisNexis Files. Thanks Neal. Factiva (as well as LexisNexis Academic) is a comprehensive repository of newspapers, magazines, and other news articles. I first … Continue reading

Posted in Python | 5 Comments

A loop of cross-sectional regressions for calculating abnormal accruals in Stata

I write a loop of cross-sectional regressions for calculating abnormal accruals. This program can be easily modified and replaced with Jones, modified Jones, or Dechow and Dichev model. I add detailed comments in the program to help you prepare the input … Continue reading

Posted in Stata | 5 Comments