Author Archives: Attaullah Shah

  • 31

Publication quality regression tables with asdoc in Stata – video example

Category:asdoc Tags : 

Creating publication-quality tables in Stata with asdoc is as simple as adding asdoc to Stata commands as a prefix. asdoc can create two types of regression tables. The first type (call it detailed) is the detailed table that combines key statistics from the Stata’s regression output with some additional statistics such as mean and standard deviation of the dependent variable etc. This table is the default option in asdoc. The second table is a compact table that nests more than one regressions in one table (call it nested).

In this video post, I show how to use asdoc to produce the following nested table. 



  • 9

How to export high-quality table of correlations from Stata to MS Word

Category:asdoc Tags : 


For creating a high-quality publication-ready table of correlations from Stata output, we need to install asdoc program from SSC first.

ssc install asdoc, update

Once the installation is complete, we shall add the word asdoc to the cor or correlate command of Stata. Since we estimate correlations among all numeric variables of a dataset with just cor, we shall add asdoc as a prefix to the cor command. For our example, purposes, let us load the auto.dta data from the Stata example files.


Example 1: Make a table of correlation for all variables.

sysuse auto, clear
asdoc cor



Example 2: We can report variable labels instead of variable names

asdoc cor, label replace



Further, it is possible to write names of the variables in the column headings instead of sequential numbers. For this, we shall invoke the option nonum. Therefore, see example 3.


Example 3: Write variable names in column headers

sysuse auto, clear

asdoc pwcorr, nonum replace


Read also : 

Table of contents of asdoc

Generate correlation table with significance/stars

Generate a table of descriptive statistics






  • 28

How to use asdoc : a basic example

Category:asdoc Tags : 

How to use asdoc

Using asdoc is pretty easy. You need to add just asdoc as a prefix to Stata commands. For example, we use sum command to find summary statistics of all numeric variables in the dataset. We shall add just asdoc as a prefix to sum.  Let us load the auto.dta set for practice and find summary stats of all numeric variables and send the output to MS Word with asdoc

sysuse auto
asdoc sum

And voila, a beautiful table of descriptive statistic is ready [click here to see it].

And for correlations, we shall use asdoc cor. If we were to append the results to the same file, we shall just add append after the comma or leave it (append is the default, you can use replace to replace existing file)

asdoc cor
asdoc cor, append


See also the following resources related to asdoc.

YouTube Video: Descriptive / Summary Statistics from Stata in Word with asdoc

YouTube Video: Create publication quality table of correlation in Stata with asdoc

YouTube Video: Writing all statistics to a single Word file from Stata with asdoc

YouTube Video: Create publication quality regression tables in Stata with asdoc

See a Table of Contents that shows what else asdoc can do


  • 22

asdoc : Sends Stata output to MS Word

Category:Stata Programs

About asdoc

asdoc is a Stata program that makes the process of sending Stata output to MS Word super easy. asdoc creates high quality, publication-ready tables from various Stata commands such as summarize, correlate, tabstat, cross-tabs, regressions, t-tests, flexible table, and many more.


The program can be installed by typing the following from the Stata command window:

ssc install asdoc, update

Table of contents

1. Introduction

1.1 asdoc: short introduction and examples
1.2 Commands for controlling asdoc


     2. Summary Statistics

2. Summary statistics
2.1 Basic summary statistics
2.2 Customized summary statistics


     3. Correlations

3. Correlations [Blog Post]
3. Correlations [YouTube Video]


4. Regressions

       4.1 Full regression tables [YouTube Video]

4.1.1 Customizing the detailed table: Stars and CIS
4.2 Compact / nested tables (publication quality)
4.3 Regression over a grouping variable (YouTube Video)


     5. Frequency tables

5.1 One-way tabulation (tabulate1)
5.2 Two-way tabulation (tabulate2)
5.3 One- and two-way tables of summary statistics (tabsum)
5.4 Multiple-way tables (tab1)
5.5 All-possible two-way tables (tab2)


