--------------------------------------------------------------------------------------------------------------
      name:  res
       log:  /Users/alainpineda/Library/CloudStorage/GoogleDrive-alainpp25@gmail.com/My Drive/PhD/Projects/Tie
> nes IMSS/replication/output/ThemeF/ThemeF_results.txt
  log type:  text
 opened on:  20 Aug 2026, 14:43:55

. 
. 
. ********************************************************************************
. * SECTION 1: LONG DIFFERENCES
. ********************************************************************************
. * Cell construction verbatim from the "For LD" block of Tienes_IMSS_Update23.do,
. * trimmed to the two outcomes used here.
. 
. use "$update23/panel_16_22.dta", clear

. drop if inrange(cohort,1999,2000) | cohort<1995
(1,033,327 observations deleted)

. gen exposed=inrange(cohort,2001,2004)

. 
. drop if clase1==0
(13,382 observations deleted)

. gen fac_inc=fac if ingocup>0
(1,036,273 missing values generated)

. gen pos_inc=(ingocup>0)

. 
. egen pop=total(fac), by(per exposed state)

. egen part_pop=total(fac), by(per exposed state clase1)

. egen ocup_pop=total(fac), by(per exposed state clase2)

. egen informal_pop=total(fac), by(per exposed state informal)

. egen income_pop=total(ingocup*fac), by(per exposed state pos_inc)

. egen pop_income=total(fac), by(per exposed state pos_inc)

. 
. gen tpart_pre =part_pop/pop            if clase1==1 & exposed==0
(1,013,476 missing values generated)

. gen tinform_pre =informal_pop/ocup_pop if informal==1 & exposed==0
(1,217,878 missing values generated)

. gen tpart_post=part_pop/pop            if clase1==1 & exposed==1
(1,253,003 missing values generated)

. gen tinform_post=informal_pop/ocup_pop if informal==1 & exposed==1
(1,294,941 missing values generated)

. 
. collapse tpart* tinform* (sum) fac fac_inc, by(per state)

. 
. replace tpart_pre =100*tpart_pre
(864 real changes made)

. replace tpart_post=100*tpart_post
(864 real changes made)

. gen tform_pre =100*(1-tinform_pre)

. gen tform_post=100*(1-tinform_post)

. 
. gen dtpart=tpart_post-tpart_pre

. gen dtform=tform_post-tform_pre

. 
. gen year=mod(per,100)+2000

. gen quarter=int(per/100)

. gen t=yq(year,quarter)

. 
. sort state

. merge m:1 state using "$update23/longdiff_covariates"

    Result                      Number of obs
    -----------------------------------------
    Not matched                             0
    Matched                               864  (_merge==3)
    -----------------------------------------

.     drop _merge

.     replace gdp_pc=ln(gdp_pc)
(864 real changes made)

. mkregion
(864 missing values generated)
(162 real changes made)
(81 real changes made)
(108 real changes made)
(108 real changes made)
(135 real changes made)
(81 real changes made)
(81 real changes made)
(108 real changes made)

. mkborder

. gen w=sqrt(fac)

. 
. keep if inrange(year,2018,2019)
(608 observations deleted)

. qui count if year==2019

. di as res _n "Long-difference cells in 2019: " r(N) "  (should be 128)"

Long-difference cells in 2019: 128  (should be 128)

. 
. *------------------------------------------------------------------------------
. * 1.1 What does dropping the border states cost?
. *------------------------------------------------------------------------------
. preserve

.     keep if year==2019
(128 observations deleted)

.     qui su inf_pre, detail

.     local lo_all = r(min)

.     local hi_all = r(max)

.     qui su inf_pre if border==0, detail

.     di as res _n "Pre-policy informality range:"

Pre-policy informality range:

.     di as res "  all 32 states:    [" %5.1f `lo_all' ", " %5.1f `hi_all' "]"
  all 32 states:    [ 37.4,  80.3]

.     di as res "  excluding border: [" %5.1f r(min) ", " %5.1f r(max) "]"
  excluding border: [ 40.5,  80.3]

.     di as res "  -> a large contraction of the lower end means check (A) is"
  -> a large contraction of the lower end means check (A) is

.     di as res "     comparing a different population, not a cleaner one."
     comparing a different population, not a cleaner one.

.     di as txt _n "Regions surviving the border drop:"

Regions surviving the border drop:

.     tab region if border==0

     region |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |         12       11.54       11.54
          3 |         16       15.38       26.92
          4 |         16       15.38       42.31
          5 |         20       19.23       61.54
          6 |         12       11.54       73.08
          7 |         12       11.54       84.62
          8 |         16       15.38      100.00
