To compare a coefficient across two subsamples, interact the subsample indicator with the covariates and run one pooled regression. If only the treatment is interacted, all other coefficients are constrained equal across subsamples; interacting everything relaxes that. This is the Chow test. (The overlapping-samples extension below follows Austin Nichols’s Statalist code.)
The data are Stata’s nlsw88, an extract from the 1988 National Longitudinal Survey of Young Women. With non-missing wage and hours, 938 of the women live in the South and 1,304 elsewhere, 2,242 in all. We regress hourly wage on weekly hours, and ask whether the slope differs by region. The chunk runs that four ways — two separate regressions, suest, and the pooled interacted regression — so the equivalences are visible side by side.
Code
estclearsysuse nlsw88, clearreg wage hours if southest sto southreg wage hours if !southest sto nonsouthsuest south nonsouthest sto suestgen hours1=hours*(south==1)gen hours2=hours*(south==0)reg wage south hours?est sto chowtest _b[hours1]-_b[hours2]=0esttab south nonsouth suest chow, nogaps mti
The separate regressions give an hours slope of 0.0623 in the South and 0.1108 elsewhere. The pooled regression with hours1 and hours2 returns 0.0623497 and 0.1107536 — the same numbers to seven digits, not merely similar ones. That is algebra, not luck: a fully interacted regression is the two subsample regressions written as one.
What does differ is the standard errors. The South slope carries 0.0177 in its own regression and 0.0189 in the pooled one, because the pooled model estimates a single error variance across both groups while the separate regressions each get their own (root MSE 5.26 in the South, 5.87 elsewhere). If that pooling is unattractive, suest avoids it: it stacks the two stored estimates with their joint covariance and reports robust standard errors, 0.0174 and 0.0135 here.
test _b[hours1]-_b[hours2]=0 is the Chow test, and it gives \(F(1, 2238) = 4.20\) with \(p = 0.0405\). The returns to hours are steeper outside the South, and the gap of 0.048 dollars per hour is just significant at 5%. Note that the south dummy itself is 0.163 with \(p = 0.860\) — the two regions differ in slope, not in intercept, which is precisely the pattern a treatment-only interaction would have missed. Stata’s suest does the same job by stacking the two stored estimates and their covariance structure; the interaction approach is more flexible since it works with any estimator.
3.2 A comparison with two different outcomes
The same idea compares a coefficient across two different outcomes. Stack the two outcome variables into a long format, interact the covariates with the stacking indicator, and run one regression.
The chunk below does that in seven steps, and it is worth reading them in order because the payoff is the last two columns of the table agreeing.
reg south wage hours and reg smsa wage hours, each stored with est sto. These are the two equations we want to compare, fitted separately.
suest south smsa refits them jointly and stacks the two coefficient vectors into one, with a robust covariance matrix across equations. This is the benchmark: it is the standard way to test a cross-equation hypothesis.
preserve, because the next steps reshape the data and we want it back.
gen Y1=south, gen Y2=smsa, gen id=_n. Copy the two outcomes into a numbered pair and give every woman an id.
reshape long Y, i(id) j(subsample) turns each woman’s one row into two: one carrying Y = south with subsample == 1, one carrying Y = smsa with subsample == 2. The stacked outcome is now a single variable Y.
gen wage1=wage*(subsample==1) and its three siblings. Each covariate is split into the part that acts in equation 1 and the part that acts in equation 2. A single regression on wage1 wage2 hours1 hours2 therefore estimates a separate slope per equation, which is what the two separate regressions did.
reg Y wage? hours? subsample, cluster(id) fits it, and test _b[wage1]-_b[wage2]=0 is the cross-equation test. The ? is a Stata wildcard, so wage? expands to wage1 wage2.
The whole construction exists so that a hypothesis across two equations becomes a hypothesis within one, where test can reach both coefficients.
Code
estclearsysuse nlsw88, clearreg south wage hoursest sto southreg smsa wage hoursest sto smsasuest south smsaest sto suestpreservegen Y1=southgen Y2=smsagen id=_nreshapelong Y, i(id) j(subsample)gen wage1=wage*(subsample==1)gen wage2=wage*(subsample==2)gen hours1=hours*(subsample==1)gen hours2=hours*(subsample==2)* Each individual contributes TWO rows here (one per stacked outcome), so the* errors are correlated within id. Clustering on the stacking id is what makes* the cross-equation test comparable to suest -- see the note below.reg Y wage? hours? subsample, cluster(id)test _b[wage1]-_b[wage2]=0est sto stacked* Match the preserve above, so the reshape does not leak into later chunks.restore* Note: suest stores coefficients under equation-qualified names (e.g.* south:hours), while the single-sample models store the same* coefficient simply as"hours"; esttab matches by exact coefficient* name, so these land onseparaterows instead of being aligned. Use* esttab's coeflabel()/eqlabel() options, orrename coefficients on the* stored estimates first, to get a directly comparable table.esttab south smsa suest stacked, nogaps mti
Read the table by columns. The first two are the separate regressions, the third is suest, and the fourth is the stacked regression. The wage1 coefficient in column four equals the wage coefficient in column one, and wage2 equals the wage coefficient in column two: stacking has reproduced both single-equation fits exactly, in one regression, with both coefficients now addressable by test. Note the sample size, 4,484 in the stacked column against 2,242 in the others — the reshape doubled the rows, which is the next point.
One detail matters a great deal here, and it is easy to skip. Stacking puts two rows per person in the data, so the two error terms belonging to the same person are correlated by construction. The cross-equation test is precisely a comparison across those two rows, so its standard error has to account for that correlation. Clustering on the stacking id does it, and it is not a cosmetic adjustment:
test of the wage coefficient across equations
suest
\(\chi^2(1) = 72.22\)
stacked, no clustering
\(F(1, 4478) = 114.12\)
stacked, cluster(id)
\(F(1, 2241) = 72.14\)
Without clustering the statistic is inflated by more than half. With it, the stacked test reproduces suest almost exactly – the small remaining gap is just the \(F\)-versus-\(\chi^2\) finite-sample adjustment. Note that robust alone will not fix this; the cluster variable has to be the id you stacked on.
3.3 Overlapping samples
The same method extends to overlapping subsamples. Here south and smsa overlap — some observations belong to both — so a simple split is not possible.
The reshape trick from the previous section will not work here, because a woman who is both southern and in an SMSA has to appear in both subsamples rather than be assigned to one. expand handles that instead:
ta south smsa shows the overlap, which is the reason for what follows.
preserve, then expand 2 duplicates every row, so each woman now has two copies.
bys idcode: g n=_n numbers a woman’s two copies 1 and 2.
keep if (n==1&south)|(n==2&smsa) keeps copy 1 only if she is southern and copy 2 only if she is in an SMSA. A woman in both keeps both copies; a woman in neither drops out; a woman in exactly one keeps one. Each surviving row now represents one woman’s membership in one subsample.
g hours1=hours*(n==1) and g hours2=hours*(n==2) split the covariate by subsample, as before. Within this restricted sample n==1 means southern and n==2 means SMSA, so the copy number is the subsample indicator.
reg wage hours? n, cl(idcode) fits both slopes at once, clustering on the woman rather than on a stacking id, since a woman can now contribute one row or two.
Code
estclearsysuse nlsw88, clearta south smsareg wage hours if southest sto southreg wage hours if smsaest sto smsasuest south smsaest sto suestpreserveexpand 2bys idcode: g n=_nkeepif (n==1&south)|(n==2&smsa)* hours1 is hours in the south subsample (n==1), hours2 is hours in the* smsa subsample (n==2); within this restricted sample n==1 <=> south==1* and n==2 <=> smsa==1, so this is equivalent to but clearer than negating* the complementary condition.g hours1=hours*(n==1)g hours2=hours*(n==2)reg wage hours? n, cl(idcode)est sto stackedrestoreesttab south smsa suest stacked, nogaps mti
(NLSW, 1988 extract)
Lives in | Lives in SMSA
the south | Not SMSA SMSA | Total
-----------+----------------------+----------
Not south | 308 996 | 1,304
South | 357 585 | 942
-----------+----------------------+----------
Total | 665 1,581 | 2,246
Source | SS df MS Number of obs = 938
-------------+---------------------------------- F(1, 936) = 12.47
Model | 344.732583 1 344.732583 Prob > F = 0.0004
Residual | 25866.3404 936 27.634979 R-squared = 0.0132
-------------+---------------------------------- Adj R-squared = 0.0121
Total | 26211.0729 937 27.973397 Root MSE = 5.2569
------------------------------------------------------------------------------
wage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hours | .0623497 .0176532 3.53 0.000 .0277053 .0969941
_cons | 4.520583 .6957145 6.50 0.000 3.155242 5.885923
------------------------------------------------------------------------------
Source | SS df MS Number of obs = 1,578
-------------+---------------------------------- F(1, 1576) = 46.48
Model | 1594.14881 1 1594.14881 Prob > F = 0.0000
Residual | 54048.2539 1,576 34.2945773 R-squared = 0.0286
-------------+---------------------------------- Adj R-squared = 0.0280
Total | 55642.4027 1,577 35.2837049 Root MSE = 5.8562
------------------------------------------------------------------------------
wage | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hours | .0953636 .0139872 6.82 0.000 .0679281 .1227991
_cons | 4.861519 .5443826 8.93 0.000 3.793729 5.929309
------------------------------------------------------------------------------
Simultaneous results for south, smsa Number of obs = 1,934
------------------------------------------------------------------------------
| Robust
| Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
south_mean |
hours | .0623497 .0174432 3.57 0.000 .0281617 .0965378
_cons | 4.520583 .6599613 6.85 0.000 3.227082 5.814083
-------------+----------------------------------------------------------------
south_lnvar |
_cons | 3.319082 .1435356 23.12 0.000 3.037758 3.600407
-------------+----------------------------------------------------------------
smsa_mean |
hours | .0953636 .0132806 7.18 0.000 .069334 .1213931
_cons | 4.861519 .4842914 10.04 0.000 3.912325 5.810713
-------------+----------------------------------------------------------------
smsa_lnvar |
_cons | 3.534987 .0910825 38.81 0.000 3.356469 3.713506
------------------------------------------------------------------------------
(2,246 observations created)
(1,969 observations deleted)
(7 missing values generated)
(7 missing values generated)
Linear regression Number of obs = 2,516
F(3, 1933) = 40.81
Prob > F = 0.0000
R-squared = 0.0399
Root MSE = 5.6403
(Std. err. adjusted for 1,934 clusters in idcode)
------------------------------------------------------------------------------
| Robust
wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hours1 | .0623497 .0174536 3.57 0.000 .0281198 .0965796
hours2 | .0953636 .0132886 7.18 0.000 .0693022 .121425
n | .3409364 .6124145 0.56 0.578 -.8601261 1.541999
_cons | 4.179646 1.177889 3.55 0.000 1.869579 6.489713
------------------------------------------------------------------------------
----------------------------------------------------------------------------
(1) (2) (3) (4)
south smsa suest stacked
----------------------------------------------------------------------------
main
hours 0.0623*** 0.0954*** 0.0623***
(3.53) (6.82) (3.57)
hours1 0.0623***
(3.57)
hours2 0.0954***
(7.18)
n 0.341
(0.56)
_cons 4.521*** 4.862*** 4.521*** 4.180***
(6.50) (8.93) (6.85) (3.55)
----------------------------------------------------------------------------
south_lnvar
_cons 3.319***
(23.12)
----------------------------------------------------------------------------
smsa_mean
hours 0.0954***
(7.18)
_cons 4.862***
(10.04)
----------------------------------------------------------------------------
smsa_lnvar
_cons 3.535***
(38.81)
----------------------------------------------------------------------------
N 938 1578 1934 2516
----------------------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001
The cross-tab shows the overlap: of the 1,304 non-South women, 996 live in an SMSA, so the two subsamples share members and cannot be produced by a simple split. Expanding the data and keeping each observation under whichever subsample it belongs to handles that. The pooled hours1 is 0.0623497, again reproducing the South regression exactly, and hours2 is 0.0954 for the SMSA subsample. The n indicator is 0.341 with \(p = 0.578\).
3.4 IV regression
The interaction approach works with IV. Interact both the endogenous variable and the instrument with the subsample indicator. Here hours is instrumented by union within each region.
The point is not to get a different estimate. The two interacted 2SLS coefficients reproduce the two subsample IV regressions exactly, just as they did for OLS. The point is that running them separately leaves the two estimates in different ivregress results with no joint covariance between them, so there is nothing to test the difference with. Interacting puts both in one estimation, so test _b[hours1]-_b[hours2]=0 can reach both coefficients and their covariance. That is the whole reason for the construction, and it is the same reason as in the OLS case.
Two details specific to IV. The instrument must be split alongside the endogenous variable — union1 and union2, not just hours1 and hours2 — because an instrument that is not subsample-specific would identify a single pooled first stage and defeat the purpose. And the number of instruments must still match the number of endogenous regressors: two of each here, so the system is exactly identified, as each subsample regression was on its own.
Code
sysuse nlsw88, clearivregress 2sls wage (hours=union) if southivregress 2sls wage (hours=union) if !southgen hours1=hours*(south==1)gen hours2=hours*(south==0)gen union1=union*(south==1)gen union2=union*(south==0)ivregress 2sls wage south (hours1 hours2 = union1 union2)test _b[hours1]-_b[hours2]=0
The IV estimates are 0.978 in the South and 0.626 elsewhere, against OLS values of 0.062 and 0.111 — an order of magnitude larger, with standard errors to match (0.519 and 0.297). And the Chow test now gives \(\chi^2(1) = 0.35\) with \(p = 0.5554\), where the OLS version rejected at \(p = 0.0405\). Instrumenting has not overturned the difference between regions; it has made the data too imprecise to detect it. The lesson is about the test, not the subsamples: a Chow test inherits the precision of whatever estimator it is built on.
3.5 IV with fixed effects
With fixed effects the pooled regression needs the fixed effects themselves interacted with the subsample indicator. The first attempt below omits this and fails to reproduce the separate estimates:
The examples below cluster standard errors on race, which in nlsw88 has only three categories (White, Black, Other). Cluster-robust standard errors rely on asymptotics in the number of clusters \(G \to \infty\); with \(G=3\) they are severely downward-biased, inflating t-statistics and false-positive rates. These chunks use race purely to illustrate the fixed-effect/IV mechanics — in an actual analysis, cluster on a variable with many more categories (e.g., industry or occupation), or on the true level of treatment assignment/sampling design.
Code
sysuse nlsw88, cleargen hours1=hours*(south==1)gen hours2=hours*(south==0)gen union1=union*(south==1)gen union2=union*(south==0)ivreghdfe wage (hours=union) if south, a(race) cluster(race)ivreghdfe wage (hours=union) if !south, a(race) cluster(race)ivreghdfe wage south (hours1 hours2 = union1 union2) , a(race) cluster(race)
(NLSW, 1988 extract)
(4 missing values generated)
(4 missing values generated)
(368 missing values generated)
(368 missing values generated)
(MWFE estimator converged in 1 iterations)
IV (2SLS) estimation
--------------------
Estimates efficient for homoskedasticity only
Statistics robust to heteroskedasticity and clustering on race
Number of clusters (race) = 3 Number of obs = 798
F( 1, 2) = 69.28
Prob > F = 0.0141
Total (centered) SS = 12186.8806 Centered R2 = -6.4527
Total (uncentered) SS = 12186.8806 Uncentered R2 = -6.4527
Residual SS = 90825.44631 Root MSE = 10.68
------------------------------------------------------------------------------
| Robust
wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hours | 1.107099 .133012 8.32 0.014 .5347947 1.679404
------------------------------------------------------------------------------
Underidentification test (Kleibergen-Paap rk LM statistic): 1.756
Chi-sq(1) P-val = 0.1852
------------------------------------------------------------------------------
Weak identification test (Cragg-Donald Wald F statistic): 3.233
(Kleibergen-Paap rk Wald F statistic): 13.977
Stock-Yogo weak ID test critical values: 10% maximal IV size 16.38
15% maximal IV size 8.96
20% maximal IV size 6.66
25% maximal IV size 5.53
Source: Stock-Yogo (2005). Reproduced by permission.
NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors.
------------------------------------------------------------------------------
Hansen J statistic (overidentification test of all instruments): 0.000
(equation exactly identified)
------------------------------------------------------------------------------
Instrumented: hours
Excluded instruments: union
Partialled-out: _cons
nb: total SS, model F and R2s are after partialling-out;
any small-sample adjustments include partialled-out
variables in regressor count K
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
race | 3 3 0 *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
(MWFE estimator converged in 1 iterations)
IV (2SLS) estimation
--------------------
Estimates efficient for homoskedasticity only
Statistics robust to heteroskedasticity and clustering on race
Number of clusters (race) = 3 Number of obs = 1079
F( 1, 2) = 1.41
Prob > F = 0.3564
Total (centered) SS = 19086.22115 Centered R2 = -2.3302
Total (uncentered) SS = 19086.22115 Uncentered R2 = -2.3302
Residual SS = 63560.97528 Root MSE = 7.682
------------------------------------------------------------------------------
| Robust
wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hours | .7023322 .5905772 1.19 0.356 -1.838717 3.243381
------------------------------------------------------------------------------
Underidentification test (Kleibergen-Paap rk LM statistic): 0.789
Chi-sq(1) P-val = 0.3745
------------------------------------------------------------------------------
Weak identification test (Cragg-Donald Wald F statistic): 5.501
(Kleibergen-Paap rk Wald F statistic): 3.772
Stock-Yogo weak ID test critical values: 10% maximal IV size 16.38
15% maximal IV size 8.96
20% maximal IV size 6.66
25% maximal IV size 5.53
Source: Stock-Yogo (2005). Reproduced by permission.
NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors.
------------------------------------------------------------------------------
Hansen J statistic (overidentification test of all instruments): 0.000
(equation exactly identified)
------------------------------------------------------------------------------
Instrumented: hours
Excluded instruments: union
Partialled-out: _cons
nb: total SS, model F and R2s are after partialling-out;
any small-sample adjustments include partialled-out
variables in regressor count K
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
race | 3 3 0 *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
(MWFE estimator converged in 1 iterations)
IV (2SLS) estimation
--------------------
Estimates efficient for homoskedasticity only
Statistics robust to heteroskedasticity and clustering on race
Number of clusters (race) = 3 Number of obs = 1877
F( 3, 2) = 1036.24
Prob > F = 0.0010
Total (centered) SS = 32142.319 Centered R2 = -3.9041
Total (uncentered) SS = 32142.319 Uncentered R2 = -3.9041
Residual SS = 157627.5718 Root MSE = 9.174
------------------------------------------------------------------------------
| Robust
wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hours1 | 1.142036 .0650507 17.56 0.003 .8621454 1.421927
hours2 | .6880691 .5265185 1.31 0.321 -1.577357 2.953495
south | -19.74773 22.10811 -0.89 0.466 -114.8712 75.37577
------------------------------------------------------------------------------
Underidentification test (Kleibergen-Paap rk LM statistic): 1.793
Chi-sq(1) P-val = 0.1806
------------------------------------------------------------------------------
Weak identification test (Cragg-Donald Wald F statistic): 3.584
(Kleibergen-Paap rk Wald F statistic): 8.484
Stock-Yogo weak ID test critical values: 10% maximal IV size 7.03
15% maximal IV size 4.58
20% maximal IV size 3.95
25% maximal IV size 3.63
Source: Stock-Yogo (2005). Reproduced by permission.
NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors.
------------------------------------------------------------------------------
Warning: estimated covariance matrix of moment conditions not of full rank.
overidentification statistic not reported, and standard errors and
model tests should be interpreted with caution.
Possible causes:
number of clusters insufficient to calculate robust covariance matrix
singleton dummy variable (dummy with one 1 and N-1 0s or vice versa)
partial option may address problem.
------------------------------------------------------------------------------
Instrumented: hours1 hours2
Included instruments: south
Excluded instruments: union1 union2
Partialled-out: _cons
nb: total SS, model F and R2s are after partialling-out;
any small-sample adjustments include partialled-out
variables in regressor count K
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
race | 3 3 0 *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
The separate regressions give 1.1071 and 0.7023. The pooled regression gives 1.1420 and 0.6881 — close, but not equal, and that is the point. The pooled coefficients do not match the separate regressions because the fixed effects are shared: one set of race effects is estimated off both subsamples at once, so neither subsample gets the within-group demeaning its own regression used. Interacting them with the subsample indicator fixes it:
Warning: estimated covariance matrix of moment conditions not of full rank.
overidentification statistic not reported, and standard errors and
model tests should be interpreted with caution.
Possible causes:
number of clusters insufficient to calculate robust covariance matrix
singleton dummy variable (dummy with one 1 and N-1 0s or vice versa)
partial option may address problem.
(NLSW, 1988 extract)
(4 missing values generated)
(4 missing values generated)
(368 missing values generated)
(368 missing values generated)
(MWFE estimator converged in 1 iterations)
IV (2SLS) estimation
--------------------
Estimates efficient for homoskedasticity only
Statistics robust to heteroskedasticity and clustering on race
Number of clusters (race) = 3 Number of obs = 798
F( 1, 2) = 69.28
Prob > F = 0.0141
Total (centered) SS = 12186.8806 Centered R2 = -6.4527
Total (uncentered) SS = 12186.8806 Uncentered R2 = -6.4527
Residual SS = 90825.44631 Root MSE = 10.68
------------------------------------------------------------------------------
| Robust
wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hours | 1.107099 .133012 8.32 0.014 .5347947 1.679404
------------------------------------------------------------------------------
Underidentification test (Kleibergen-Paap rk LM statistic): 1.756
Chi-sq(1) P-val = 0.1852
------------------------------------------------------------------------------
Weak identification test (Cragg-Donald Wald F statistic): 3.233
(Kleibergen-Paap rk Wald F statistic): 13.977
Stock-Yogo weak ID test critical values: 10% maximal IV size 16.38
15% maximal IV size 8.96
20% maximal IV size 6.66
25% maximal IV size 5.53
Source: Stock-Yogo (2005). Reproduced by permission.
NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors.
------------------------------------------------------------------------------
Hansen J statistic (overidentification test of all instruments): 0.000
(equation exactly identified)
------------------------------------------------------------------------------
Instrumented: hours
Excluded instruments: union
Partialled-out: _cons
nb: total SS, model F and R2s are after partialling-out;
any small-sample adjustments include partialled-out
variables in regressor count K
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
race | 3 3 0 *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
(MWFE estimator converged in 1 iterations)
IV (2SLS) estimation
--------------------
Estimates efficient for homoskedasticity only
Statistics robust to heteroskedasticity and clustering on race
Number of clusters (race) = 3 Number of obs = 1079
F( 1, 2) = 1.41
Prob > F = 0.3564
Total (centered) SS = 19086.22115 Centered R2 = -2.3302
Total (uncentered) SS = 19086.22115 Uncentered R2 = -2.3302
Residual SS = 63560.97528 Root MSE = 7.682
------------------------------------------------------------------------------
| Robust
wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hours | .7023322 .5905772 1.19 0.356 -1.838717 3.243381
------------------------------------------------------------------------------
Underidentification test (Kleibergen-Paap rk LM statistic): 0.789
Chi-sq(1) P-val = 0.3745
------------------------------------------------------------------------------
Weak identification test (Cragg-Donald Wald F statistic): 5.501
(Kleibergen-Paap rk Wald F statistic): 3.772
Stock-Yogo weak ID test critical values: 10% maximal IV size 16.38
15% maximal IV size 8.96
20% maximal IV size 6.66
25% maximal IV size 5.53
Source: Stock-Yogo (2005). Reproduced by permission.
NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors.
------------------------------------------------------------------------------
Hansen J statistic (overidentification test of all instruments): 0.000
(equation exactly identified)
------------------------------------------------------------------------------
Instrumented: hours
Excluded instruments: union
Partialled-out: _cons
nb: total SS, model F and R2s are after partialling-out;
any small-sample adjustments include partialled-out
variables in regressor count K
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
race | 3 3 0 *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
note: 3.race1 omitted because of collinearity.
note: 3.race2 omitted because of collinearity.
Instrumental-variables 2SLS regression Number of obs = 1,877
Wald chi2(7) = 101696.08
Prob > chi2 = 0.0000
Root MSE = 9.0693
(Std. err. adjusted for 3 clusters in race)
------------------------------------------------------------------------------
| Robust
wage | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
hours1 | 1.107099 .1085357 10.20 0.000 .8943732 1.319825
hours2 | .7023322 .4819806 1.46 0.145 -.2423324 1.646997
south | -21.52299 22.35225 -0.96 0.336 -65.33259 22.28662
|
race1 |
1 | 3.054296 .1451752 21.04 0.000 2.769758 3.338834
2 | 1.987268 .176538 11.26 0.000 1.64126 2.333277
3 | 0 (omitted)
|
race2 |
1 | -.4816127 .434723 -1.11 0.268 -1.333654 .3704287
2 | -2.065527 .7694573 -2.68 0.007 -3.573635 -.5574181
3 | 0 (omitted)
|
_cons | -17.01633 18.01689 -0.94 0.345 -52.32879 18.29614
------------------------------------------------------------------------------
Endogenous: hours1 hours2
Exogenous: south 1.race1 2.race1 1.race2 2.race2 union1 union2
This reproduces the separate estimates exactly: 1.107099 and 0.7023322 in the pooled regression against 1.107099 and 0.7023322 separately. The approach builds explicit dummies from the interaction of the fixed-effect variable and the subsample indicator, which becomes impractical when the number of fixed-effect levels is large.
One caution about how those dummies were built. race1 = race*(south==1) multiplies a categorical code by an indicator, so non-south observations are assigned race1 = 0 and then i.race1 treats 0 as its own category. That is safe here only because race has no zero level (it is coded 1/2/3). If the absorbed variable did have a 0 category, those observations and all the non-south ones would be silently collapsed into the same dummy. For a general recipe, build the interactions from the category dummies directly (i.race#i.south) rather than from the code.
Alternatively, pass the two interaction variables to reghdfe’s absorb option as a two-way fixed effect:
Warning: estimated covariance matrix of moment conditions not of full rank.
overidentification statistic not reported, and standard errors and
model tests should be interpreted with caution.
Possible causes:
number of clusters insufficient to calculate robust covariance matrix
singleton dummy variable (dummy with one 1 and N-1 0s or vice versa)
partial option may address problem.
(NLSW, 1988 extract)
(4 missing values generated)
(4 missing values generated)
(368 missing values generated)
(368 missing values generated)
(MWFE estimator converged in 2 iterations)
IV (2SLS) estimation
--------------------
Estimates efficient for homoskedasticity only
Statistics robust to heteroskedasticity and clustering on race
Number of clusters (race) = 3 Number of obs = 1877
F( 2, 2) = 13010.62
Prob > F = 0.0001
Total (centered) SS = 31273.10174 Centered R2 = -3.9367
Total (uncentered) SS = 31273.10174 Uncentered R2 = -3.9367
Residual SS = 154386.4216 Root MSE = 9.089
------------------------------------------------------------------------------
| Robust
wage | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
hours1 | 1.107099 .1331773 8.31 0.014 .5340838 1.680115
hours2 | .7023322 .5914076 1.19 0.357 -1.84229 3.246954
south | 0 (omitted)
------------------------------------------------------------------------------
Underidentification test (Kleibergen-Paap rk LM statistic): 0.000
Chi-sq(1) P-val = 1.0000
------------------------------------------------------------------------------
Weak identification test (Cragg-Donald Wald F statistic): 3.793
(Kleibergen-Paap rk Wald F statistic): 0.000
Stock-Yogo weak ID test critical values: 10% maximal IV size 7.03
15% maximal IV size 4.58
20% maximal IV size 3.95
25% maximal IV size 3.63
Source: Stock-Yogo (2005). Reproduced by permission.
NB: Critical values are for Cragg-Donald F statistic and i.i.d. errors.
------------------------------------------------------------------------------
Warning: estimated covariance matrix of moment conditions not of full rank.
overidentification statistic not reported, and standard errors and
model tests should be interpreted with caution.
Possible causes:
number of clusters insufficient to calculate robust covariance matrix
singleton dummy variable (dummy with one 1 and N-1 0s or vice versa)
partial option may address problem.
------------------------------------------------------------------------------
Collinearities detected among instruments: 1 instrument(s) dropped
Instrumented: hours1 hours2
Included instruments: south
Excluded instruments: union1 union2
Partialled-out: _cons
nb: total SS, model F and R2s are after partialling-out;
any small-sample adjustments include partialled-out
variables in regressor count K
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
race1 | 4 0 4 |
race2 | 4 2 2 |
-----------------------------------------------------+
( 1) hours1 - hours2 = 0
F( 1, 2) = 0.31
Prob > F = 0.6325
Absorbing race1 and race2 as a two-way fixed effect gives the same 1.107099 and 0.7023322 without building the dummies by hand, and scales to many fixed-effect levels. The Chow test is \(F(1,2) = 0.31\) with \(p = 0.6325\) — but read that denominator: 2 degrees of freedom, because the standard errors are clustered on race, which has three categories. This is the problem the callout above flags, and it is why these IV/FE numbers illustrate mechanics rather than support any conclusion about the South.
3.6 Chow test with different covariates
The equations need not share the same covariates. If equation 1 includes \(X_2\) and equation 2 does not,
the second equation implicitly sets the coefficient on \(X_2\) to zero. In the stacked regression, replace \(X_2\) with a constant (e.g. 1) for the \(Y_2\) subsample, so that its “coefficient” is absorbed into the intercept:
Code
sysuse nlsw88, clearreg south wage hours tenureest sto southreg smsa wage hoursest sto smsasuest south smsaest sto suestpreservegen Y1=southgen Y2=smsagen id=_nreshapelong Y, i(id) j(subsample)gen wage1=wage*(subsample==1)gen wage2=wage*(subsample==2)gen hours1=hours*(subsample==1)gen hours2=hours*(subsample==2)replace tenure=1 if subsample==2gen tenure1= tenure*(subsample==1)gen tenure2= tenure*(subsample==2)reg Y wage? hours? tenure? subsample, cluster(id)est sto chowtest _b[hours1]-_b[hours2]=0esttab suest chow, nogaps mtirestore
Warning: estimated covariance matrix of moment conditions not of full rank.
overidentification statistic not reported, and standard errors and
model tests should be interpreted with caution.
Possible causes:
number of clusters insufficient to calculate robust covariance matrix
singleton dummy variable (dummy with one 1 and N-1 0s or vice versa)
partial option may address problem.
Warning: estimated covariance matrix of moment conditions not of full rank.
overidentification statistic not reported, and standard errors and
model tests should be interpreted with caution.
Possible causes:
number of clusters insufficient to calculate robust covariance matrix
singleton dummy variable (dummy with one 1 and N-1 0s or vice versa)
partial option may address problem.
(NLSW, 1988 extract)
Source | SS df MS Number of obs = 2,227
-------------+---------------------------------- F(3, 2223) = 20.30
Model | 14.4507388 3 4.81691294 Prob > F = 0.0000
Residual | 527.507052 2,223 .23729512 R-squared = 0.0267
-------------+---------------------------------- Adj R-squared = 0.0254
Total | 541.957791 2,226 .243467112 Root MSE = .48713
------------------------------------------------------------------------------
south | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
wage | -.0119584 .0018359 -6.51 0.000 -.0155586 -.0083583
hours | .004828 .0010072 4.79 0.000 .0028528 .0068031
tenure | -.0024032 .0019221 -1.25 0.211 -.0061726 .0013661
_cons | .346361 .0392121 8.83 0.000 .2694648 .4232573
------------------------------------------------------------------------------
Source | SS df MS Number of obs = 2,242
-------------+---------------------------------- F(2, 2239) = 36.17
Model | 14.6274602 2 7.31373012 Prob > F = 0.0000
Residual | 452.719551 2,239 .202197209 R-squared = 0.0313
-------------+---------------------------------- Adj R-squared = 0.0304
Total | 467.347012 2,241 .208543959 Root MSE = .44966
------------------------------------------------------------------------------
smsa | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
wage | .0139103 .0016711 8.32 0.000 .0106332 .0171873
hours | .0003663 .0009155 0.40 0.689 -.0014291 .0021616
_cons | .5820585 .0357648 16.27 0.000 .511923 .6521941
------------------------------------------------------------------------------
Simultaneous results for south, smsa Number of obs = 2,242
------------------------------------------------------------------------------
| Robust
| Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
south_mean |
wage | -.0119584 .001953 -6.12 0.000 -.0157862 -.0081307
hours | .004828 .0009971 4.84 0.000 .0028737 .0067822
tenure | -.0024032 .0018928 -1.27 0.204 -.0061131 .0013066
_cons | .346361 .038473 9.00 0.000 .2709554 .4217667
-------------+----------------------------------------------------------------
south_lnvar |
_cons | -1.438451 .0096359 -149.28 0.000 -1.457337 -1.419565
-------------+----------------------------------------------------------------
smsa_mean |
wage | .0139103 .0018313 7.60 0.000 .010321 .0174996
hours | .0003663 .0009099 0.40 0.687 -.0014172 .0021497
_cons | .5820585 .0361037 16.12 0.000 .5112965 .6528205
-------------+----------------------------------------------------------------
smsa_lnvar |
_cons | -1.598512 .0195103 -81.93 0.000 -1.636751 -1.560272
------------------------------------------------------------------------------
(j = 1 2)
Data Wide -> Long
-----------------------------------------------------------------------------
Number of observations 2,246 -> 4,492
Number of variables 23 -> 23
j variable (2 values) -> subsample
xij variables:
Y1 Y2 -> Y
-----------------------------------------------------------------------------
(8 missing values generated)
(8 missing values generated)
(2,222 real changes made)
(15 missing values generated)
(15 missing values generated)
note: subsample omitted because of collinearity.
Linear regression Number of obs = 4,469
F(6, 2241) = 81.10
Prob > F = 0.0000
R-squared = 0.1091
Root MSE = .4687
(Std. err. adjusted for 2,242 clusters in id)
------------------------------------------------------------------------------
| Robust
Y | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
wage1 | -.0119584 .0019543 -6.12 0.000 -.0157909 -.008126
wage2 | .0139103 .0018325 7.59 0.000 .0103166 .0175039
hours1 | .004828 .0009978 4.84 0.000 .0028713 .0067846
hours2 | .0003663 .0009105 0.40 0.688 -.0014193 .0021519
tenure1 | -.0024032 .0018941 -1.27 0.205 -.0061176 .0013111
tenure2 | .2356975 .0550137 4.28 0.000 .1278144 .3435806
subsample | 0 (omitted)
_cons | .346361 .0384988 9.00 0.000 .270864 .4218581
------------------------------------------------------------------------------
( 1) hours1 - hours2 = 0
F( 1, 2241) = 10.03
Prob > F = 0.0016
--------------------------------------------
(1) (2)
suest chow
--------------------------------------------
main
wage -0.0120***
(-6.12)
hours 0.00483***
(4.84)
tenure -0.00240
(-1.27)
wage1 -0.0120***
(-6.12)
wage2 0.0139***
(7.59)
hours1 0.00483***
(4.84)
hours2 0.000366
(0.40)
tenure1 -0.00240
(-1.27)
tenure2 0.236***
(4.28)
subsample 0
(.)
_cons 0.346*** 0.346***
(9.00) (9.00)
--------------------------------------------
south_lnvar
_cons -1.438***
(-149.28)
--------------------------------------------
smsa_mean
wage 0.0139***
(7.60)
hours 0.000366
(0.40)
_cons 0.582***
(16.12)
--------------------------------------------
smsa_lnvar
_cons -1.599***
(-81.93)
--------------------------------------------
N 2242 4469
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001
The stacked model reproduces suest’s point estimates exactly: the hours coefficient is 0.004828 in the south equation and 0.0003663 in the smsa one, in both. Here the covariates differ — tenure appears in the first equation only — and the trick of setting tenure = 1 for the second subsample lets its coefficient be absorbed by that equation’s intercept. The Chow test on the hours coefficient gives \(F(1, 2241) = 10.03\) with \(p = 0.0016\): hours predicts living in the South quite differently from how it predicts living in an SMSA. (The esttab columns do not line up because suest stores equation-qualified names like south:wage while the stacked model stores plain wage.)
3.7 Conclusion
suest and the stacking method both test cross-equation hypotheses with robust standard errors. sureg does the same under a GLS framework, but it assumes homoscedastic errors across equations; under misspecification it remains consistent but its standard errors are invalid. When the equations share covariates sureg and OLS give the same point estimates; with different covariates they diverge.
The stacking approach is the most portable. It works in any language, extends to IV and fixed-effect models, and requires only that the single-equation estimator works — no special post-estimation infrastructure.
One pattern runs through every example in this chapter, and it is worth stating once on its own. A Chow test is a hypothesis about two coefficients that live in two different regressions. Stata’s test can only reach coefficients inside a single stored estimation result, and, more importantly, testing a difference requires the covariance between the two estimates, which separate regressions never produce. Every construction here — the reshape for two outcomes, the expand for overlapping samples, the split instruments under IV, the absorbed fixed effects — exists to move both coefficients into one estimation so that the covariance exists and test can use it. suest does the same thing by a different route, refitting the stored estimates jointly with a robust cross-equation covariance matrix.
So the choice among them is practical rather than statistical. Use suest when the estimator supports it and the samples are the same. Stack when the samples overlap, when the covariates differ across equations, or when the estimator is one suest will not take — which, in practice, means most fixed-effect and IV commands.
---title: "Chow test and more"date: "2022-04-06"---## Chow testTo compare a coefficient across two subsamples, interact the subsample indicator with the covariates and run one pooled regression. If only the treatment is interacted, all other coefficients are constrained equal across subsamples; interacting everything relaxes that. This is the Chow test. (The overlapping-samples extension below follows Austin Nichols's Statalist code.)The data are Stata's `nlsw88`, an extract from the 1988 National LongitudinalSurvey of Young Women. With non-missing wage and hours, 938 of the women live inthe South and 1,304 elsewhere, 2,242 in all. We regress hourly `wage` on weekly`hours`, and ask whether the slope differs by region. The chunk runs that four ways — two separateregressions, `suest`, and the pooled interacted regression — so the equivalencesare visible side by side.```{r}#| label: setup#| include: falselibrary(Statamarkdown)stataexe <-find_stata()#stataexe <- "/usr/local/bin/stata"knitr::opts_chunk$set(engine.path=list(stata=stataexe))``````{stata}*| label: stata1*| echo: true*| collectcode: trueest clearsysuse nlsw88, clearreg wage hours if southest sto southreg wage hours if !southest sto nonsouthsuest south nonsouthest sto suestgen hours1=hours*(south==1)gen hours2=hours*(south==0)reg wage south hours?est sto chowtest _b[hours1]-_b[hours2]=0esttab south nonsouth suest chow, nogaps mti```The separate regressions give an hours slope of 0.0623 in the South and 0.1108elsewhere. The pooled regression with `hours1` and `hours2` returns0.0623497 and 0.1107536 — the *same numbers to seven digits*, not merelysimilar ones. That is algebra, not luck: a fully interacted regression is thetwo subsample regressions written as one.What does differ is the standard errors. The South slope carries 0.0177 in itsown regression and 0.0189 in the pooled one, because the pooled model estimatesa single error variance across both groups while the separate regressions eachget their own (root MSE 5.26 in the South, 5.87 elsewhere). If that pooling isunattractive, `suest` avoids it: it stacks the two stored estimates with theirjoint covariance and reports robust standard errors, 0.0174 and 0.0135 here.`test _b[hours1]-_b[hours2]=0` is the Chow test, and it gives$F(1, 2238) = 4.20$ with $p = 0.0405$. The returns to hours are steeper outsidethe South, and the gap of 0.048 dollars per hour is just significant at 5%.Note that the `south` dummy itself is 0.163 with $p = 0.860$ — the two regionsdiffer in slope, not in intercept, which is precisely the pattern atreatment-only interaction would have missed. Stata's `suest` does the same jobby stacking the two stored estimates and their covariance structure; theinteraction approach is more flexible since it works with any estimator.## A comparison with two different outcomesThe same idea compares a coefficient across two different outcomes. Stack the two outcome variables into a long format, interact the covariates with the stacking indicator, and run one regression.The chunk below does that in seven steps, and it is worth reading them in orderbecause the payoff is the last two columns of the table agreeing.1. `reg south wage hours` and `reg smsa wage hours`, each stored with `est sto`. These are the two equations we want to compare, fitted separately.2. `suest south smsa` refits them jointly and stacks the two coefficient vectors into one, with a robust covariance matrix across equations. This is the benchmark: it is the standard way to test a cross-equation hypothesis.3. `preserve`, because the next steps reshape the data and we want it back.4. `gen Y1=south`, `gen Y2=smsa`, `gen id=_n`. Copy the two outcomes into a numbered pair and give every woman an id.5. `reshape long Y, i(id) j(subsample)` turns each woman's one row into two: one carrying `Y = south` with `subsample == 1`, one carrying `Y = smsa` with`subsample == 2`. The stacked outcome is now a single variable `Y`.6. `gen wage1=wage*(subsample==1)` and its three siblings. Each covariate is split into the part that acts in equation 1 and the part that acts in equation 2. A single regression on `wage1 wage2 hours1 hours2` therefore estimates a separate slope per equation, which is what the two separate regressions did.7. `reg Y wage? hours? subsample, cluster(id)` fits it, and`test _b[wage1]-_b[wage2]=0` is the cross-equation test. The `?` is a Stata wildcard, so `wage?` expands to `wage1 wage2`.The whole construction exists so that a hypothesis *across* two equationsbecomes a hypothesis *within* one, where `test` can reach both coefficients.```{stata}*| label: stata2*| echo: true*| collectcode: trueest clearsysuse nlsw88, clearreg south wage hoursest sto southreg smsa wage hoursest sto smsasuest south smsaest sto suestpreservegen Y1=southgen Y2=smsagen id=_nreshape long Y, i(id) j(subsample)gen wage1=wage*(subsample==1)gen wage2=wage*(subsample==2)gen hours1=hours*(subsample==1)gen hours2=hours*(subsample==2)* Each individual contributes TWO rows here (one per stacked outcome), so the* errors are correlated within id. Clustering on the stacking id is what makes* the cross-equation test comparable to suest -- see the note below.reg Y wage? hours? subsample, cluster(id)test _b[wage1]-_b[wage2]=0est sto stacked* Match the preserve above, so the reshape does not leak into later chunks.restore* Note: suest stores coefficients under equation-qualified names (e.g.* south:hours), while the single-sample models store the same* coefficient simply as "hours"; esttab matches by exact coefficient* name, so these land on separate rows instead of being aligned. Use* esttab's coeflabel()/eqlabel() options, or rename coefficients on the* stored estimates first, to get a directly comparable table.esttab south smsa suest stacked, nogaps mti```Read the table by columns. The first two are the separate regressions, thethird is `suest`, and the fourth is the stacked regression. The `wage1`coefficient in column four equals the `wage` coefficient in column one, and`wage2` equals the `wage` coefficient in column two: stacking has reproducedboth single-equation fits exactly, in one regression, with both coefficients nowaddressable by `test`. Note the sample size, 4,484 in the stacked column against2,242 in the others — the reshape doubled the rows, which is the next point.One detail matters a great deal here, and it is easy to skip. Stacking puts **tworows per person** in the data, so the two error terms belonging to the same personare correlated by construction. The cross-equation test is precisely a comparison*across* those two rows, so its standard error has to account for thatcorrelation. Clustering on the stacking id does it, and it is not a cosmeticadjustment:|| test of the wage coefficient across equations ||---|---||`suest`| $\chi^2(1) = 72.22$ || stacked, **no** clustering | $F(1, 4478) = 114.12$ || stacked, `cluster(id)`| $F(1, 2241) = 72.14$ |Without clustering the statistic is inflated by more than half. With it, thestacked test reproduces `suest` almost exactly -- the small remaining gap is justthe $F$-versus-$\chi^2$ finite-sample adjustment. Note that `robust` alone will*not* fix this; the cluster variable has to be the id you stacked on.## Overlapping samplesThe same method extends to overlapping subsamples. Here south and smsa overlap— some observations belong to both — so a simple split is not possible.The reshape trick from the previous section will not work here, because a womanwho is both southern and in an SMSA has to appear in both subsamples rather thanbe assigned to one. `expand` handles that instead:1. `ta south smsa` shows the overlap, which is the reason for what follows.2. `preserve`, then `expand 2` duplicates every row, so each woman now has two copies.3. `bys idcode: g n=_n` numbers a woman's two copies 1 and 2.4. `keep if (n==1&south)|(n==2&smsa)` keeps copy 1 only if she is southern and copy 2 only if she is in an SMSA. A woman in both keeps both copies; a woman in neither drops out; a woman in exactly one keeps one. Each surviving row now represents one woman's membership in one subsample.5. `g hours1=hours*(n==1)` and `g hours2=hours*(n==2)` split the covariate by subsample, as before. Within this restricted sample `n==1` means southern and`n==2` means SMSA, so the copy number *is* the subsample indicator.6. `reg wage hours? n, cl(idcode)` fits both slopes at once, clustering on the woman rather than on a stacking id, since a woman can now contribute one row or two.```{stata}*| label: stata3*| echo: true*| collectcode: trueest clearsysuse nlsw88, clearta south smsareg wage hours if southest sto southreg wage hours if smsaest sto smsasuest south smsaest sto suestpreserveexpand 2bys idcode: g n=_nkeep if (n==1&south)|(n==2&smsa)* hours1 is hours in the south subsample (n==1), hours2 is hours in the* smsa subsample (n==2); within this restricted sample n==1 <=> south==1* and n==2 <=> smsa==1, so this is equivalent to but clearer than negating* the complementary condition.g hours1=hours*(n==1)g hours2=hours*(n==2)reg wage hours? n, cl(idcode)est sto stackedrestoreesttab south smsa suest stacked, nogaps mti```The cross-tab shows the overlap: of the 1,304 non-South women, 996 live in anSMSA, so the two subsamples share members and cannot be produced by a simplesplit. Expanding the data and keeping each observation under whicheversubsample it belongs to handles that. The pooled `hours1` is 0.0623497, againreproducing the South regression exactly, and `hours2` is 0.0954 for the SMSAsubsample. The `n` indicator is 0.341 with $p = 0.578$.## IV regressionThe interaction approach works with IV. Interact both the endogenous variable andthe instrument with the subsample indicator. Here `hours` is instrumented by`union` within each region.The point is not to get a different estimate. The two interacted 2SLScoefficients reproduce the two subsample IV regressions exactly, just as they didfor OLS. The point is that running them separately leaves the two estimates indifferent `ivregress` results with no joint covariance between them, so there isnothing to test the difference *with*. Interacting puts both in one estimation,so `test _b[hours1]-_b[hours2]=0` can reach both coefficients and theircovariance. That is the whole reason for the construction, and it is the samereason as in the OLS case.Two details specific to IV. The instrument must be split alongside theendogenous variable — `union1` and `union2`, not just `hours1` and `hours2` —because an instrument that is not subsample-specific would identify a singlepooled first stage and defeat the purpose. And the number of instruments muststill match the number of endogenous regressors: two of each here, so the systemis exactly identified, as each subsample regression was on its own.```{stata}*| label: stata4*| echo: true*| collectcode: truesysuse nlsw88, clearivregress 2sls wage (hours=union) if southivregress 2sls wage (hours=union) if !southgen hours1=hours*(south==1)gen hours2=hours*(south==0)gen union1=union*(south==1)gen union2=union*(south==0)ivregress 2sls wage south (hours1 hours2 = union1 union2)test _b[hours1]-_b[hours2]=0```The IV estimates are 0.978 in the South and 0.626 elsewhere, against OLS valuesof 0.062 and 0.111 — an order of magnitude larger, with standard errors tomatch (0.519 and 0.297). And the Chow test now gives $\chi^2(1) = 0.35$ with$p = 0.5554$, where the OLS version rejected at $p = 0.0405$. Instrumenting hasnot overturned the difference between regions; it has made the data tooimprecise to detect it. The lesson is about the test, not the subsamples: aChow test inherits the precision of whatever estimator it is built on.## IV with fixed effectsWith fixed effects the pooled regression needs the fixed effects themselves interacted with the subsample indicator. The first attempt below omits this and fails to reproduce the separate estimates:::: {.callout-warning}The examples below cluster standard errors on `race`, which in `nlsw88` has only three categories (White, Black, Other). Cluster-robust standard errors rely on asymptotics in the number of clusters $G \to \infty$; with $G=3$ they are severely downward-biased, inflating t-statistics and false-positive rates. These chunks use `race` purely to illustrate the fixed-effect/IV mechanics — in an actual analysis, cluster on a variable with many more categories (e.g., `industry` or `occupation`), or on the true level of treatment assignment/sampling design.:::```{stata}*| label: stata5*| echo: true*| collectcode: truesysuse nlsw88, cleargen hours1=hours*(south==1)gen hours2=hours*(south==0)gen union1=union*(south==1)gen union2=union*(south==0)ivreghdfe wage (hours=union) if south, a(race) cluster(race)ivreghdfe wage (hours=union) if !south, a(race) cluster(race)ivreghdfe wage south (hours1 hours2 = union1 union2) , a(race) cluster(race)```The separate regressions give 1.1071 and 0.7023. The pooled regression gives1.1420 and 0.6881 — close, but not equal, and that is the point. The pooledcoefficients do not match the separate regressions because the fixed effects are shared: one set of race effects is estimated off both subsamples at once, so neither subsample gets the within-group demeaning its own regression used. Interacting them with the subsample indicator fixes it:```{stata}*| label: stata6*| echo: true*| collectcode: truesysuse nlsw88, cleargen hours1=hours*(south==1)gen hours2=hours*(south==0)gen union1=union*(south==1)gen union2=union*(south==0)gen race1=race*(south==1)gen race2=race*(south==0)ivreghdfe wage (hours=union) if south, a(race) cluster(race)ivreghdfe wage (hours=union) if !south, a(race) cluster(race)ivregress 2sls wage south (hours1 hours2 = union1 union2) i.race1 i.race2, cluster(race)```This reproduces the separate estimates exactly: 1.107099 and 0.7023322 in the pooled regression against 1.107099 and 0.7023322 separately. The approach builds explicit dummies from the interaction of the fixed-effect variable and the subsample indicator, which becomes impractical when the number of fixed-effect levels is large.One caution about how those dummies were built. `race1 = race*(south==1)` multipliesa *categorical code* by an indicator, so non-south observations are assigned`race1 = 0` and then `i.race1` treats 0 as its own category. That is safe here onlybecause `race` has no zero level (it is coded 1/2/3). If the absorbed variable didhave a 0 category, those observations and all the non-south ones would be silentlycollapsed into the same dummy. For a general recipe, build the interactions from thecategory dummies directly (`i.race#i.south`) rather than from the code.Alternatively, pass the two interaction variables to `reghdfe`'s absorb option as a two-way fixed effect:```{stata}*| label: stata7*| echo: true*| collectcode: truesysuse nlsw88, cleargen hours1=hours*(south==1)gen hours2=hours*(south==0)gen union1=union*(south==1)gen union2=union*(south==0)gen race1=race*(south==1)gen race2=race*(south==0)ivreghdfe wage south (hours1 hours2 = union1 union2) , a(race1 race2) cluster(race)test _b[hours1]-_b[hours2]=0```Absorbing `race1` and `race2` as a two-way fixed effect gives the same 1.107099and 0.7023322 without building the dummies by hand, and scales to manyfixed-effect levels. The Chow test is $F(1,2) = 0.31$ with $p = 0.6325$ — butread that denominator: 2 degrees of freedom, because the standard errors areclustered on `race`, which has three categories. This is the problem the calloutabove flags, and it is why these IV/FE numbers illustrate mechanics rather thansupport any conclusion about the South.## Chow test with different covariatesThe equations need not share the same covariates. If equation 1 includes $X_2$ and equation 2 does not,$$ Y_1 = \beta_0 + \beta_1 X_1 + \beta_2 X_2 + \epsilon_1, \qquad Y_2 = \gamma_0 + \gamma_1 X_1 + \epsilon_2, $$ {#eq-chow-test-1}the second equation implicitly sets the coefficient on $X_2$ to zero. In the stacked regression, replace $X_2$ with a constant (e.g. 1) for the $Y_2$ subsample, so that its "coefficient" is absorbed into the intercept:```{stata}*| label: stata8*| echo: true*| collectcode: truesysuse nlsw88, clearreg south wage hours tenureest sto southreg smsa wage hoursest sto smsasuest south smsaest sto suestpreservegen Y1=southgen Y2=smsagen id=_nreshape long Y, i(id) j(subsample)gen wage1=wage*(subsample==1)gen wage2=wage*(subsample==2)gen hours1=hours*(subsample==1)gen hours2=hours*(subsample==2)replace tenure=1 if subsample==2gen tenure1= tenure*(subsample==1)gen tenure2= tenure*(subsample==2)reg Y wage? hours? tenure? subsample, cluster(id)est sto chowtest _b[hours1]-_b[hours2]=0esttab suest chow, nogaps mtirestore```The stacked model reproduces `suest`'s point estimates exactly: the hourscoefficient is 0.004828 in the `south` equation and 0.0003663 in the `smsa` one,in both. Here the covariates differ — `tenure` appears in the first equationonly — and the trick of setting `tenure = 1` for the second subsample lets itscoefficient be absorbed by that equation's intercept. The Chow test on the hourscoefficient gives $F(1, 2241) = 10.03$ with $p = 0.0016$: hours predicts livingin the South quite differently from how it predicts living in an SMSA. (The`esttab` columns do not line up because `suest` stores equation-qualified names like `south:wage` while the stacked model stores plain `wage`.)## Conclusion`suest` and the stacking method both test cross-equation hypotheses with robust standard errors. `sureg` does the same under a GLS framework, but it assumes homoscedastic errors across equations; under misspecification it remains consistent but its standard errors are invalid. When the equations share covariates `sureg` and OLS give the same point estimates; with different covariates they diverge.The stacking approach is the most portable. It works in any language, extends to IV and fixed-effect models, and requires only that the single-equation estimator works — no special post-estimation infrastructure.One pattern runs through every example in this chapter, and it is worth statingonce on its own. A Chow test is a hypothesis about two coefficients that live intwo different regressions. Stata's `test` can only reach coefficients inside asingle stored estimation result, and, more importantly, testing a differencerequires the covariance between the two estimates, which separate regressionsnever produce. Every construction here — the reshape for two outcomes, the`expand` for overlapping samples, the split instruments under IV, the absorbedfixed effects — exists to move both coefficients into one estimation so that thecovariance exists and `test` can use it. `suest` does thesame thing by a different route, refitting the stored estimates jointly with arobust cross-equation covariance matrix.So the choice among them is practical rather than statistical. Use `suest` whenthe estimator supports it and the samples are the same. Stack when the samplesoverlap, when the covariates differ across equations, or when the estimator isone `suest` will not take — which, in practice, means most fixed-effect and IVcommands.