Oct 3, 2015

Firebaugh (1997): Analyzing Repeated Surveys in Stata (ch. 3)




set maxvar 6000
use GSS7214_R4.DTA, clear

fre sample
// Try to recreate sample
drop if sample == 4 // FP 1970 Black oversample
drop if sample == 5 // BFP 1980 Black oversample
drop if sample == 7 // FP 1980 Black oversample

// Retirement status
fre wrkstat

generate retired_others  = (wrkstat == 5)
generate retired_workers = (wrkstat == 5)
replace  retired_workers = . if inlist(wrkstat, 7, 6, 8) // Exclude homemakers, 
                                                         // students, and others
// Spending on education
gen ed_toolittle = 0
replace ed_toolittle = 1 if nateduc == 1 & !missing(nateduc)
replace ed_toolittle = 0 if nateduc  > 1 & !missing(nateduc)
replace ed_toolittle = . if missing(nateduc)

gen ed_toomuch = 0
replace ed_toomuch = 1 if nateduc == 3 & !missing(nateduc)
replace ed_toomuch = . if missing(nateduc)

// Spending on social security
gen ss_toolittle = 0
replace ss_toolittle = 1 if natsoc == 1 & !missing(natsoc)
replace ss_toolittle = 0 if natsoc  > 1 & !missing(natsoc)
replace ss_toolittle = . if missing(natsoc)

gen ss_toomuch = 0
replace ss_toomuch = 1 if natsoc == 3 & !missing(natsoc)
replace ss_toomuch = 0 if natsoc  < 3 & !missing(natsoc)
replace ss_toomuch = . if missing(natsoc)

eststo clear
// Table 3.1

preserve
keep if year >= 1973 & year <= 1993
gen trend = year - 1973

eststo: logit ed_toomuch     c.trend##retired_others
eststo: logit ed_toolittle   c.trend##retired_others
 
eststo: logit ed_toomuch     c.trend##retired_workers
eststo: logit ed_toolittle   c.trend##retired_workers

esttab est1 est2 est3 est4 using table3.1.tex, replace varwidth(50) ///
       booktabs label ///
       mgroups("Retirees vs. others" "Retirees vs. workers", pattern(1 0 1 0) ///
       prefix(\multicolumn{@span}{c}{) suffix(})   ///
       span erepeat(\cmidrule(lr){@span}))         ///
       alignment(D{.}{.}{-1}) page(dcolumn) nonumber ///
       b(%9.3f) not ///
       drop(0b.retired_others ///
            0b.retired_others#co.trend ///
            0b.retired_workers ///
            0b.retired_workers#co.trend ///
   _cons) ///
    rename(1.retired_others 1.retired_workers ///
              1.retired_others#c.trend 1.retired_workers#c.trend) ///
       coeflabels(1.retired_workers "Initial difference, retirees minus workers/others" ///
               trend "Trend for retirees" ///
      1.retired_workers#c.trend "Trend difference retirees minus workers/others" ///
                  1.retired_others "Initial difference, retirees minus others" ///
      1.retired_others#c.trend "Trend difference retirees minus workers/others") ///
       mlabels("\multicolumn{1}{c}{Too much}" ///
            "\multicolumn{1}{c}{Too little}" ///
      "\multicolumn{1}{c}{Too much}" ///
            "\multicolumn{1}{c}{Too little}") ///
       order(1.retired_workers trend 1.retired_workers#c.trend) ///
    title("Table 3.1: Trend analysis for spending on education, 1973-1993: Logit coefficients")

restore

// Table 3.2
preserve
keep if year >= 1984 & year <= 1993
gen trend = year - 1984

eststo: logit ss_toomuch   c.trend##retired_others
eststo: logit ss_toolittle c.trend##retired_others
eststo: logit ss_toomuch   c.trend##retired_workers
eststo: logit ss_toolittle c.trend##retired_workers

esttab est5 est6 est7 est8 using table32.tex, replace varwidth(50) ///
       booktabs label ///
       mgroups("Retirees vs. others" "Retirees vs. workers", pattern(1 0 1 0) ///
       prefix(\multicolumn{@span}{c}{) suffix(})   ///
       span erepeat(\cmidrule(lr){@span}))         ///
       alignment(D{.}{.}{-1}) page(dcolumn) nonumber ///
       b(%9.3f) not ///
       drop(0b.retired_others ///
            0b.retired_others#co.trend ///
            0b.retired_workers ///
            0b.retired_workers#co.trend ///
   _cons) ///
    rename(1.retired_others 1.retired_workers ///
              1.retired_others#c.trend 1.retired_workers#c.trend) ///
       coeflabels(1.retired_workers "Initial difference, retirees minus workers/others" ///
               trend "Trend for retirees" ///
      1.retired_workers#c.trend "Trend difference retirees minus workers/others" ///
                  1.retired_others "Initial difference, retirees minus others" ///
      1.retired_others#c.trend "Trend difference retirees minus workers/others") ///
       mlabels("\multicolumn{1}{c}{Too much}" ///
            "\multicolumn{1}{c}{Too little}" ///
      "\multicolumn{1}{c}{Too much}" ///
            "\multicolumn{1}{c}{Too little}") ///
       order(1.retired_workers trend 1.retired_workers#c.trend) ///
    title("Table 3.2: Trend analysis for spending on social security, 1984-1993: Logit coefficients")
restore

Reference

Firebaugh, Glenn. 1997. Analyzing Repeated Surveys. Sage. doi: 10.4135/9781412983396