use year age race partyid sex educ region if inlist(year, 1973, 1974, 1994) ///
using GSS7214_R4.DTA, clear
replace year = 1974 if year == 1973
// Create sample
drop if partyid == 7
keep if race < 3
keep if !missing(year, age, race, partyid, sex, educ, region)
// Create variables
generate strongdem = (partyid == 0) * 100
generate white = (race == 1)
generate south = inlist(region, 5, 6, 7)
generate y1994 = (year == 1994)
generate y1974 = (year == 1974)
generate female = (sex == 2)
replace age = age - 16 // Give 0 more meaningful value
drop sex region race partyid
// Table 6.2
reg strongdem y1994##white
estimates store ols
logit strongdem y1994##white
estimates store logit
esttab ols logit logit ///
, p wide eform(0 0 1) not ///
coeflabel(1.y1994 "1994 dummy" ///
1.white "White (ref. black)" ///
1.y1994#1.white "White X 1994 dummy" ///
_cons "Intercept") ///
drop(0b.y1994 0b.white ///
0b.y1994#0b.white ///
0b.y1994#1o.white ///
1o.y1994#0b.white) ///
mtitles("OLS" "Logit" "Odds ratios") varwidth(24)
// Table 6.3
logit strongdem y1994##white y1994##c.educ
estimates store logit
esttab logit logit
, p wide eform(0 1) ///
coeflabel(1.y1994 "1994 dummy" ///
1.white "White (ref. black)" ///
1.y1994#1.white "White X 1994 dummy" ///
educ "Education (in yrs.)" ///
1.y1994#c.educ "Education X 1994 dummy" ///
_cons "Intercept") ///
drop(0b.y1994 0b.white ///
0b.y1994#0b.white ///
0b.y1994#1o.white ///
0b.y1994#co.educ ///
1o.y1994#0b.white) ///
mtitles("Logit" "Odds ratios") varwidth(24)
// Table 6.4
logit strongdem y1974##white y1974##c.educ
estimates store logit
esttab logit logit ///
, p wide eform(0 1) ///
coeflabel(1.y1974 "1974 dummy" ///
1.white "White (ref. black)" ///
1.y1974#1.white "White X 1974 dummy" ///
educ "Education (in yrs.)" ///
1.y1974#c.educ "Education X 1974 dummy" ///
_cons "Intercept") ///
drop(0b.y1974 0b.white ///
0b.y1974#0b.white ///
0b.y1974#1o.white ///
0b.y1974#co.educ ///
1o.y1974#0b.white) ///
mtitles("Logit" "Odds ratios") varwidth(24)
// Table 6.5
logit strongdem y1994##white y1994##c.educ south female c.age##c.age
estimates store logit
esttab logit logit ///
, p wide eform(0 1) ///
coeflabel(1.y1994 "1994 dummy" ///
1.white "White (ref. black)" ///
1.y1994#1.white "White X 1994 dummy" ///
educ "Education (in yrs.)" ///
1.y1994#c.educ "Education X 1994 dummy" ///
south "South (ref. rest of US)" ///
female "Female (ref. male)" ///
age "Age" ///
c.age#c.age "Age squared" ///
_cons "Intercept") ///
drop(0b.y1994 0b.white ///
0b.y1994#0b.white ///
0b.y1994#1o.white ///
0b.y1994#co.educ ///
1o.y1994#0b.white) ///
mtitles("Logit" "Odds ratios") varwidth(24)
// Table 6.6
logit strongdem y1974##white y1974##c.educ south female c.age##c.age
estimates store logit
esttab logit logit
, p wide eform(0 1) ///
coeflabel(1.y1974 "1974 dummy" ///
1.white "White (ref. black)" ///
1.y1974#1.white "White X 1974 dummy" ///
educ "Education (in yrs.)" ///
1.y1974#c.educ "Education X 1974 dummy" ///
south "South (ref. rest of US)" ///
female "Female (ref. male)" ///
age "Age" ///
c.age#c.age "Age squared" ///
_cons "Intercept") ///
drop(0b.y1974 0b.white ///
0b.y1974#0b.white ///
0b.y1974#1o.white ///
0b.y1974#co.educ ///
1o.y1974#0b.white) ///
mtitles("Logit" "Odds ratios") varwidth(24)
The last tables of the chapter make use of an occupation variable that I cannot find in the data/I can't be bothered to harmonize the ones that I can find.
Oct 5, 2015
Firebaugh (1997): Analyzing Repeated Surveys in Stata (ch. 6)
Labels:
esttab,
General Social Survey,
Textbooks