Difference between revisions of "Ieddtab"
Kbjarkefur (talk | contribs) |
|||
(11 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
<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. | |||
==Read First== | |||
*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. | |||
* For detailed instructions on how to implement the command in Stata, type <code>help ieddtab</code> in Stata. | |||
=== | ==Overview== | ||
<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: | |||
<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. | |||
The command then outputs the results into a well-formatted table. | |||
== | ==How it Works == | ||
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. | |||
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 | |||
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</nowiki> | |||
The tempvars are automatically deleted when the command ends. | |||
== 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 includingieddtab
, typessc 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