-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathChapter10.do
More file actions
81 lines (55 loc) · 2.68 KB
/
Copy pathChapter10.do
File metadata and controls
81 lines (55 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
*******************************************************************************
*General Do-File Header*
clear all //clear memory
capture log close //close any log-files (if still running)
*version 15.0 //your current version, change this to your version (and remove asterisk)!
set more off //do not halt to show all output
*******************************************************************************
*cd "path" //enter the path to your working directory and uncomment this line
sysuse nlsw88, clear //open the dataset
*set scheme plotplain //Uncomment if you want to use the same style as in the book
**********************************************************************
*Creating Tables
**********************************************************************
***Model 1***
regress wage c.ttl_exp //Only include work experience
estimates store M1 //Save results
***Model 2***
regress wage c.ttl_exp i.union i.south //Add binary variables
estimates store M2 //Save results
***Model 3***
regress wage c.ttl_exp i.union i.south i.race //Add ordinal variable
estimates store M3 //Save results
*Produce output*
estimates table M1 M2 M3, se stats(r2 N)
*Change number format*
estimates table M1 M2 M3, se stats(r2 N) b(%7.3f) se(%7.2f)
***Using the estout-Ado***
ssc install estout, replace //Install ado
eststo M1: regress wage c.ttl_exp
eststo M2: regress wage c.ttl_exp i.union i.south
eststo M3: regress wage c.ttl_exp i.union i.south i.race
esttab M1 M2 M3 using "new_table.rtf" //Output table in current working directory
esttab M1 M2 M3 using "new_table.rtf", nogaps nomtitles r2 ///
star(# 0.10 * 0.05 ** 0.01 *** 0.001) b(3) se label replace
**********************************************************************
*Creating Graphs
**********************************************************************
ssc install coefplot, replace //Install ado
quietly regress wage c.ttl_exp i.union i.south i.race
coefplot, xline(0) //Create vertical line at zero
quietly regress wage c.ttl_exp i.union i.south i.race
margins //Show average wage when all variables are at the mean
margins, atmeans //Show the means for all variables
margins, at(ttl_exp=(0(5)30)) //Compute predicted values for certain values of job experience
marginsplot
margins union, at(ttl_exp=(0(5)30)) //Furthermore differentiate by union status
marginsplot
margins union, at(ttl_exp=(0(5)30) south=(0 1)) //Subgraphs by union status
marginsplot
marginsplot, by(south)
*Including an interaction between job experience and itself to account
*for higher ordered terms
regress wage c.ttl_exp##c.ttl_exp i.union i.south i.race //Run new regression model
margins union, at(ttl_exp=(0(5)30) south=(0 1))
marginsplot, by(union)