
Categories
 Data (9)
 Learning Resources (9)
 Python (8)
 SAS (13)
 Stata (26)
Archives
 September 2023 (1)
 August 2023 (1)
 May 2023 (1)
 February 2022 (2)
 January 2022 (1)
 August 2021 (1)
 September 2019 (1)
 August 2019 (2)
 July 2019 (2)
 May 2019 (1)
 April 2019 (1)
 March 2019 (1)
 August 2018 (3)
 July 2018 (4)
 December 2017 (1)
 November 2017 (1)
 October 2017 (1)
 September 2017 (1)
 April 2017 (2)
 September 2016 (1)
 April 2016 (1)
 December 2015 (1)
 November 2015 (1)
 September 2015 (4)
 August 2015 (5)
 June 2015 (3)
 March 2015 (7)
 February 2015 (2)
Category Archives: Stata
Stata command 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
7 Comments
Stata command 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
3 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
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
5 Comments
Sample code for “outreg” command in Stata
outreg is a timesaving and musthave command in Stata. It will generate a readyforuse results table like this. I’m sure you will see what a relief this can give us. outreg is not a builtin command and can be installed … Continue reading
Posted in Stata
Leave a comment
A loop of crosssectional regressions for calculating abnormal accruals in Stata
I write a loop of crosssectional 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
7 Comments
Rollingwindow computation in SAS and Stata
SASers often find proc expand plus transformout very useful for rollingwindow (or movingwindow) computation. Stataers may wonder if there is a counter party in Stata. The answer is “yes”. The command in Stata is rolling. See the manual below: http://www.stata.com/manuals13/tsrolling.pdf The … Continue reading
Posted in Learning Resources, SAS, Stata
Leave a comment