Difference between revisions of "Ieddtab"

Jump to: navigation, search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''ieddtab''' is used to run difference in difference regressions and output the results in well formatted tables.
<code>ieddtab</code> is a Stata command that estimates and outputs [[Difference-in-Differences | differences in differences]] results in well-formatted tables. It is a useful command for conducting [[Data Analysis | data analysis]] and [[Exporting Analysis | exporting results]] in a reproducible manner. This page describes how to use the command and how it works.  


This article is meant to describe use cases, work flow and the reasoning used when developing the commands. For instructions on how to use the command specifically in Stata and for a complete list of the options available, see the help files by typing <code>help '''ieddtab'''</code> in Stata. This command is a part of the package [[Stata_Coding_Practices#ietoolkit|ietoolkit]], to install all the commands in this package including this command, type <code>ssc install ietoolkit</code> in Stata.
==Read First==


== Intended use cases ==
*This command is a part of the package <code>[[Stata_Coding_Practices#ietoolkit|ietoolkit]]</code>. To install all the commands in this package including <code>ieddtab</code>, type <code>ssc install ietoolkit</code> in Stata.
The intended use case is when you are using a [[Difference-in-Difference]] model for your analysis and you want to output your results in well formatted tables. This command is particularly suited for the case when you run the same difference-in-difference regression on multiple outcome variables.
* For detailed instructions on how to implement the command in Stata, type <code>help ieddtab</code> in Stata.


=== Intended Work Flow ===
==Overview==
The workflow for ''ieddtab'' is as simple as possible. You do not need to run any regression yourself before using this command. You only need to have one dummy variable that indicates which observations are treatment and which are control, and a dummy variable that indicates which observations are from baseline and which are from the follow-up/endline. The command creates the interaction dummy needed, run the regressions as well as outputs the table with the results.


== Instructions ==
<code>ieddtab</code> is a Stata command that estimates and outputs [[Difference-in-Differences | differences in differences]] results in well-formatted tables. To run <code>ieddtab</code> in its most basic form, you need three variables: the outcome variable, a dummy variable that indicates treatment vs. control assignment and a dummy variable that indicates whether the observation comes from baseline vs. endline. In this example, these variables are varA, treat, and t, respectively. The basic implementation of the command is:
These instructions are meant to help you understand how to use the command. For technical instructions on how to implement the command in Stata see the help files by typing <code>help  '''ieddtab'''</code> in Stata.
  <nowiki>ieddtab varA, time(t) treatment(treat)</nowiki>  
The command estimates five statistics for each outcome: the baseline means of the outcome for treatment = 0 and treatment = 1; the first difference regression coefficient of the outcome for treatment = 0 and treatment = 1; and the second difference. The baseline means represent the starting average for each group, the first differences represent the trend in each group between the two time periods, and the second difference represents the impact effect as estimated by a difference-in-difference model.  


== Description of the Statistics used ==
The command then outputs the results into a well-formatted table.


For each outcome variable five statistics are estimated. Two baseline means (one for control and one for treatment), two first differences (one for control and one for treatment) and the second difference. The baseline means show the starting point in each group, the first difference shows the trend in each group between the two time periods, and the second difference is the impact effect as estimated by a difference-in-difference model. This page is about how to use ''ieddtab'' and will therefore not discuss the statistical meaning of the results of this command more than this.
==How it Works ==


The sections below discuss how the statistics are calculated by this command if the command was specified like this:
This section explains how <code>ieddtab</code> estimates results, using the variables specified in the above example (varA, treat, t). The user does not need to know the following backend information in order to implement the command: this section is intended solely to enhance user understanding. Note that, for simplicity, any tempvars mentioned in this section are represented as normal variables.


<code>ieddtab varA, time(t) treatment(treat)</code>
The command first creates an interaction tempvar, which we call interact (line 1). The command then calculates the difference-in-difference result (line 2). The difference-in-difference result displayed in the table is the beta-coefficient of interact in the following regression. The command then creates a tempvar, which we call sample, that indicates which observations were included in the regression (line 3). The command then calculates the first differences for control and treatment, respectively (lines 4, 5). The first difference results displayed in the table are the beta-coefficients of time. Finally, the command calculates baseline means for control and treatment, respectively (lines 6, 7).
 
<nowiki>generate interact = t * treat
=== Interaction Dummy Creation ===
regress varA time treat interact
The command creates the interaction variable in a 'tempvar' but for the simplicity of this description we will use a regular variable and name it 'interact'. Stata treats a 'tempvar' the same as a regular variable, but a 'tempvar' is automatically deleted when the command finishes. This is how the interaction variable is created:
generate sample = e(sample)
 
regress varA time if treat == 0 & sample == 1
<code>generate interact = t * treat</code>
regress varA time if treat == 1 & sample == 1
 
mean varA if time == 0 & treat == 0 & sample == 1
=== Difference-in-Difference ===
mean varA if time == 0 & treat == 1 & sample == 1</nowiki>
While the difference-on-difference result is presented in the last column in the table, this is the first statistics calculated as this command is used to restrict the sample when calculating the following statistics. This is because the sample for all other statistics estimations are restricted to not include any observation dropped in the difference-in-difference regression due to missing values in any variable used.
The tempvars are automatically deleted when the command ends.
 
The difference-in-difference result displayed in the table is the beta-coefficient of interact in the following regression.  
 
<code>regress varA time treat interact</code>
 
A 'tempvar' indicating which observations were included in the regression above, let's make that variable a regular variable and call it 'sample' in this example.
 
<code>generate sample = e(sample)</code>
 
=== First Difference ===
The first differences, where the first difference results displayed in the table are the beta-coefficients of time, are calculated like this:
 
For control: <code>regress varA time if treat == 0 & sample == 1</code>
 
For treatment: <code>regress varA time if treat == 1 & sample == 1</code>
 
=== Baseline means ===
The baseline means are calculated like this:
 
For control: <code>mean varA if time == 0 & treat == 0 & sample == 1</code>
 
For treatment: <code>mean varA if time == 0 & treat == 1 & sample == 1</code>


== Back to Parent ==
== Back to Parent ==
This article is part of the topic [[Stata_Coding_Practices#ietoolkit|ietoolkit]]
This article is part of the topic [[Stata_Coding_Practices#ietoolkit|ietoolkit]]
 
== Additional Resources ==
*Read more about <code>ietoolkit</code> [https://github.com/worldbank/ietoolkit here] on GitHub
[[Category: Stata ]]
[[Category: Stata ]]

Latest revision as of 17:53, 4 June 2019

ieddtab is a Stata command that estimates and outputs differences in differences results in well-formatted tables. It is a useful command for conducting data analysis and exporting results in a reproducible manner. This page describes how to use the command and how it works.

Read First

  • This command is a part of the package ietoolkit. To install all the commands in this package including ieddtab, type ssc install ietoolkit in Stata.
  • For detailed instructions on how to implement the command in Stata, type help ieddtab in Stata.

Overview

ieddtab is a Stata command that estimates and outputs differences in differences results in well-formatted tables. To run ieddtab in its most basic form, you need three variables: the outcome variable, a dummy variable that indicates treatment vs. control assignment and a dummy variable that indicates whether the observation comes from baseline vs. endline. In this example, these variables are varA, treat, and t, respectively. The basic implementation of the command is:

 ieddtab varA, time(t) treatment(treat) 

The command estimates five statistics for each outcome: the baseline means of the outcome for treatment = 0 and treatment = 1; the first difference regression coefficient of the outcome for treatment = 0 and treatment = 1; and the second difference. The baseline means represent the starting average for each group, the first differences represent the trend in each group between the two time periods, and the second difference represents the impact effect as estimated by a difference-in-difference model.

The command then outputs the results into a well-formatted table.

How it Works

This section explains how ieddtab estimates results, using the variables specified in the above example (varA, treat, t). The user does not need to know the following backend information in order to implement the command: this section is intended solely to enhance user understanding. Note that, for simplicity, any tempvars mentioned in this section are represented as normal variables.

The command first creates an interaction tempvar, which we call interact (line 1). The command then calculates the difference-in-difference result (line 2). The difference-in-difference result displayed in the table is the beta-coefficient of interact in the following regression. The command then creates a tempvar, which we call sample, that indicates which observations were included in the regression (line 3). The command then calculates the first differences for control and treatment, respectively (lines 4, 5). The first difference results displayed in the table are the beta-coefficients of time. Finally, the command calculates baseline means for control and treatment, respectively (lines 6, 7).

generate interact = t * treat
regress varA time treat interact
generate sample = e(sample)
regress varA time if treat == 0 & sample == 1
regress varA time if treat == 1 & sample == 1
mean varA if time == 0 & treat == 0 & sample == 1
mean varA if time == 0 & treat == 1 & sample == 1

The tempvars are automatically deleted when the command ends.

Back to Parent

This article is part of the topic ietoolkit

Additional Resources

  • Read more about ietoolkit here on GitHub