Stata Programs

Why user-written Programs

The following list of Stata programs can be used in finance and accounting research and other allied disciplines. In finance, usually we have very large data sets and some of the built-in data tools in Stata are very slow to process such data sets. Take the example of xtile command that is used for creating quantile groups, or the rolling command for rolling window calculations. These commands are extremely slow. These limitations have always frustrated me and gave me enough motivation to write the following commands.

 

1.  asm : A Stata program to create momentum portfolios

[available for nominal price]
I have written an easy to use Stata® program, asm.ado for creation and testing of momentum portfolio returns. The program offers a large number of options which have been used in the the momentum literature. This program employs well-known momentum portfolio strategies as suggested in Jagadesh and Titman (1993) and many other options suggested in subsequent papers. This program is equally useful for academics and practitioners. The program offers the the following features:… Read more … 

 


 

2.  asrol : A Stata program to generate rolling-window statistics and by-group statistics

[available for free]
asrol calculates descriptive statistics in a user’s defined rolling-window or over a grouping variable. The descriptive statistics include standard deviation, mean, median, geometric mean, products, count, minimum, maximum, number of missing values, first observation, last observation, and total.   asrol can efficiently handle all types of data structures such as data declared as time series or panel data, undeclared data, or data with duplicate values, missing values or data having time series gaps.. Read more … 


 

3.  ascol : To convert returns and prices from daily to weekly, monthly… frequency.

[available for free]
It is pretty easy with ascol to convert stock returns or prices data from daily to weekly, monthly, quarterly, or yearly frequency. Since returns and prices need different treatments for conversion (returns need to be summed for their conversion from daily to say weekly frequency, while in case of prices, the conversion will just results in producing end of the week prices.), the program gives us both the option of converting returns and prices data. data, undeclared data, or data with duplicate values, missing values or data having time series gaps.. Read more … 

 


 

4.  asreg : A Stata program for rolling-window and by-group regressions

[available for free]
asreg fits a model of dependent variable on independent variabless using linear regression in a user’s defined rolling window or by a grouping variable. The estimation of rolling beta or cross-sectional regression is very common in finance. asreg is very efficient in both estimaton of rolling-window regressions or cross-sectional regressions. asreg is order of magnitude faster than estimating rolling window regressions through conventional methods such as Stata loops or using the Stata’s official rolling command. asreg has the same speed efficiency as asrol. All the rolling window calculations, estimation of regression parameters, and writing the results to Stata variables are done in the Mata language. Read more … 


 

5.  astile : A Stata program for rolling-window and by-group regressions

[available for free]
asreg fits a model of dependent variable on independent variables using linear regression in a user’s defined rolling window or by a grouping variable. The estimation of rolling beta or cross-sectional regression is very common in finance. asreg is very efficient in both estimation of rolling-window regressions or cross-sectional regressions. asreg is order of magnitude faster than estimating rolling window regressions through conventional methods such as Stata loops or using the Stata’s official rolling command. asreg has the same speed efficiency as asrol. All the rolling window calculations, estimation of regression parameters, and writing the results to Stata variables are done in the Mata language. Read more … 


 

6.  asgen : A Stata program for generating weighted average mean

[available for free]
asgen creates a new variable from an existing variable or an expression. The new variable contains weighted average mean. The existing variable is supplied to asgen by the =exp. The weights are based on the values of an existing numeric variable, that is specified in the weight(varname) option. asgen accepts both the [if] [in] qualifiers for performing the required calculations on a subset of data. Further, the use of =exp can come handy in many situations where we want to make changes on the fly before we find the weighted average mean.
Read more … 


 

7.  astx : Creates a table of descriptive statistics by a grouping variable.

[available for free]
astx finds descriptive statistics for a specific variable over a grouping variable. Further, it estimates t-statistics and sends the output file to MS Excel File. Read more … 


 

8.  searchfor : Searches for texts in selected or all string variables.

[available for free]
searchfor finds text in string variables and either lists the selected variables on screen or edits the variables in Data Editor. The search text is capitalization free. Read more …