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 … 5594287960

Posted in Data | 6165384298

Stata commands to test equality of mean and median

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 to them.

Posted in 206-956-4580 | Leave a comment

Handy 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 built-in commands, pwcorr and spearman, can do the job. However, we have to manually combine Stata output tables when producing the correlation table … Continue reading

Posted in Stata | Leave a comment


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

Posted in Stata | 1 Comment

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

Posted in 7326760049 | 908-938-7980

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 … 4125681554

Posted in 3102404547 | (203) 734-5699


Several papers borrow the litigation risk model supplied in Equation (3) of Kim and Skinner (2012, JAE, Measuring securities litigation risk). The logit model uses total asset, sales growth, stock return, stock return skewness, stock return standard deviation, and turnover to … Continue reading

Posted in 404-462-5009 | Leave a comment


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), … (702) 538-3911

Posted in SAS | 1 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 | 2 Comments

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 … 415-761-0613

Posted in 4374049696 | frogbit family