------------+-----------------------------------
      Total |        104      100.00

.     di as txt "(region 2 disappears: all three of its states are border states)"
(region 2 disappears: all three of its states are border states)

. restore

. 
. *------------------------------------------------------------------------------
. * 1.2 The checks
. *------------------------------------------------------------------------------
. foreach y in dtpart dtform {
  2. 
.     di as res _n(2) "{hline 78}"
  3.     di as res "LONG DIFFERENCES: `y'"
  4.     di as res "{hline 78}"
  5. 
.     * (0) baseline, Table 2 Panel B
.     qui reg `y' inf_pre `CTRLS' i.region i.t [aw=w] if year==2019, cluster(state)
  6.     local b0 = _b[inf_pre]
  7.     local s0 = _se[inf_pre]
  8.     qui boottest inf_pre, boot(wild) weight(webb) reps(`REPS') nogr
  9.     di as txt _n "(0) baseline, 32 states     " %6.3f `b0' "  (" %5.3f `s0' ")" ///
>         "   WCB p = " %5.3f r(p)
 10. 
.     * (A) drop border states
.     qui reg `y' inf_pre `CTRLS' i.region i.t if year==2019 & border==0 [aw=w], ///
>         cluster(state)
 11.     local gA = e(N_clust)
 12.     local bA = _b[inf_pre]
 13.     local sA = _se[inf_pre]
 14.     qui boottest inf_pre, boot(wild) weight(webb) reps(`REPS') nogr
 15.     di as txt "(A) excl. border, `gA' states " %6.3f `bA' "  (" %5.3f `sA' ")" ///
>         "   WCB p = " %5.3f r(p)
 16. 
.     * (B) border control, all states (identified off region 1 only)
.     qui reg `y' inf_pre border `CTRLS' i.region i.t [aw=w] if year==2019, ///
>         cluster(state)
 17.     local bB = _b[inf_pre]
 18.     local sB = _se[inf_pre]
 19.     qui boottest inf_pre, boot(wild) weight(webb) reps(`REPS') nogr
 20.     di as txt "(B) border control          " %6.3f `bB' "  (" %5.3f `sB' ")" ///
>         "   WCB p = " %5.3f r(p)
 21. 
.     * (B') does the gradient itself differ in border states?
.     * The test a minimum-wage story actually requires. Run in both years: the
.     * reform predicts an interaction present in 2019 but absent in 2018.
.     foreach yr in 2018 2019 {
 22.         qui reg `y' c.inf_pre##i.border `CTRLS' i.region i.t [aw=w] ///
>             if year==`yr', cluster(state)
 23.         qui test 1.border#c.inf_pre
 24.         di as txt "(B') inf x border, `yr'     " ///
>             %6.3f _b[1.border#c.inf_pre] "  (" %5.3f _se[1.border#c.inf_pre] ")" ///
>             "   p = " %5.3f r(p)
 25.     }
 26. 
.     * (C) 2018 instead of 2019 -- the headline check
.     qui reg `y' inf_pre `CTRLS' i.region i.t [aw=w] if year==2018, cluster(state)
 27.     local bC = _b[inf_pre]
 28.     local sC = _se[inf_pre]
 29.     qui boottest inf_pre, boot(wild) weight(webb) reps(`REPS') nogr
 30.     di as res "(C) 2018, 32 states         " %6.3f `bC' "  (" %5.3f `sC' ")" ///
>         "   WCB p = " %5.3f r(p)
 31. }


------------------------------------------------------------------------------
LONG DIFFERENCES: dtpart
------------------------------------------------------------------------------

(0) baseline, 32 states      0.592  (0.089)   WCB p = 0.000
(A) excl. border, 26 states  0.625  (0.081)   WCB p = 0.001
(B) border control           0.649  (0.079)   WCB p = 0.000
(B') inf x border, 2018     -0.412  (0.177)   p = 0.027
(B') inf x border, 2019      0.039  (0.170)   p = 0.821
(C) 2018, 32 states          0.552  (0.101)   WCB p = 0.001


------------------------------------------------------------------------------
LONG DIFFERENCES: dtform
------------------------------------------------------------------------------

(0) baseline, 32 states      0.875  (0.155)   WCB p = 0.003
(A) excl. border, 26 states  0.949  (0.175)   WCB p = 0.005
(B) border control           0.980  (0.161)   WCB p = 0.002
(B') inf x border, 2018      0.045  (0.210)   p = 0.833
(B') inf x border, 2019      0.326  (0.323)   p = 0.320
(C) 2018, 32 states          1.156  (0.124)   WCB p = 0.000

. 
. 
. ********************************************************************************
. * SECTION 2: PANEL
. ********************************************************************************
. 
. capture confirm file "ThemeC/panel_cells_91.dta"

. if _rc {
.     di as err "ThemeC/panel_cells_91.dta not found."
.     di as err "Run C__CohortProfiles_Placebos.do Section 1 first."
.     exit 601
. }

. 
. use "ThemeC/panel_cells_91.dta", clear

. keep if year<=2019
(4,928 observations deleted)

. keep if inrange(cohort,1995,2004)          // Table 3 cohort range
(2,048 observations deleted)

. 
. capture confirm variable region

. if _rc mkregion
(5,120 missing values generated)
(960 real changes made)
(480 real changes made)
(640 real changes made)
(640 real changes made)
(800 real changes made)
(480 real changes made)
(480 real changes made)
(640 real changes made)

. capture confirm variable border

. if _rc mkborder

. 
. * exposure schedule of Figure 1, verbatim
. gen exposed=inrange(cohort,2001,2004)

.     replace exposed=1/3 if cohort==1999
(512 real changes made)

.     replace exposed=2/3 if cohort==2000
(512 real changes made)

. 
. gen inf_pre_exp       = inf_pre*exposed

. gen gdp_pc_exp        = gdp_pc*exposed

. gen school_attain_exp = school_attain*exposed

. gen border_exp        = border*exposed

. 
. local CX "gdp_pc_exp school_attain_exp"

. 
. foreach y in tpart tform {
  2. 
.     di as res _n(2) "{hline 78}"
  3.     di as res "PANEL: `y'"
  4.     di as res "{hline 78}"
  5. 
.     * (0) baseline, Table 3
.     qui areg `y' inf_pre_exp `CX' i.state i.t [aw=w], absorb(cohort) cluster(state)
  6.     di as txt _n "(0) baseline, 32 states     " %6.3f _b[inf_pre_exp] ///
>         "  (" %5.3f _se[inf_pre_exp] ")   N = " e(N)
  7. 
.     * (A) drop border states
.     qui areg `y' inf_pre_exp `CX' i.state i.t if border==0 [aw=w], ///
>         absorb(cohort) cluster(state)
  8.     di as txt "(A) excl. border, " %2.0f e(N_clust) " states " ///
>         %6.3f _b[inf_pre_exp] "  (" %5.3f _se[inf_pre_exp] ")"
  9. 
.     * (B) border x exposure control
.     * State FE absorb the border level, so the interaction with exposure is the
.     * relevant control: the shock hits young cohorts differentially.
.     qui areg `y' inf_pre_exp border_exp `CX' i.state i.t [aw=w], ///
>         absorb(cohort) cluster(state)
 10.     di as txt "(B) border x exposure       " %6.3f _b[inf_pre_exp] ///
>         "  (" %5.3f _se[inf_pre_exp] ")"
 11.     di as txt "     border x exposure coef " %6.3f _b[border_exp] ///
>         "  (" %5.3f _se[border_exp] ")"
 12. 
.     * (C) drop 2019 -- covers the minimum wage reform and JCF together
.     qui areg `y' inf_pre_exp `CX' i.state i.t if year<=2018 [aw=w], ///
>         absorb(cohort) cluster(state)
 13.     di as res "(C) 2016-2018 only          " %6.3f _b[inf_pre_exp] ///
>         "  (" %5.3f _se[inf_pre_exp] ")   N = " e(N)
 14. }


------------------------------------------------------------------------------
PANEL: tpart
------------------------------------------------------------------------------

(0) baseline, 32 states      0.442  (0.053)   N = 5094
(A) excl. border, 26 states  0.456  (0.076)
(B) border x exposure        0.444  (0.073)
     border x exposure coef  0.089  (1.360)
(C) 2016-2018 only           0.460  (0.054)   N = 3814


------------------------------------------------------------------------------
PANEL: tform
------------------------------------------------------------------------------

(0) baseline, 32 states      1.283  (0.056)   N = 5091
(A) excl. border, 26 states  1.275  (0.103)
(B) border x exposure        1.268  (0.095)
     border x exposure coef -0.488  (1.705)
(C) 2016-2018 only           1.359  (0.058)   N = 3811

. 
. log close res
      name:  res
       log:  /Users/alainpineda/Library/CloudStorage/GoogleDrive-alainpp25@gmail.com/My Drive/PhD/Projects/Tie
> nes IMSS/replication/output/ThemeF/ThemeF_results.txt
  log type:  text
 closed on:  20 Aug 2026, 14:48:08
--------------------------------------------------------------------------------------------------------------
