Categories
 Data (8)
 Learning Resources (8)
 Python (8)
 SAS (14)
 Stata (23)
 Uncategorized (1)

Recent Posts
Recent Comments
 Alex Luong on Export a SAS dataset to Stata with all variable names converted to lowercase
 X Huan on Calculate market value of equity: use CRSP or Compustat?
 Kai Chen on Use Python to extract URLs to HTMLformat SEC filings on EDGAR
 Kai Chen on EDGAR index files in Stata dataset (from 1993 Q1 to March 2, 2017)
 bruno on EDGAR index files in Stata dataset (from 1993 Q1 to March 2, 2017)
Archives
Meta
Author Archives: Kai Chen
Display mean and median test results in Stata
Sometimes we may want to produce the following table to compare the mean and median of two groups: First of all, please refer to this post to see Stata commands to test equality of mean and median. However, it is … Continue reading
Posted in Stata
19 Comments
Stata commands to do Heckman two steps
We often see Heckman’s two steps in accounting literature. But how to do it in Stata? The two steps refer to the following two regressions: Outcome equation: y = X × b1 + u1 Selection equation: Dummy = Z × … Continue reading
Posted in Stata
5 Comments
The calculation of average credit rating using ratings from three rating agencies
I was doing something in Finance and wanted to calculate the average rounded credit rating. Basically, I need to translate textual grades (e.g., AAA, Baa) to a numerical value. I found a clue in the following paper: Becker, B., and … Continue reading
Stata commands to test equality of mean and median
Please read this post for how to display the results in a readyforuse format. UCLA IDRE has posted an article (link) that may provide a bit more explanation. UCLA IDRE is a great resource for learning statistical analysis. A big thank you … Continue reading
Posted in Stata
2 Comments
Stata command to display combined Pearson and Spearman correlation matrix
Oftentimes we would like to display Pearson correlations below the diagonal and Spearman correlations above the diagonal. Two builtin commands, pwcorr and spearman, can do the job. However, we have to manually combine Stata output tables when producing the correlation table … Continue reading
Stata command to convert string GVKEY to numerical GVKEY or vice versa
The default type of GVEKY in Compustat is string. Sometimes, we need it to be a numerical type in Stata (e.g., when we want to use the super handy command tsset). The command to convert string GVKEY to numerical GVEKY … Continue reading
Stata command to calculate the area under ROC curve
If we want to evaluate the predictive ability of a logit or probit model, Kim and Skinner (2012, JAE, Measuring securities litigation risk) suggest that A better way of comparing the predictive ability of different models is to use the Receiver … Continue reading
Stata commands to calculate skewness
Suppose we are going to calculate the skewness of 12 monthly returns. The 12 returns may be stored in a row (Figure 1) or in a column (Figure 2). This post discusses how to calculate the skewness in these two … Continue reading
Posted in Stata
Leave a comment
Use Python to download lawsuit data from Stanford Law School’s Securities Class Action Clearinghouse
[Update on 20190707] I am grateful to Shiyu Chen, my research assistant, who did a very good job on not only web scraping the toplevel table, but also extracting from the case summary page additional information (link to case summary … Continue reading
Posted in Python
6 Comments
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.15406261.2003.00607.x Rajgopal, S. and Venkatachalam, M. (2011), … Continue reading
Posted in SAS
8 Comments