6. Compact tables (tabstat)

6.1 Without groups
6.1 With groups


7. Flexible table of statistics (table)

7.1 One-way table
7.2 Two-way table
7.3 Three-way table
7.4 Four-way table


8. T-tests

8.1 one-sample t-test
8.2 two-sample using groups
8.3 two-sample using variables
8.4 paired t-test


9. Table of means, std., and frequencies (tabsum)

10. Means
10.1 Arithmetic / harmonic / geometric means
10.2 Proportions
10.3 Ratio
10.4 Total

11. Exporting the Stata Data with the sub-command list 

12. Writing matrix to a Word / RTF file

13.The survey prefix command

14.Customized tables with option row

  • 0

Log vs simple returns: Examples and comparisons

Category:Uncategorized Tags : 

Simple vs log returns | Conversion from daily to other frequencies

MS Excel Example 

[Download Example]

In the following table, we have data from 1/1/2010 to 1/7/2010.  The first column has firm id; the second column has date; the third column has stock prices.

id date prices simple ri log_ri ri+1
1 1/1/2010 70
1 1/2/2010 72 2.857% 2.817% 102.857%
1 1/3/2010 75 4.167% 4.082% 104.167%
1 1/4/2010 73 -2.667% -2.703% 97.333%
1 1/5/2010 74 1.370% 1.361% 101.370%
1 1/6/2010 76 2.703% 2.667% 102.703%
1 1/7/2010 77 1.316% 1.307% 101.316%

The fourth and fifth columns have simple and log returns, calculated as:

