View
218
Download
1
Category
Preview:
Citation preview
Empirical Research in Economics Using Stata
Jeehoon Hanjhan4@nd.edu
Fall 2017
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Course Information
I Classroom: Jenkins Nanovic Hall B077
I Meeting Times: Fridays 10:00 AM - 11:15 AM
I Office Hours (tentative): Wednesdays 3 PM - 5 PMat Jenkins Nanovic Hall 3002 (or by appointment)
I Temporary Course Website: jeehoonhan.weebly.com
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Course Information
I Target: students who have basic knowledge of statistics, butdo not have prior experience with Stata
I Goal:I Efficiently learn nuts and bolts about Stata
I Be able to conduct an independent research project usingStata
I How:I Focus on hands-on experience using Stata
I Useful Stata techniques and tips for analyzing data
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Course Information
I Course Materials: lecture slidesI Reference: Microeconometrics Using Stata: Revised Edition
by A. Colin Cameron and Pravin K. Trivedi
I Expectations:I To do: attend class, turn in assignments on time
I Not to do: be late to class, engage in academic dishonesty
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Course Information
I Evaluations:I Three problem sets (60%): hands-on practice
manipulating/analyzing data using Stata
I A research project (40%): address research questions thatinterest you
I Abstract
I Visual inspection and a table of summary statistics
I Regression analysis
I Stata do file and log file
I Recommended data sources: Integrated Public Use MicrodataSeries (https://www.ipums.org/)
I Talk with me about your idea for the project during office hours
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Introduction to Stata
I Most commonly used software in applied microeconomicresearch
I Provide a wide variety of statistical analyses and graphsI handle panel, time series, and clustered data
I Easy to learn and useI Intuitive syntax and language
I A wealth of resources for learning:built-in manuals, online tutorials, user-written commands
I Read and write data in different formats
I export results to other formats such as Excel and LaTeX
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
What Stata Looks Like
I Command: where you type commands
I Results: outputs will appear here
I Review: list commands you have usedI click on a command to transfer it to the command window,
double-click for execution
I Variables: show variables in the dataset
I Properties: show properties of variables/datasetJeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
How to Enter Commands?
1. Type in the command window
2. Use the menus and dialogsI might be useful when building graphs or trying out complex
statistical analyses
3. Write commands in a “do” file and execute the fileI Convenient to manage and analyze data
I Store and edit commands, and reproduce results
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Command Syntax
I [by varlist :] command [varlist ] [if ] [in] [weight ] [, options]I square brackets: optional qualifiers
I by varlist : repeat the command for each group in varlist
I varlist : a list of variable names
I if and in: apply the command only to a subset of observations
I help command: show syntax diagrams, options, andexamples for command
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Examples: SummarizeI sysuse lifeexp.dta
I sum lexp
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Examples: Summarize
I bysort region: sum lexp
I sum lexp in 1/5
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Examples: Summarize
I sum lexp if lexp>70
I Common Mistakessum lexp if lexp=70
⇒ sum lexp if lexp==70
sum lexp if lexp=70|71
⇒ sum lexp if lexp==70|lexp==71
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Opening and Saving Data
I mkdir ‘‘C:\Intro Stata’’
cd C:\Intro Stata
use C:\Datafolder\filename, clear
sysuse filename
webuse filename
save ‘‘C:\Intro Stata\filename’’, replace
I mkdir: create a directory
cd: change directory
use: load the specified dataset into memory
, clear: clear the current data in memory before open a new data
sysuse: load example datasets installed with Stata
webuse: load datasets from Stata website
save filename, replace: save a file and overwrite any previous file
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Log File
I cd C:\Intro Stata
sysuse lifeexp.dta, clear
capture log close
log using class1.log, replace
set more off
save ”C:\Intro Stata\lifeexp.dta”, replace
log close
I capture: let the do-file continue without reporting outputs
log close: close any log file open
set more off: continue to scroll outputs when the screen fills with them
log using filename.log: start a text file that will records everything in
results window
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Log File
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Loading Non-Stata Format Dataset
I Read a text file with delimited format
I If there is one observation per line:import delimited filename
I Otherwise:infile varlist using filename
I Example: a text file separated by tabs
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Loading Non-Stata Format Dataset
I Read a text file with fixed formatinfix varlist [#-#] using filename
where [#-#] are the column locations for variables
I Example
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Loading Non-Stata Format Dataset
I Read an excel fileimport excel filename, sheet(‘‘sheetname’’)
cellrange([start][:end]) firstrow
sheet(“sheetname”): specifies the worksheet to loadcellrange([start][:end]): specifies the range of cells to loadfirstrow: treat observations in the 1st row of the excel file as variable names
I Use menus and dialog boxes
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Loading Non-Stata Format Dataset
→
↙
→
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Questions in Last Week’s Class
I Q. How to clear the result window?
I A. cls
I Q. Why do we need a log file when we have a do file?
I A. a log file is useful sometimesI Look at outputs without executing a do file
I Debug a do file running on linux server
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Creating and Changing Variables
I sysuse uslifeexp, clear
drop if year<1970 | year>=1980
(keep if year>=1970 & year<=1980 & year!=1980)
drop le *
rename le life exp
I drop (keep): remove (keep) variables/observations in the data
|: or (&: and, !: not)
le *: all variables starting with le
rename: change the name of variables
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Creating and Changing Variables
I gen high lexp = 0
replace high lexp = 1 if life exp>72
recode life exp (min/72 = 0) (else = 1),
gen(High lexp)
bysort year: egen avg lexp = mean(life exp)
gen first yr = year[1]
gen years elapsed = year[ n]-year[1]
gen num obs = N
I gen: create new variables
replace : change the values of existing variables
recode : change the values of numeric variables
egen: create variables containing summary measures such as mean
varname[#]: observation # of varname
n ( N): current observation number (total number of observations)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Labels and Notes
I Label dataset and variablesI label data ‘‘label ’’
I label variable varname ‘‘label ’’
I Label valuesI label define labelname # ‘‘label ’’
label values varname labelname
I [, options]I add: add new items (#↔‘‘label ’’) to labelnameI modify: change the existing itemsI replace: redefine the existing value labels
I Displaying labelsI describe: displays variable and value labels
I label list: displays the contents of value labels
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Labels and Notes
I Ways to insert commentsI *: the entire line is ignored. Can be put only at the beginning
of a line
I /* */: everything inside /* */ is treated a comment
I //: the rest of the line after // is treated as a comment
I ///: the same function as // except that it makes the next linejoint the current one (when used at the end of a line)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Labels and NotesI sysuse lifeexp.dta, clear
I label list
I ∗ Redefine labels for region categories
label define region 1 ‘‘Europe-Central Asia’’ ///
2 ‘‘North America’’ 3 ‘‘South America’’, replace
/∗ notes: the original labels were: 1 ‘‘Eur &
C.Asia’’ 2 ‘‘N.A.’’ 3 ‘‘S.A.’’∗/tab region
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Handling Long Lines
I Utilize the comment indicators (/// and /* */):I replace logvar = /*
*/ ln(var1) /**/ if var1 >0 /*
I #delimit; : change the delimiter to a semicolonI #delimit ;
replace logvar = ln(var1)if var1 >0 ;replace logvar = .if var1 ==0 ;#delimit cr
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Storage TypesI Storage types
I Numbers (digits of accuracy)I Integers: byte(2), int(4), long(9)
I Floating points: float(7), double(16)
I Strings: str1, str2, ..., str#
where str# can hold words with # characters or less
I The default storage type is float
I Storing a variable containing numbers > 7 digitsI 8-9 digit integer: gen long varname
I Otherwise: gen double varname
I Changing the storage type of an existing variable:recast type varname
I Use compress to save memory by storing variables in the smallesttypes without losing precision
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Storage Types: ExampleI set obs 1
gen var = 0.2
tab var if var == 0.2
⇒ no observation
I ProblemsI Numbers are stored in binary form and most decimals have no
exact representations in binary (0.2→ 0.00110011...)
I 0.2 is stored as 0.20000000298023224 in float
0.20000000000000001 in double
I When you create the variable var, 0.2 is stored in float
but Stata does all calculations in double precision
I Two ways to deal with this issueI Store data as double
I tab var if var==float(0.2)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Display Format
I Specify the display formatformat varlist %fmt
I Numeric formatsI Fixed format: %w.df
General format: %w.dg
where w : the total width of the displayd : the number of decimals (fixed format)
For general format, Stata decides the number of decimals todisplay (if d > 0, d indicates the maximum number of decimalplaces)
I String format: %wswhere w : the width of characters
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Display Format: example
I Default formatbyte, int: %8.0glong: %12.0gfloat: %9.0gdouble: %10.0g
I Examplesclear
set obs 1
gen double pi = 3.1415926535
list pi⇒ 3.1415927format pi %8.0 g⇒ 3.14159format pi %8.5 f⇒ 3.14159
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Inspecting DataI sysuse uslifeexp, clear
browse
I list
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Inspecting DataI describe
I codebook region
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Strings (pure text)� NumericsI String variable→ numeric variable
encode country, gen(country code)
I Numeric variable→ string variabledecode country code, gen(county str)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Strings (numeric text)� Numerics
I String variable→ numeric variable
I destring varlist, {gen(varname)|replace} [option]
I [option]
I ignore(‘‘chars’’): remove the nonnumeric charactersspecified
I force: treat any values containing nonnumeric characters asmissing values
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Strings (numeric text)� Numerics
I Example:use http://www.stata-press.com/data/r13/destring2
I destring price, gen(priceA) ignore(‘‘$ ,’’)
destring price, gen(priceB) force
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Strings (numeric text)� Numerics
I Numeric variable→ string variableI tostring varlist, {gen(varname)|replace} [option]
I [option]
I format(%fmt): convert using specified formatI force: convert to string even if it entails information loss
I tostring priceA, gen(price strA)
tostring priceA, gen(price strB) format(%8.1f) force
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Disconnect the Characters of VariablesI substr(str,(-)n,m): extract a substring from str starting at
position n (from the end of a string) for a length of m
I gen year = substr(date,1,4)
gen month = substr(date,6,2)
gen day = substr(date,-2,.)
I gen length = strlen(priceA)
gen decimal = substr(date,-2,.)
gen integer = substr(date,1,length-3)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Connect the Characters of Variables
I gen date1 = year+‘‘ ’’+month+‘‘ ’’+day
egen date2 = concat(year month day), punct(‘‘ ’’)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
SortI Arrange the data in ascending order
I sysuse uslifeexp, clear
I sort le sort year le
I gsort -year
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Sort: Applications
I Create a lagged variableI sort year
gen le lag = le[ n-1]
I Finding duplicatesI sort year
list if year == year[ n-1]
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Finding Variables
I List variables matching certain properties/patternsds [varlist] [, option]
I options
not: list all variables except varlistalpha: list in alphabetical orderdetail: show detailed outputhas(spec): list variables that meet specnot(spec): list variables that do not meet spec
I spec
type types (e.g., string, numeric, byte, str5)
format patterns (e.g., *f, *s, %9*)
varlabel patterns (e.g., Number*, *year*)
vallabel patterns (e.g., *old*, *yes*)
I ds leaves behind the names of variables in r(varlist) , which canbe used in following commands
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Finding Variables: example
I sysuse census, clear
describe
I ds, alpha
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Finding Variables: example
I ds pop*
I ds pop*, not
I ds, has(type string)
I ds, has(format %9*)
I ds, has(varl Number*)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Ordering Variables
I Rearrange variables in the dataorder [varlist] [, option]
I option
first: move varlist to beginning of data (default)last: move varlist to end of databefore(varname): move varlist before varname
after(varname): move varlist after varnamealpha: alphabetizes varlist and move to beginning of data
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Ordering Variables: exampleI sysuse census, clear
order all, alpha
⇒
I ds, has(type string)
order ‘r(varlist)’
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Dealing with Missing DataI Stata treats a missing numeric value (denoted by ., .a, .b, ..., .z) as
positive infinity (for string variable, a missing value is denoted by “ ”)
I A subject with missing data for any of the variables is excluded fromanalysis
I count if year>=1995
⇒ 6
count if year>=1995 & year<.
I sum year
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Dealing with Missing Data
I Finding missing valueslist if missing(year)
codebook year
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Dealing with Missing Data
I misstable sum
I egen tot miss = rowmiss( all)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Collapse
I Converts the data into a dataset of aggregate statistics
I Example: monthly⇒ annual data, county-level⇒ state-level data
I sysuse census, clear
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Collapse: example
I Create a dataset containing the average population of states foreach region
I preserve
collapse (mean) pop, by(region)
list
restore
I preserve: temporarily store the data(retrieve it when a program (do file) finishes)restore: bring the stored data back now
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Collapse: example
I collapse (mean) avg pop=pop ///
(median) med pop=pop, by(region)
list
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
MergeI Add variables to the existing dataset
I Require one or more variables that are common to both datasets
autosize.dta autoexpense.dta
⇓
webuse autosize.dta
merge 1:1 make using ///
http://www.stata-press.com/data/r13/autoexpense.dta
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
MergeI Many-to-one (one-to-many) match merge
ca unemp.dta capop.dta
⇓
use ca unemp.dta
merge m:1 county using ///
http://www.stata-press.com/data/r13/capop.dta
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Append
I Add new observations to the existing dataset
⇓
webuse capop.dta, clear
append using http://www.stata-press.com/data/r13/ilpop.dta
append using http://www.stata-press.com/data/r13/txpop.dta
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
ReshapeI Two Data Formats: Wide and LongI Example: A household survey collecting data about the household
and individuals
Wide format long format
Wide: The data about HH members are in different variablesLong: The data about HH members are in different observations
I Some data analyses are easier when the data is in long format
I Wide⇒ Longreshape long inc, i(hh id) j(person id)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
MacroI A name assigned to string/numeric characters
I Save time in typing a list of the same string/numeric characters
I global: persist until it is deleted or you exit Stata
local: accessible only in the current session/program
I local classfolder ‘‘N:\Econ 30300\’’cd ‘‘‘classfolder’’’
save ‘‘‘classfolder’class6’’, replace
I set obs 1
local a = 10
local b = 50
gen c = ‘a’+‘b’
display c
⇒ 60
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Macro
I sysuse nlsw88.dta, clear
describe
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Macro
I Regress wage on demographic characteristics// reg wage age married collgrad
local indepvar age married collgrad
local depvar wage
reg ‘depvar’ ‘indepvar’
I // reg wage age married collgrad if age>40
local age above 40 ‘‘if age>40’’
reg ‘depvar’ ‘indepvar’ ‘age above 40’
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Macro
I Some Stata commands automatically store results in macrossum wage
display ‘r(mean)’
⇒ 7.766949
display ‘r(max)’
⇒ 40.74659
ds * *
⇒ never marr∼d c city ttl exp
sum ‘r(varlist)’
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Loop
I foreach (forvalues): repeat commands over a list ofnumbers/strings (consecutive numbers)
I browse wage ttl exp tenure
convert values to integers
replace wage = round(wage)
replace ttl exp = round(ttl exp)
replace tenure = round(tenure)
I foreach var in wage ttl exp tenure {replace ‘var’ = round(‘var’)
}
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Loop
I reg wage age married collgrad
reg hours age married collgrad
reg tenure age married collgrad
local depvar wage hours tenure
local indvar age married collgrad
foreach var in ‘depvar’ {reg ‘var’ ‘indvar’
}
I forvalues i=35/40 {sum wage if age==‘i’
gen avg wage age‘i’= ‘r(mean)’
}
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
LoopI while: executing commands until the condition becomes false
I sysuse nlsw88.dta, clear
local i=41
while ‘i’<45 {di ‘i’
sum wage if age==‘i’
local i=‘i’+1
}
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Indicator Variable
I sysuse nlsw88.dta
I Potential determinants of wages: age, race, and education
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Indicator Variable
I reg wage age race collgrad ⇒WRONG
I Problemcodebook race
I The values in race are arbitrary and have no meaning
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Indicator Variable
I Method 1: generate and replace
gen white = 0
replace white = 1 if race==1
// you can do this with a single line:
// gen white = race==1
gen black = 0
replace black = 1 if race==2
gen other = 0
replace other = 1 if race==3
I Method 2: tabulate and generate
tab race, gen(group)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Factor Variable
I Method 3: factor variables (denoted by i.varname)
sum i.race, allbaselevels
I These are virtual variables that are not created in the datasetThe first level of a variable is treated as the base category
I reg wage i.race
Wagei = β0 + β1blacki + β2otheri
I Why drop one category? ⇒ Perfect Multicollinearity issue
whitei = 1− blacki − otheri
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Factor Variable
I Changing base levels
ib#.race: choose category # as a base value
sum ib3.race, allbaselevels
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Factor VariableI Does the choice of reference group matter?⇒ The answer depends on what you are interested inreg wage i.race
Wagei = 8.08− 1.24blacki + 0.47otheri
I reg wage ib3.race
Wagei = 8.55− 0.47whitei − 1.71blacki
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Factor Variable
I Interactions among variablesvar1#var2: all combinations of the categories of var1 and var2
reg wage collgrad#race, allbaselevels
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Factor VariableI Interactions with a continuous variable
c.var1#var2: the interactions of var1 (continuous variable) andi.var2
I var1##var2: i.var1 i.var2 var1#var2
reg wage c.age##race, allbaselevels
// reg wage age i.race c.age#race, allbaselevels
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Hypothesis Tests
I Testing whether a statement about a population parameter is true
I Steps of hypothesis testing
Step1. formulate a null hypothesis (H0) and an alternativehypothesis (Ha)
Step2. set the level of significance (α): the probability of rejectingH0 when H0 is true (type 1 error)
Step3. compute a test statistic (e.g., t-statistic for a population meanµ) using the sample data
Step4. compute the p-value using the test statistic
Step5. compare the p-value to α. Reject H0 if the p-value< α
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
t-test: Population Mean
I sysuse nlsw88.dta, clear
I Is the hourly earnings of women $8?ttest wage=8
I Cannot reject that the hourly wage of women is $8at the conventional significance level of 5%
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
t-test: Equality of Two MeansI Case1. When population variances are equal
I Is the average wage of college graduates different than that ofnon-college graduates?ttest wage, by (collgrad)
I There is a statistically significant difference in the wage betweencollege graduates and non-college graduates
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
t-test: Equality of Two MeansI Case2. When population variances are not equal
I Is there a wage gap between blacks and whites?ttest wage if race==1|race==2, by (race) unequal
I There is a statistically significant wage gap between whites andblacks
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Correlation
I ρX ,Y =cov(X ,Y )
σXσY=
E [(X − µX )(Y − µY )]
σXσY
: measures the strength of linear relationship between two variables
I correlation wage age hours
I corr: excludes observations that have any missing value in any ofthe variables in the list
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
CorrelationI pwcorr: excludes observations that have missing values for a
specified pair of variables
I pwcorr wage age hours, obs
I options
obs: display the number of observations used to calculate eachcoefficientsig: display the p-values for coefficientsstar(α): put * next to the coefficients when the p-value< αlistwise: use listwise deletion for treating missing data(the same way as corr handles missing data)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Hypothesis Test: Regression CoefficientI Examine the relationship between wage and age
Wagei = β0 + β1agei + εi
Test H0: β1 = 0 vs. H1: β1 6= 0I regression wage age
I t-test: t-statistic = -1.71, p-value= 0.087 > 0.05I Confidence Interval: The 95% CI for β1 contains 0
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Hypothesis Test: Regression CoefficientI Multiple regression
Wagei = β0 + β1agei + β2collgradi + εi
I regression wage age collgrad
I Testing individual significance (H0: β1 (β2) = 0)⇒ t-testI Testing overall significance (H0: β1 = β2 = 0)⇒ F-test: F-statistic = 87.71, p-value= 0.000 < 0.05
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Other Tests
I reg wage age collgrad
I H0 : β1 = β2 = 0 test age collgrad
I H0 : β1 = β2 test age=collgrad
H0 : β1 = −0.1 test age=-0.1
H0 : β0 + β1 ∗ 50 + β2 = 5 test con+age∗50+collgrad=5
I A variable name is used to represent the corresponding coefficient
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Interpreting Regression Coefficients
Wagei = β0 + β1agei + β2collgradi + εi
I E(wage) = 9.43− 0.064age + 3.61collgrad
For each additional year of age, the hourly wage decreases by $0.064,holding education level constant
People with a college degree earn $3.61 more than those without, holdingage constant
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Regression with Interaction terms
Wagei = β0 + β1agei + β2collgradi + β3agei ∗ collgradi + εi
I gen age collgrad = age*collgrad
reg age collgrad age collgrad
I E(wage) = 9.6− 0.07age + 2.89collgrad + 0.02age ∗ collgrad
E(wage|nocollgrad) = 9.6− 0.07age
E(wage|collgrad) = 12.49− 0.05age
I Can’t reject H0 : β3 = 0: the relationship between wage and age does notdepend on collgrad
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Regression with Interaction terms
Wagei = β0 + β1agei + β2collgradi + β3agei ∗ collgradi + εi
I Test for no effect of age on wage
∂wage∂age
= β1 + β3collgradi = 0 ⇒ β1 = 0 & β1 + β3 = 0
⇒ β1 = β3 = 0
I Test for no effect of collgrad on wage
∂wage∂collgrad
= β2 + β3agei = 0 ⇒ β2 = β3 = 0
I Test for no effect of collgrad on wage for women aged 40
∂wage∂collgrad
= β2 + β340 = 0 ⇒ β2 = −40β3
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Regression with Interaction terms
Wagei = β0 + β1agei + β2collgradi + β3agei ∗ collgradi + εi
I Test for no effect of age on wage for college graduates
∂wage∂age
= β1 + β3 = 0
I Test for no effect of age on wage for people w/o college degree
∂wage∂age
= β1 = 0
I Test whether the effect of age on wage depends on collgrad
β3 = 0
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Method 1. Copy and PasteI reg wage age ib3.race
⇓
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Method 1. Copy and PasteCopy table
Copy table as HTML
Copy as picture
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Method 2. eststo + esttabI eststo: reg wage age i.race
esttab
I commands for the right tableesttab, se mtitle(‘‘Model 1’’) nonumber label ///
nobaselevels r2
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Method 2. eststo + esttabI save the table in a specific format
esttab using filename.format
where format includes smcl, txt, csv, html, rtf
I Exampleesttab using result.txt, replace se ///
mtitle(‘‘Model 1’’) nobaselevels
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Stored Results: r() & e()I r-class (e-class) commands store results in r() (e())I sum age
return list
I Example:di r(N)⇒ 2246di “# obs: ‘r(N)’”⇒ # obs: 2246
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Stored Results: r() & e()I reg wage age ib3.race
I ereturn list: List results stored in e()
I Example:di e(N)⇒ 2246di e(r2)⇒ .01089375di e(depvar)⇒ wagematrix list e(b)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Method 3. putexcel
I putexcel: export results to an Excel file
I putexcel set ‘‘result.xls’’, sheet(‘‘A’’) replace
putexcel A1=(‘‘Command’’) B1=(e(cmdline))
putexcel A2=(‘‘Coefficients’’) B2=(‘‘b1’’) C2=(‘‘b2’’) ///
D2=(‘‘b3’’) F2=(‘‘ cons’’)
putexcel B3=matrix(e(b))
putexcel A4=(‘‘R-square’’) B4=(e(r2))
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Method 4. outreg2I Install a user-written command outreg2
ssc install outreg2
I Summary statisticsoutreg2 using summary stats.doc, replace sum(log) ///
keep (wage age) eqkeep (N mean sd) title(Summary stats)
summary stats.doc⇒ open the file from inside Statadir:seeout ⇒ open the table in the data browser
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Method 4. outreg2I Regression results
reg wage age i.race
outreg2 using regression.doc, replace ///
title(Regression results) ctitle(Model 1)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Method 4. outreg2I reg wage age c.age#c.age i.race
outreg2 using regression.doc, append ctitle(Model 2)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Method 4. outreg2I reg wage age c.age#c.age i.race
outreg2 using regression.doc, replace title(Regression) ///
ctitle(Model 1) keep(age c.age#c.age) stats(coef se) ///
bdec(2) sdec(2) label addstat(F-stat, e(F)) nocons
I For more details on outreg2
help outreg2
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
GraphsI sysuse nlsw88.dta, clear
histogram wage
(bin=33, start=1.0049518, width=1.2042921)
I options
bin(#): specify the number of binswidth(#):specify the bin widthstart(#):specify the minimum value of a variablefrequency:change the scale of x axis to frequencynormal:add a normal density curve
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
HistogramI gen ln wage = ln(wage)
hist ln wage, normal
I hist wage, by(collgrad) freq bin(10)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Bar chartI graph bar wage, over(collgrad)
graph bar wage, over(collgrad) asyvars ///
bar(1, color(blue)) bar(2, color(red)) bargap(10) ///
legend(label(1 ‘‘no-collgrad’’) label(2 ‘‘collgrad’’))
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
ScatterI sysuse census, clear
gen death rate = death/pop
scatter death rate medage
I scatter death rate medage || lfit death rate medage
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Scatter
I scatter death rate medage in 1/20, ///
mlabel(state2) || lfit death rate medage in 1/20
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Scatter
I scatter death rate medage in 1/20 [w=pop], ///
ms(circle hollow) || lfit death rate medage in 1/20
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Scatter
I scatter death rate medage, ms(T) mc(blue) ///
msiz(large) xt(Median Age) xl(24(4)36) ///
yt(Death Rate (%)) yl(0.004(0.004)0.012) ///
graphr(color(gs14)) plotr(color(eggshell)) ///
note(‘‘Data Source:Stata’’)
I Export graphsgraph export filename.format, replace
where format includes png, pdf, tif, ps, eps, and svg
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
LineI sysuse uslifeexp.dta, clear
line le male le female year, legend(off)
I line le male le female year, lpattern( -)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Line
I #delimit;
scatter le male le female year, connect(l l)
msymbol(x o) mcolor(green orange) lcolor(green orange);
#delimit; crJeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Line
I #delimit;
line le male le female year,
xline(1918, lpattern(dash)) tit(Life Expectancy by Sex)
subt(Years 1900-1999) xt(Year) yt(Life Expectancy)
legend(lab(1 ‘‘Males’’) lab(2 ‘‘Females’’)) ;
#delimit; cr
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Line
I #delimit;
twoway scatteri 80 1929 80 1941, recast(area) color(gs12)
|| line le male le female year, yt(Life Expectancy)
legend(order(1 ‘‘Great Depression’’) pos(11));
#delimit; cr
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Regression CoefficientsI sysuse nlsw88, clear
reg wage married south union
I ssc install coefplot
coefplot, drop( cons) xline(0)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Regression Coefficients
I reg wage married south union if collgrad==1
est store collgrad
reg wage married south union if collgrad==0
est store noncollgrad
coefplot collgrad noncollgrad, drop( cons) xline(0)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Regression Coefficients
I #delimit;
coefplot (collgrad, label(College Graduates) pstyle(p4)
offset(0.05)) (noncollgrad, label(Non College Graduates)
pstyle(p2) offset(-0.05)), msymbol(S) drop( cons)
yline(0) vertical;
#delimit; cr
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Maps
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Maps
I Step1. Install commandsssc install shp2dta
ssc install spmap
Step2. Download a geographic boundary file (shapefile)https://www.census.gov/geo/maps-data/data/tiger-cart-boundary.html
Step3. Convert the file into a Stata fileshp2dta using gz 2010 us 040 00 5m, replace ///
database(statemap) coordinates(coord) genid(id)
use statemp, clear
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
MapsI Step4. Merge with population data
sysuse census, clear
replace state =‘‘North Carolina’’ if state ==‘‘N. Carolina’’
replace state =‘North Dakota’’ if state ==‘‘N. Dakota’’
replace state =‘‘South Carolina’’ if state ==‘‘S. Carolina’’
replace state =‘‘South Dakota’’ if state ==‘‘S. Dakota’’
replace state =‘‘West Virginia’’ if state ==‘‘W. Virginia’’
rename state NAME
keep NAME pop
merge 1:1 NAME using statemap
Step5. Create a mapspmap pop using coord if id!=2 & id!=12 & id!=52, id(id) ///
fcolor(Blues) title(‘‘State Population 1980’’) ///
legend(size(medium))
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Time SeriesI Time Series: a sequence of observations collected over time
I sysuse sp500, clear
line close date
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
ts commandsI Declare the dataset to be time series
tsset date
I Subset the datalist close if tin(11jan2001,16jan2001)
list close if twithin(11jan2001,16jan2001)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
ts commandsI Fill in gaps in the data with new observations (missing values)
tsfill
I tsline close, tline(11sep2001) ///
ttext(1400 11sep2001 ‘‘September 11’’)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Lag and Lead operatorsI gen lag1 = L1.close⇒ closet−1
gen lead1 = F1.close⇒ closet+1
gen diff1 = D1.close⇒ closet − closet−1
gen diff2 = D2.close
⇒ (closet − closet−1)− (closet−1 − closet−2)gen season2 = S2.close⇒ closet − closet−2
I reg close L1.close L2.close
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Handling unformatted time variableI sysuse sp500, clear
keep close
gen date = n
I Change the values of time variable to Stata Internal Form (SIF)values
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Handling unformatted time variable
I Example1. Daily data with the starting date of 01jan2001gen new date = td(01jan2001) + date -1
format new date %td
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Handling unformatted time variableI Example2. Monthly data with the starting month/year of 01/2001
gen yrm = tm(2001m1) + date -1
format yrm %tm
I Example3. Quarterly data with the starting quarter/year of q1/2001gen yrq = tq(2001q1) + date -1
format yrq %tq
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Handling unformatted time variable
I Conversion between SIFsI SIF date⇒ SIF monthly variable
gen monthly = mofd(new date)
format monthly %tm
I SIF date⇒ SIF quarterly variablegen quarterly = qofd(new date)
format quarterly %tq
I SIF monthly⇒ SIF quarterly variablegen new quarterly = qofd(dofm(monthly))
format new quarterly %tq
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Handling unformatted time variable
I Extract components from SIFsI Extraction from SIF date variable
gen day = day(new date)
gen week = week(new date)
gen month = month(new date)
gen year = year(new date)
I Extract month from SIF monthly variablegen month1 = month(dofm(monthly))
I Extract year from SIF quarterly variablegen year1 = year(dofq(quarterly))
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Panel DataI Panel data: repeated observations for many subjects over time
I webuse nlswork, clear
I Declare the dataset to be panelxtset idcode year
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Panel Data
I xtdescribe
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Panel DataI xtline ttl exp if idcode<7, overlay
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Fixed Effect Model
I Cross-sectional data
log(wage)i = α+ β1agei + β2work experiencei + εi
I Issue: omitted variable problemI high-ability individuals tend to have more work experience
⇒ Cov(εi ,work experiencei) 6= 0
I Fixed Effect model with panel data
log(wage)it = αi + β1ageit + β2work experienceit + εit
I αi : accounts for any time-invariant individual characteristics
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Fixed Effect ModelI reg ln wage age ttl exp i.idcode
I Too many indicator variables (>4,700)
I Solution: areg (reghdfe for many levels of FEs)areg ln wage age ttl exp, absorb(idcode)
I Differences from reg:1) No coefficients for idcode2) Dummies for idcode are not included in the F test on top right corner3) A new F test for idcode (H0 : all coefficients for idcode are jointly 0) atthe bottom
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Fixed Effect ModelI Two-way fixed effects model
log(wage)it = αi + γt + β1ageit + β2work experienceit + εit
I γt : accounts for any shocks that affect the wages of allsubjects equally
I reg ln wage age ttl exp i.year, absorb(idcode)
I The coefficient on ttl exp indicates: each additional year of workexperience is associated with 4.2% hourly wage increase controlling forage, any time-invariant individual characteristics (individual fixed effect),and population-wide wage trends (year fixed effect)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Question 16 in PS3
I PRs = β0 + β1HPs + β2HMs + β3GDs + β4HPsHMs
+ β5HPsGDs + β6HMsGDs + β7HPsHMsGDs + εs
I Test whether the relationship between state’s poverty rate and populationdepends on the political party of the Governor for high minimum wagestates
I High minimum wage states⇒ HMs = 1
PRs = β0 + β1HPs + β2 + β3GDs + β4HPs
+ β5HPsGDs + β6GDs + β7HPsGDs + εs
I Test for no relationship between PRs and HPs
∂PR∂HP
= β1 + β4 + β5GDs + β7GDs = 0
I Test whether the relationship between PRs and HPs depends on GDs
β5 + β7 = 0
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Robust Standard ErrorsI An OLS regression model assumes var(εi |Xi) = σ2 for all i
I Results of violations: the standard error is biased
I Example: the relationship between car weight and fuel efficiencywebuse auto.dta, clear
scatter mpg weight || lfit mpg weight
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Robust Standard Errors
I Use a residual plot to identify heteroscedasticityreg mpg weight
rvpplot weight, yline(0)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Robust Standard Errors
I Solution: heteroscedastic-robust standard errors: vce(robust)reg mpg weight
reg mpg weight, vce(robust)
I No change in the point estimate, but the standard error is larger
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Instrumental Variable
I Another assumption in an OLS regression model: The errors areuncorrelated with the regressors: Cov(εi ,Xi) = 0
Y↗ ↖
X 8 ε
I Consequences of violation: the effect of X on Y is biased andinconsistent
I Potential causes:I Simultaneous causality
I Omitted variables
I Measurement errors
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Instrumental Variable
I Example: The effect of food stamps on consumption
I Simultaneous causality: Changes in food consumption affectthe decision to participate in food stamps
I Omitted variables: unexpected negative income shock willaffect both food stamps participation and the level ofconsumption
I Measurement errors: In the most household surveys, peopletend to under-report their food stamps benefit receipt
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Instrumental Variable
I Solution: find a variable Z that is:1) associated with X (Relevance)2) not correlated with any other determinants of Y
(Exclusion Restriction)
Y↗ ↖
X ← ε↖
Z
I Two-stage Least Squares (2SLS) using the instrument Z1st stage: Xi = π0 + π1Zi + νi
2nd stage: Yi = β0 + β1X̂i + εi
Reduced form: Yi = ρ0 + ρ1Zi + ξi
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
The impact of schooling on earnings
I OLS: Log(wage)i = β0 + β1Schoolingi + OtherCharactersiγ + εi
I Problem: Unobserved ability can affect both years of schooling andwage
I Instrument for schooling: proximity to college (Card, 1995)I Idea: youths who live near a college are more likely to go to college
than those who live farther away
I First-StageSchoolingi = π0 + π1Live Near Collegei + OtherCharactersiγ + νi
I Second-StageLog(wage)i = β0 + β1 ̂Schooling i + OtherCharactersiη + εi
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
The impact of schooling on earningsI use http://www.stata.com/data/jwooldridge/eacsap/card
reg lwage educ black exper, vce(robust)
I ivreg2 lwage (educ=nearc4) black exper, robust first
I First-Stage
I Second-Stage
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
The impact of schooling on earnings
I Another instrument for schooling: quarter of birth (Angrist andKrueger (1991))
Idea: Individuals born in early in the year have more schooling thanthose born late in the year
Why? compulsory schooling laws: students start first grade whenthey turn 6 and have to stay until their 16th birthday
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
The impact of schooling on earningsI First-Stage
I IV results
I Is schooling the only channel through which QOB affects wage?
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
The impact of schooling on earningsI Buckles and Hungerman (2013) find that women giving birth in the
winter are younger, less educated, and less likely to be married
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
The impact of schooling on earnings
I Controlling for family background characteristics, therelationship between season of birth and later outcomesbecomes weaker
I Difficult to find an instrument that satisfies the exclusionrestriction condition
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Sampling Design
I Interest: The height difference between male and female NDundergraduates
I How to choose a sample?I Simple random sampling (SRS): each member of the
population has the equal chance of being chosenI Obtain the list of all students (8,600) and randomly contact 800
students and measure their heights
I Purpose: the sample is representative of the population
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Sampling Design
I Cluster sampling: divide the population into groups (clusters). Thenrandomly select clusters from the population
I Divide students into groups based on their dorms (31 dorms).Randomly choose three dorms and measure the heights of allstudents in those dorms
I Purpose: reduce the cost of collecting the sample
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Sampling Design
I Stratified sampling: divide the population into groups based oncharacteristics of importance for the study. Then select a randomsample within each group
I Divide students into male and female. Randomly choose 400students from each group
I Purpose: ensure enough members in the target group
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Sampling Design: ExampleI Interest: the average household income in the U.S.I Concern: expensive to travel to all over the U.S.
SRS Cluster Sampling
I ClusteringI First, select regions, then areas within regions, and then finally
a sample of households within areas.
I Clusters: regions and areasI Primary sampling units (PSUs): regions
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Sampling Design: ExampleI Interest: the income gap between African-American and White
AmericanI Concern: African-Americans are more likely to live in rural areas
SRS Stratified Sampling
I StratificationI Divided the country into urban and rural areas, then select a
sample of subareas from each area, and then select a sampleof households within subareas.
I Strata: Rural and Urban areasJeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Sampling Design: ExampleI Sampling weight: the inverse of the probability of being sampled
I The population consists of 200 HHs in rural area and 1,200HHs in urban area.Choose a stratified sample of 300 HHs: 100 HHs from ruralarea and 200 HHs from urban area
I Each household that is selected from rural (urban) area represents2 (6) households in the population
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Using Stata to Analyze Survey Data
I svyset [psu] [pweight=weight] [, strata(varname)]
I svyset: declare survey design for datasetpsu: primary sampling units (clusters)weight: sampling weight for each observationstrata(varname): stratification variable
I Syntax for statistical analysisI svy: command (e.g., tab, mean, reg)
I Syntax for sub-population analysisI svy, subpop(if exp): command
I svy, over(varname): command
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Example: Second National Health and Nutrition Examination Survey
I webuse nhanes2d, clear
describe
I svyset psu [pweight=finalwgt], strata(strata)
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Example: Second National Health and Nutrition Examination SurveyI reg diabetes sex age i.race height weight
I svy: reg diabetes sex age i.race height weight
I Estimates are adjusted for the sample design effect
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
References
I http://personal.lse.ac.uk/lembcke/ecStata/2010/
MResStataNotesOct2010PartA.pdf
I https://stats.idre.ucla.edu/stata/modules/
I https://www.princeton.edu/~otorres/
I http://www.cpc.unc.edu/research/tools/data_
analysis/statatutorial
I http://data.princeton.edu/stata/
I http://libguides.library.nd.edu/stata
Jeehoon Han jhan4@nd.edu Empirical Research in Economics Using Stata
Recommended