Event Analysis using Stata

Advanced Econometrics using Stata training workshop and tutorial. The following Stata code computes simple t-test to test the hypothesis that the variables are different between two time periods. The time periods have been defined based on pre-event and post-event time periods. Thus, we can employ this method to test an event impact on a few variables in a single script of the Stata code which also produces a single table ready for publication or inserting into a word document.

****Open the data file using the following code.
use "E:\Dropbox\Advanced Econometrics using Stata Trainings\data12.dta", clear

****The following two lines of codes creates a few temprary files in Stata to create and save the results in our analysis. The results will be available to call into Stata from the same temprary files.
tempname econometrics_ttest
tempfile ttests
postfile `econometrics_ttest' str12 name t_statistic swilk rankstat pearson fisher using `ttests'

****Now, loop over the given variables to be used for testing the hypothesis. These are the variables which will make the hypothesis to be tested on using Stata and following the simple t-test to verify the post-event variable values has equal greater average than the pre-event time period sample of the same variable.
foreach var of varlist  y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 {

****t-test is used to test the null hypothesis that the variable has equal means between post-event and pre-event samples for the variables. The -local-command saves the given statistics saved under the Stata routine r().
ttest `var', by(event)
local tstat = r(t)

****Shapiro Wilk test can be employed and produced results can be saved using the following code.
swilk `var'
local swilk = r(W)

****RankSum test is applied using the following code.
ranksum `var', by(event)
local rankstat = r(z)

****Chi-square tests can be employed using the following code.
median `var', by(event)
local pearson = r(chi2)
median `var', by(event) exact
local fisher = r(chi2_cc)

****The following code writes the produced and saved results in -local-s to the given variables defined under -postfile-.
post `econometrics_ttest' ("`var'") (`tstat') (`swilk') (`rankstat') (`pearson') (`fisher')
}

****These lines of the code closes the above temprary files, calculations and saving the results.
postclose `econometrics_ttest'
clear

****Call in the results to see the output of the above code.
use `ttests'

****Change any variable, their labels or create further statisticals.
label var t_statistic "Unequal Variance type t-Statistic"
rename name variable_name
label var variable_name "Variable Tested for Different in Mean Post minus Pre event"

****Now export the table which is already saved in form of a Stata file. This can be a simple table in a standard format.
export excel using "E:\Dropbox\Advanced Econometrics using Stata Trainings\tables_econometrics_research.xls", firstrow(variables) replace

****See the results.
list


Event Study Stata is one of the most interesting area that we can help you with. You can request a freelance project from our top freelancers in Stata to help you complete the event study even for a complex study. We handle Event Study using Stata for all kinds of data from cross sectional, panel data and time series. You can request a Event Study Stata help from our freelancers in econometrics and Stata using the following proforma.