simple ri = (Price[i] - Price[i-1] ) /  Price[i-1]  --- (Eq. 1)
log ri = ln( Price[i]  /  Price[i-1]  --- (Eq. 2)

where Price[i] is the stock price in the current period,  Price[i-1] is the stock price in the previous period, ln is the natural log. To convert simple returns to n-period cumulative returns, we can use the products of the terms (1 + ri) up to period n. Therefore, the fifth column adds a value of 1 to the simple period returns.

Weekly cumulative simple returns

Suppose we wish to find weekly cumulative simple returns from the stock prices, we shall just use the first and the last stock prices of the week and apply equation (1). Therefore, our cumulative weekly simple return is as follows:

weekly simple ri = ( 77 - 70) /  70 = 10.00%

And if we were to find weekly cumulative simple returns from the daily returns, then we would add 1 to each of the period simple_ri, find its product, and deduct 1 at the end. Therefore, the formula for converting simple periodic daily returns to weekly cumulative returns would be :

Cumulative n-period simple returns =

(1+simple_r1) * (1+simple_r2) *(1+simple_r3)
  ... (1+simple_rn- 1     --- (Eq. 3)

Therefore, applying Equation 3 to our example;

Cumulative weekly simple returns =
102.857% * 104.167% * 97.333% * 101.370% * 102.703% 

* 101.316% - 1 = 10.00%


Weekly cumulative log returns

Now suppose we wish to find weekly cumulative log returns from the stock prices, again we shall use the first and the last of the stock prices of the week in equation (2). So, our cumulative weekly log return is as follows:

weekly log ri = ln( 77 /  70) = 9.53%

Since log returns are continuously compounded returns, it is normal to see that the log returns are lower than simple returns. To find n-period log returns from daily log returns, we need to just sum up the daily log returns. Therefore :

Cumulative weekly simple returns2.817% + 4.082% +  (-2.703%) + 
1.361% +2.667% +  1.307% = 9.53%



Stata Example

We shall continue to use the same data as above. The Stata do file for all of the following steps can be downloaded from here.

The following lines of code will generate the required data

input float date byte(id prices) float wofd
18263 1 70 2600
18264 1 72 2600
18265 1 75 2600
18266 1 73 2600
18267 1 74 2600
18268 1 76 2600
18269 1 77 2600
format %td date
format %tw wofd
tsset id date

Now to generate simple and log returns

bys id (date) : gen simple_ri = (price / L.price) -1
bys id (date) : gen log_ri = ln(price / L.price)


Cumulative weekly simple returns

we shall use ascol program. This program can be downloaded from SSC by typing:

ssc install ascol

If daily returns were calculated with Eq. 1 above (i.e. simple returns) and they needed to be converted to cumulative n-periods returns, we shall use the option returns(simple). For this purpose, we would type the following command:

ascol simple_ri, returns(simple) keep(all) toweek

For syntax and option details of ascol, you can type help ascol at the Stata command prompt. We shall just briefly list the option used in the above command. After typing ascol, we need to mention the name of the variable for which cumulative returns are needed.

In our case, it is the simple_ri. Then after the comma, we invoke various program options. Our first option is returns(simple), which tells ascol that our data have simple returns. ascol will apply product method of converting from daily to weekly see Eq. 3 above ).  Then we use keep(all)  to stop ascol from collapsing the data set to a weekly frequency. Absent this option, the data will be reduced to one observation per ID and weekly_period identifier.  The other possibility in this regard is the option price, which can be used if the variable is stock prices.  And finally, we used toweek option for converting the data to a weekly frequency. Other possible options in this regard are tomonth, toquarter, and toyear.

Cumulative weekly log returns

If daily returns were calculated using Eq. 2 above  (i.e. log returns) and they need to be converted to cumulative n-periods returns, we shall use the option returns(log). For this purpose, we would type the following command:

 ascol log_ri , returns(log) keep(all) toweek gen(log_cumRi)

The syntax details remain the same as given above. We have used one additional option gen(log_cum) for naming the new variable as log_cumRi

date wofd simple_ri log_ri week_s~i log_cumRi
01jan2010 2010w1 . . .1 .09531018
02jan2010 2010w1 .0285714 .0281709 .1 .09531018
03jan2010 2010w1 .0416667 .040822 .1 .09531018
04jan2010 2010w1 -.0266667 -.0270287 .1 .09531018
05jan2010 2010w1 .0136986 .0136057 .1 .09531018
06jan2010 2010w1 .027027 .0266682 .1 .09531018
07jan2010 2010w1 .0131579 .0130721 .1 .09531018

  • 0

Stata Dates: Conversion from one format to another


Case 1: From String to Stata format

Usually, when we import data manually into the Stata Editor, the dates are shown in string format. For example, Nov202011, November202011, or  etc. We can use the gen command with date function

gen newdate = date(oldDate, "MDY")


Case 2: From daily to monthly

gen monthly = mofd(daily_date)


Case 3: From daily to weekly

gen monthly = wofd(daily_date)

Case 4: From daily to quarterly

gen monthly = qofd(daily_date)


Case 5: From daily to yearly

gen monthly = year(daily_date)


Case 6: From monthly to daily

If our date is recorded in monthly numeric format such as 2001m1, 2001m2, etc, then:

gen daily = dofm(monthly_date)

  • 0

Find annual | monthly cumulative (product) of returns

Category:Blog Tags : 

The problem

Let’s say that we have daily stock returns. We want to convert those returns to cumulative returns for a weekly, monthly or yearly frequency.

Where cumulative returns = (1+Ri1) * (1+Ri2) * (1+R3) * … (1+R4) – 1



First create the weekly, monthly or year identifier, and then use asrol program.

Let us use this data set [Click here to download], also shown below and find returns for different frequencies.

input id str20 D returns
 1 30jun1993 .7437958 
 1 02jul1993 .0674011 
 1 06jul1993 .2668857 
 1 14jul1993 .0454151 
 1 19jul1993 .1340756 
 1 29jul1993 .8053644 
 1 13aug1993 .5861199 
 1 24sep1993 .3200437 
 1 19oct1993 .0098762 
 1 19oct1993 .005197 
g date = date(D, "DMY")
drop D


Find weekly cumulative returns

Let us first install asrol from ssc

ssc install asrol

Now create weekly date

gen week = wofd(date)

Now find the returns using asrol

bys id week :  asrol returns, stat(product) add(1)

Note : add(1) adds 1 with each returns before multiplication and then subtracts 1 at the end.

Find monthly cumulative returns

gen month = mofd(date)
bys id month:  asrol returns, stat(product) add(1)

Find yearly cumulative returns

 gen year= year(date)
bys id year:  asrol returns, stat(product) add(1)

  • 0

Research Topics in Islamic Banking and Finance



 How Islamic financial instruments can be used in international trade?

 A mechanism for inter-bank transactions for Islamic and conventional banks

Can Sharia board play a role in the development of Islamic instruments?

4 Tawarruq as a tool of inter-bank borrowing

5  Risk management framework for Islamic banks: do we need something special?

6  Have the challenges faced by Islamic banks changed over the last decade?

7  The dynamics of financial crisis: Conventional vs Islamic finance

8  Can Zakat be used as a microfinancing tools?

9  Value at Risk of Sukuk and conventional bonds

10  Risk analysis of Murabaha financing and leasing

11  What customers say about Islamic banking? Values vs religious perspectives

12  Can ownership structure affect earning management?

13 Collaborative Islamic Banking Service: The Case of Ijarah

14 Success factors of collaboration in Islamic banks

15 Constraints in the application of partnerships in Islamic banks

16  Can Islamic finance reduce nonperforming loans?

17  Which firms use Islamic financing?

18  Can SME’s benefit more from Islamic financing?

19  Islamic banking development and access to credit

20  Islamic finance and economic growth

  • 0

Research Topics in Finance: Earning Management

Category:Uncategorized Tags : 


 The relationship between earning management and market liquidity

 Are top management pays and earning management practices related?

 Can financial crisis affect earning management practices?

 The effect of the earning transparency on cost of capital 

4  The impact of leverage on accrual-based earnings management

5  Can institutional investors exploit the accrual anomaly?

6  Accrual-based and real earnings management: Are investors protected?

7  Cost of capital and earnings transparency

8  The effect of accounting comparability on the accrual-based and real earnings management

9  Earnings management and accrual anomaly across market states and business cycles

10  Short-term debt maturity, monitoring and accruals-based earnings management

11  The effect of mandatory IFRS adoption on real and accrual-based earnings management activities

12  Can ownership structure affect earning management?

13  Regulatory Risk and the Cost of Capital

14  Accrual-based and real earnings management activities around seasoned equity offerings

15  Time-varying risk, mispricing attributes, and the accrual premium

16  Accruals, cash flows, and operating profitability in the cross section of stock returns

17  Does family involvement explain why corporate social responsibility affects earnings management?

18  How excess control and earning management practices are related?

19  Managerial entrenchment and earnings management

20  Product market competition and earnings management

  • 2

Research Topics in Finance | Financing / Capital Structure Choices

Category:Blog Tags : 

In this blog post, I would like to present a list of research topics related to financing or capital structure decisions.

 Top managers experiences and firms’ capital structure choices

 Do macroeconomic factors affect the choice of debt /equity financing? How are small firms affected?

 Supply of capital and debt-equity choices

 Persistence in capital structure decisions?

4  Can earning timing affect capital structure decisions?

5   Can stock return shocks affect capital structure decisions?

6   Effects of Capital Structure on Cost of Capital

7  judicial efficiency and capital structure: is there a relation?

8   Cultural and religious effects on capital structure choices

9  Credit market imperfections and capital structure changes

10  How corporate governance affect capital structure decisions

11  How financial crisis plays a role in altering capital structures

12  Country tax system and capital structure choices

13  Information asymmetries and capital structure decisions around the world

14  Product market competition and capital structure decisions

15  Capital structure adjustments: Do macroeconomic and business risks matter?

16  The capital structure and investment decisions of the small owner-managed firm

17  Competing theories of capital structure: pecking order theory vs trade-off theory

18  Can hedging increase the debt capacity of a firm?

19  Can credit ratings determine firm’s capital structure

20  Diversification and capital structure