Code Run:
ssc install b1x2
clear all

set seed 0
set obs 500

gen double x1 = invnorm(uniform())
gen double x21 = x1*1 + invnorm(uniform())
gen double x22 = x1*0.25 + x21*0.75 + invnorm(uniform())
gen double x23 = x1*0.4 + x21*0.6 + x22*0.4 + invnorm(uniform())
gen double y = x1*1 + x21*2 + x22*0.5 + x23*0.75 + invnorm(uniform())
gen cluster = floor((_n - 1) / 50) + 1

b1x2 y, x1all(x1 x21) x2all(x22 x23) x1only(x1)
b1x2 y, x1all(x1 x21 x22) x2all(x23) x1only(x1)
b1x2 y, x1all(x1 x21) x2all(x22 x23) x2delta(g1 = x22 x23) x1only(x1)



Output:
. ssc install b1x2
checking b1x2 consistency and verifying not already installed...
all files already exist and are up to date.

. clear all

.
. set seed 0

. set obs 500
Number of observations (_N) was 0, now 500.

.
. gen double x1 = invnorm(uniform())

. gen double x21 = x1*1 + invnorm(uniform())

. gen double x22 = x1*0.25 + x21*0.75 + invnorm(uniform())

. gen double x23 = x1*0.4 + x21*0.6 + x22*0.4 + invnorm(uniform())

. gen double y = x1*1 + x21*2 + x22*0.5 + x23*0.75 + invnorm(uniform())

. gen cluster = floor((_n - 1) / 50) + 1

.
. b1x2 y, x1all(x1 x21) x2all(x22 x23) x1only(x1)

                                                      Number of obs = 500


Restricted regression:

. b1x2: reg y x1 x21

------------------------------------------------------------------------------
           y | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
          x1 |   1.453369   .0963084    15.09   0.000     1.264608     1.64213
         x21 |   2.992916   .0682683    43.84   0.000     2.859113     3.12672
       _cons |   .0269501   .0677137     0.40   0.691    -.1057664    .1596665
------------------------------------------------------------------------------

Unrestricted regression:

. b1x2: reg y x1 x21  x22 x23
------------------------------------------------------------------------------
           y | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
          x1 |   .9509434   .0680711    13.97   0.000     .8175264     1.08436
         x21 |   1.956069   .0620514    31.52   0.000      1.83445    2.077688
         x22 |   .5320202   .0469754    11.33   0.000     .4399502    .6240903
         x23 |   .7323302   .0446836    16.39   0.000     .6447519    .8199085
       _cons |   .0415917   .0454547     0.92   0.360    -.0474979    .1306812
------------------------------------------------------------------------------

Decomposition of changes in coefficients on x1 vars:

       x1 x21

into parts due to these groups:

ALL  = x22 x23

------------------------------------------------------------------------------
           y | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
x1           |
         ALL |   .5024257   .0749808     6.70   0.000      .355466    .6493854
        __TC |   .5024257   .0749808     6.70   0.000      .355466    .6493854
------------------------------------------------------------------------------

Note: The __TC...  line is the sum of all x2 variables' impacts on each x1.
      The reported covariance between this coef and all others is zero.
      This is NOT correct!!

Done with -b1x2-.


. b1x2 y, x1all(x1 x21 x22) x2all(x23) x1only(x1)

                                                      Number of obs = 500


Restricted regression:

. b1x2: reg y x1 x21 x22

------------------------------------------------------------------------------
           y | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
          x1 |   1.265919   .0810251    15.62   0.000     1.107113    1.424725
         x21 |   2.386221   .0697658    34.20   0.000     2.249483     2.52296
         x22 |   .8116855   .0543045    14.95   0.000     .7052506    .9181204
       _cons |  -.0001164   .0563107    -0.00   0.998    -.1104834    .1102506
------------------------------------------------------------------------------

Unrestricted regression:

. b1x2: reg y x1 x21 x22  x23
------------------------------------------------------------------------------
           y | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
          x1 |   .9509434   .0680711    13.97   0.000     .8175264     1.08436
         x21 |   1.956069   .0620514    31.52   0.000      1.83445    2.077688
         x22 |   .5320202   .0469754    11.33   0.000     .4399502    .6240903
         x23 |   .7323302   .0446836    16.39   0.000     .6447519    .8199085
       _cons |   .0415917   .0454547     0.92   0.360    -.0474979    .1306812
------------------------------------------------------------------------------

Decomposition of changes in coefficients on x1 vars:

       x1 x21 x22

into parts due to these groups:

ALL  = x23

------------------------------------------------------------------------------
           y | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
x1           |
         ALL |   .3149754    .051801     6.08   0.000     .2134473    .4165035
        __TC |   .3149754    .051801     6.08   0.000     .2134473    .4165035
------------------------------------------------------------------------------

Note: The __TC...  line is the sum of all x2 variables' impacts on each x1.
      The reported covariance between this coef and all others is zero.
      This is NOT correct!!

Done with -b1x2-.


. b1x2 y, x1all(x1 x21) x2all(x22 x23) x2delta(g1 = x22 x23) x1only(x1)

                                                      Number of obs = 500


Restricted regression:

. b1x2: reg y x1 x21

------------------------------------------------------------------------------
           y | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
          x1 |   1.453369   .0963084    15.09   0.000     1.264608     1.64213
         x21 |   2.992916   .0682683    43.84   0.000     2.859113     3.12672
       _cons |   .0269501   .0677137     0.40   0.691    -.1057664    .1596665
------------------------------------------------------------------------------

Unrestricted regression:

. b1x2: reg y x1 x21  x22 x23
------------------------------------------------------------------------------
           y | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
          x1 |   .9509434   .0680711    13.97   0.000     .8175264     1.08436
         x21 |   1.956069   .0620514    31.52   0.000      1.83445    2.077688
         x22 |   .5320202   .0469754    11.33   0.000     .4399502    .6240903
         x23 |   .7323302   .0446836    16.39   0.000     .6447519    .8199085
       _cons |   .0415917   .0454547     0.92   0.360    -.0474979    .1306812
------------------------------------------------------------------------------

Decomposition of changes in coefficients on x1 vars:

       x1 x21

into parts due to these groups:

g1  = x22 x23

------------------------------------------------------------------------------
           y | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
-------------+----------------------------------------------------------------
x1           |
          g1 |   .5024257   .0749808     6.70   0.000      .355466    .6493854
        __TC |   .5024257   .0749808     6.70   0.000      .355466    .6493854
------------------------------------------------------------------------------

Note: The __TC...  line is the sum of all x2 variables' impacts on each x1.
      The reported covariance between this coef and all others is zero.
      This is NOT correct!!

Done with -b1x2-.
