* Author: William D. MacMillan * Prepared for ICPSR time-series and cross-section data analysis * 5/19/09 * A quick note, for display purposes, you will want a text editor that has "line wrap" turned on. * If a line is long, it will display as one really long line, unless you have the computer "wrap" it onto the next line for you. * another solution is to make it so that a carriage return is not a return in Stata. This is done with the #delimit command. * If you type #delimit; this makes it so that a command isn't finished until you type ; no matter how much white * space there is. * this command lets the computer scroll through results, without pause set more off * these two commands (three actually, capture and log close are two separate commands on the same line) close any existing log files * and start a new log. The capture suppresses errors, and allows the do file to keep going in case of an error. capture log close log using "D:\Documents and Settings\Administrator\Desktop\icpsr example garret data.log", replace text use "D:\Documents and Settings\Administrator\Desktop\garmit_esspanel1.dta", clear * this is a loop, this is so that I don't have to type 18 generate commands in by hand * the "i" is a macro, a short term storage device. To reference it you put the goofy quotes around it (`i') forvalues i = 1/18 { generate _cc`i' = 1 if cc == `i' replace _cc`i' = 0 if _cc`i'== . } reg spend unem growthpc depratio left cdem trade lowwage fdi _cc* * lets get rid of NZ, its just making our results messy. Also, lets try * another solution. Let's use the xi system for creating dummies. xi: reg spend unem growthpc depratio left cdem trade lowwage i.cc xi, noomit: reg spend unem growthpc depratio left cdem trade lowwage i.cc, nocons * We need to rerun our preferred model. * We'll do it quietly though, we don't need to see the output again drop if cc == 13 qui xi: reg spend unem growthpc depratio left cdem trade lowwage i.cc * testing a smaller combination of coefficients is as easy--just use either test, or testparm * testparm allows shortcuts in naming the coefficients to test testparm _Icc* * this command is not part of the base package--to install it, you type "findit whitetst" (ommitting the quotes) whitetst * here's another way to do this test, using loops * note that you need to run the regression again--whitetst ran one and it removed your results qui xi: reg spend unem growthpc depratio left cdem trade lowwage i.cc predict res, resid gen res2 = res^2 local varnames unem growthpc depratio left cdem trade lowwage foreach var of local varnames { foreach othervar of local varnames { gen `var'times`othervar' = `var'*`othervar' } } * I'm using a lot of shorthand here so its not as messy reg res2 `varnames' *times* _I* log close * to end do files, you need a blank line at the end--any command on the very end of the file is not used.