Chapter 7. Import Tariffs and Dumping

Empirical exercise

In this exercise, you are asked to reproduce some of the empirical results from Feenstra (1989).

To complete the exercise, the files “cars.csv, trucks.csv, cycon.csv, cyship.csv, cypool.csv” should be stored in the directory: first-edition/Chapter-7. Each of these can be used in STATA programs “cars.do, trucks.do, cycon.do, cyship.do, cypool.do” to create a dataset with the variables described in “Documentation_Chp7.doc.”

Data Description for Feenstra (1989)

There are five data sets in excel format: cars.csv, trucks.csv, cycon.csv, cypool.csv, cyship.csv. All of the variables in the data sets are fitted values from instrumental variables regression.

Variable Description
iprice Import price
usprice US price
gprice German price
tariff Tariff rate
income Expenditure on product class
lag0 First order polynomial lag on betas
lag1 Second order polynomial lag on betas
lag2 Third order polynomial lag on betas
y Import price transformed, y = iprice – income
x1 US price transformed, usprice – income
x2 German price transformed, gprice – income
z0 First order polynomial lag transformed
z1 Second order polynomial lag transformed
z2 Third order polynomial lag transformed

Note: all the transformations are done to reflect their restrictions. So some are restricted to homogeneity, where others are restricted to symmetry and homogeneity.

Explanation of lag0, lag1 and lag2

With a second-order polynomial, \(\alpha_i = a + bi + ci^2\) it follows that

\[\begin{align} \sum_{i=0}^4 \log(c_t^* s_{t-i}) \alpha_i &= \sum_{i=0}^4 \log(c_t^* s_{t-i}) (a + bi + ci^2) \\ &= a \sum_{i=0}^4 \log(c_t^* s_{t-i}) + b \sum_{i=0}^4 \log(c_t^* s_{t-i}) i + c \sum_{i=0}^4 \log(c_t^* s_{t-i}) i^2. \end{align}\]

Letting \(\log(c_t^* s_{t-i}) = x_i\), we can define the three lags appeating in this formula as

\[\begin{align} \text{lag}0 = x_0 + x_1 + x_2 + x_3 + x_4 \\ \text{lag}1 = 0 + x_1 + 2x_2 + 3x_3 + 4x_4 \\ \text{lag}2 = 0 + x_1 + 4x_2 + 9x_3 + 16x_4. \end{align}\]

Then to compute the total pass-through of the exchange rate, it follow that,

\[\begin{align} \sum_{i=0}^4 \alpha_i &= \sum_{i=0}^4 (a + bi + ci^2) \\ &= 5a + b(1 + 2 + 3 + 4) + c(1^2 + 2^2 + 3^2 + 4^2) \\ &= 5a + 10b + 30c. \end{align}\]

When estimating the equation using lag0, lag1, and lag2, the coefficient estimates that you obtain are a, b, and c, respectively. Using this, you can recover the coefficient estimate and standard error for each individual exchange rate term reported in the Table 7.2. You can always do this by hand, but STATA does offer a command to calculate the linear combination of the estimated coefficients. The syntax for this is,

lincom lag0 + lag1 + lag2

This will calculate the coefficient estimates for the \(\log(c_t^* s_{t-1})\). This is much in a same way as the syntax for test. Lag0 in above command does not refer to the data, but the coefficient estimate associated with lag0.

Exercise 1

Replicate Table 7.2, i.e., run the specifications of (7.34) without imposing the tests of symmetry or homogeneity. Duplicate all of the coefficients that are reported in this table, except the Durbin-Watson statistics.

Feenstra’s code

Cars

clear
capture log close

log using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapter-7\cars.log, replace

insheet using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapter-7\cars.csv
* drop if time<=12
regress iprice time timesq lag0 lag1 lag2 usprice gprice income

*i=0
lincom lag0

*i=1
lincom lag0+lag1+lag2

*i=2
lincom lag0+2*lag1+4*lag2

*i=3
lincom lag0+3*lag1+9*lag2

*i=4
lincom lag0+4*lag1+16*lag2

*summation of betai's
lincom 5*lag0+10*lag1+30*lag2

*Impose the homogeneity constraint
regress y time timesq z0 z1 z2 x1 x2

*summation of betai's
lincom 5*z0+10*z1+30*z2

log close
exit

Output:

. clear

. capture log close

. 
. log using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapte
> r-7\cars.log, replace
(note: file Z:\home\pacha\github\advanced-international-trade\first-edition\Chapte
> r-7\cars.log not found)
----------------------------------------------------------------------------------
      name:  <unnamed>
       log:  Z:\home\pacha\github\advanced-international-trade\first-edition\Chapt
> er-7\cars.log
  log type:  text
 opened on:  19 Jun 2024, 13:46:47

. 
. insheet using Z:\home\pacha\github\advanced-international-trade\first-edition\Ch
> apter-7\cars.csv
(15 vars, 46 obs)

. * drop if time<=12
. regress iprice time timesq lag0 lag1 lag2 usprice gprice income

      Source |       SS       df       MS              Number of obs =      29
-------------+------------------------------           F(  8,    20) =  313.58
       Model |  1.88266593     8  .235333241           Prob > F      =  0.0000
    Residual |  .015009666    20  .000750483           R-squared     =  0.9921
-------------+------------------------------           Adj R-squared =  0.9889
       Total |   1.8976756    28  .067774128           Root MSE      =  .02739

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        time |  -.0071005   .0198015    -0.36   0.724    -.0484056    .0342047
      timesq |   .2232319   .1698526     1.31   0.204    -.1310743    .5775381
        lag0 |   .4435311   .1011438     4.39   0.000     .2325488    .6545134
        lag1 |  -.1156862    .165797    -0.70   0.493    -.4615325    .2301602
        lag2 |  -.0116016   .0404346    -0.29   0.777    -.0959467    .0727435
     usprice |   1.002242   .9090603     1.10   0.283    -.8940243    2.898509
      gprice |   .0838093   .0880309     0.95   0.352      -.09982    .2674386
      income |  -.0257564   .1138551    -0.23   0.823    -.2632538    .2117411
       _cons |   3.370612   4.178309     0.81   0.429    -5.345189    12.08641
------------------------------------------------------------------------------

. 
. *i=0
. lincom lag0

 ( 1)  lag0 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .4435311   .1011438     4.39   0.000     .2325488    .6545134
------------------------------------------------------------------------------

. 
. *i=1
. lincom lag0+lag1+lag2

 ( 1)  lag0 + lag1 + lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .3162433    .041669     7.59   0.000     .2293232    .4031634
------------------------------------------------------------------------------

. 
. *i=2
. lincom lag0+2*lag1+4*lag2

 ( 1)  lag0 + 2*lag1 + 4*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .1657523   .0782848     2.12   0.047     .0024531    .3290514
------------------------------------------------------------------------------

. 
. *i=3
. lincom lag0+3*lag1+9*lag2

 ( 1)  lag0 + 3*lag1 + 9*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   -.007942    .051645    -0.15   0.879    -.1156716    .0997877
------------------------------------------------------------------------------

. 
. *i=4
. lincom lag0+4*lag1+16*lag2

 ( 1)  lag0 + 4*lag1 + 16*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |  -.2048394   .0992571    -2.06   0.052    -.4118862    .0022073
------------------------------------------------------------------------------

. 
. *summation of betai's
. lincom 5*lag0+10*lag1+30*lag2

 ( 1)  5*lag0 + 10*lag1 + 30*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .7127453   .0974163     7.32   0.000     .5095385     .915952
------------------------------------------------------------------------------

. 
. *Impose the homogeneity constraint
. regress y time timesq z0 z1 z2 x1 x2

      Source |       SS       df       MS              Number of obs =      29
-------------+------------------------------           F(  7,    21) =   88.33
       Model |  .457112589     7  .065301798           Prob > F      =  0.0000
    Residual |  .015525208    21  .000739296           R-squared     =  0.9672
-------------+------------------------------           Adj R-squared =  0.9562
       Total |  .472637797    28  .016879921           Root MSE      =  .02719

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        time |   .0089206   .0042701     2.09   0.049     .0000405    .0178007
      timesq |   .1355201    .131858     1.03   0.316    -.1386936    .4097339
          z0 |    .418623   .0958376     4.37   0.000     .2193179    .6179281
          z1 |  -.0822192   .1595793    -0.52   0.612    -.4140826    .2496442
          z2 |  -.0182092   .0393397    -0.46   0.648    -.1000206    .0636022
          x1 |   .2590963   .1491977     1.74   0.097    -.0511772    .5693698
          x2 |    .115353   .0787821     1.46   0.158    -.0484832    .2791893
       _cons |   6.813711   .4488137    15.18   0.000     5.880352     7.74707
------------------------------------------------------------------------------

. 
. *summation of betai's
. lincom 5*z0+10*z1+30*z2

 ( 1)  5*z0 + 10*z1 + 30*z2 = 0

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .7246472   .0956301     7.58   0.000     .5257736    .9235208
------------------------------------------------------------------------------

. 
. log close
      name:  <unnamed>
       log:  Z:\home\pacha\github\advanced-international-trade\first-edition\Chapt
> er-7\cars.log
  log type:  text
 closed on:  19 Jun 2024, 13:46:50
----------------------------------------------------------------------------------

. exit

end of do-file

Cycon

clear
capture log close

log using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapter-7\cycon.log,replace

insheet using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapter-7\cycon.csv
drop if time<=16
drop if time>=45
regress iprice dummy1 dummy2 dummy3 time timesq lag0 lag1 lag2 /*
     */ tariff usprice gprice income

*i=0
lincom lag0

*i=1
lincom lag0+lag1+lag2

*i=2
lincom lag0+2*lag1+4*lag2

*i=3
lincom lag0+3*lag1+9*lag2

*i=4
lincom lag0+4*lag1+16*lag2

*summation of betai's
lincom 5*lag0+10*lag1+30*lag2

*Impose the homogeneity and symmetry constraints
regress y dummy1 dummy2 dummy3 time timesq z0 z1 z2 x1 x2

*summation of betai's
lincom 5*z0+10*z1+30*z2

log close
exit

Output:

. clear

. capture log close

. 
. log using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapte
> r-7\cycon.log,replace
(note: file Z:\home\pacha\github\advanced-international-trade\first-edition\Chapte
> r-7\cycon.log not found)
----------------------------------------------------------------------------------
      name:  <unnamed>
       log:  Z:\home\pacha\github\advanced-international-trade\first-edition\Chapt
> er-7\cycon.log
  log type:  text
 opened on:  19 Jun 2024, 13:48:28

. 
. insheet using Z:\home\pacha\github\advanced-international-trade\first-edition\Ch
> apter-7\cycon.csv
(19 vars, 57 obs)

. drop if time<=16
(16 observations deleted)

. drop if time>=45
(13 observations deleted)

. regress iprice dummy1 dummy2 dummy3 time timesq lag0 lag1 lag2 /*
>      */ tariff usprice gprice income

      Source |       SS       df       MS              Number of obs =      28
-------------+------------------------------           F( 12,    15) =   23.08
       Model |  1.16011255    12  .096676046           Prob > F      =  0.0000
    Residual |  .062818315    15  .004187888           R-squared     =  0.9486
-------------+------------------------------           Adj R-squared =  0.9075
       Total |  1.22293087    27  .045293736           Root MSE      =  .06471

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      dummy1 |   .0634105   .0430635     1.47   0.162    -.0283773    .1551982
      dummy2 |  -.0305492   .0369325    -0.83   0.421    -.1092689    .0481706
      dummy3 |   .0397123   .0355224     1.12   0.281     -.036002    .1154265
        time |  -.0197231   .0600121    -0.33   0.747    -.1476358    .1081896
      timesq |     .41476   .4312669     0.96   0.351    -.5044635    1.333984
        lag0 |   .2879891   .2546382     1.13   0.276    -.2547594    .8307377
        lag1 |  -.1465425   .3537084    -0.41   0.685    -.9004542    .6073692
        lag2 |   .0306294   .0866307     0.35   0.729    -.1540196    .2152783
      tariff |   .9493961   .2181512     4.35   0.001     .4844179    1.414374
     usprice |   .6821239    .597725     1.14   0.272    -.5918968    1.956145
      gprice |   .0556783   .1064855     0.52   0.609    -.1712902    .2826468
      income |  -.2273151   1.683928    -0.13   0.894    -3.816524    3.361893
       _cons |   6.738914   11.55768     0.58   0.569     -17.8957    31.37353
------------------------------------------------------------------------------

. 
. *i=0
. lincom lag0

 ( 1)  lag0 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .2879891   .2546382     1.13   0.276    -.2547594    .8307377
------------------------------------------------------------------------------

. 
. *i=1
. lincom lag0+lag1+lag2

 ( 1)  lag0 + lag1 + lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |    .172076   .0947437     1.82   0.089    -.0298654    .3740173
------------------------------------------------------------------------------

. 
. *i=2
. lincom lag0+2*lag1+4*lag2

 ( 1)  lag0 + 2*lag1 + 4*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .1174215   .1450444     0.81   0.431    -.1917333    .4265763
------------------------------------------------------------------------------

. 
. *i=3
. lincom lag0+3*lag1+9*lag2

 ( 1)  lag0 + 3*lag1 + 9*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .1240258   .0837432     1.48   0.159    -.0544686    .3025202
------------------------------------------------------------------------------

. 
. *i=4
. lincom lag0+4*lag1+16*lag2

 ( 1)  lag0 + 4*lag1 + 16*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .1918888   .2302309     0.83   0.418    -.2988368    .6826143
------------------------------------------------------------------------------

. 
. *summation of betai's
. lincom 5*lag0+10*lag1+30*lag2

 ( 1)  5*lag0 + 10*lag1 + 30*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .8934012   .3594978     2.49   0.025     .1271498    1.659652
------------------------------------------------------------------------------

. 
. *Impose the homogeneity and symmetry constraints
. regress y dummy1 dummy2 dummy3 time timesq z0 z1 z2 x1 x2

      Source |       SS       df       MS              Number of obs =      28
-------------+------------------------------           F( 10,    17) =    8.64
       Model |  .321112891    10  .032111289           Prob > F      =  0.0001
    Residual |  .063155914    17  .003715054           R-squared     =  0.8356
-------------+------------------------------           Adj R-squared =  0.7390
       Total |  .384268805    27  .014232178           Root MSE      =  .06095

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      dummy1 |     .06846   .0367494     1.86   0.080    -.0090744    .1459945
      dummy2 |  -.0296761   .0333669    -0.89   0.386    -.1000741    .0407219
      dummy3 |   .0404237   .0329202     1.23   0.236    -.0290317    .1098792
        time |   -.005507   .0157472    -0.35   0.731    -.0387307    .0277166
      timesq |   .3625585    .253875     1.43   0.171    -.1730708    .8981879
          z0 |   .3294302   .1732048     1.90   0.074        -.036    .6948604
          z1 |  -.1849915   .2875633    -0.64   0.529    -.7916969     .421714
          z2 |   .0391241   .0718017     0.54   0.593    -.1123642    .1906124
          x1 |   .6062422    .501893     1.21   0.244    -.4526596    1.665144
          x2 |   .0639407   .0948443     0.67   0.509    -.1361634    .2640447
       _cons |    9.80264   1.904478     5.15   0.000     5.784542    13.82074
------------------------------------------------------------------------------

. 
. *summation of betai's
. lincom 5*z0+10*z1+30*z2

 ( 1)  5*z0 + 10*z1 + 30*z2 = 0

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .9709581    .144562     6.72   0.000      .665959    1.275957
------------------------------------------------------------------------------

. 
. log close
      name:  <unnamed>
       log:  Z:\home\pacha\github\advanced-international-trade\first-edition\Chapt
> er-7\cycon.log
  log type:  text
 closed on:  19 Jun 2024, 13:48:30
----------------------------------------------------------------------------------

. exit

end of do-file

Cypool

clear
capture log close
log using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapter-7\cypool.log,replace

insheet using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapter-7\cypool.csv

regress iprice dummy1 dummy2 dummy3 time timesq lag0 lag1 lag2 /*
        */ tariff usprice gprice income

*i=0
lincom lag0

*i=1
lincom lag0+lag1+lag2

*i=2
lincom lag0+2*lag1+4*lag2

*i=3
lincom lag0+3*lag1+9*lag2

*i=4
lincom lag0+4*lag1+16*lag2

*summation of betai's
lincom 5*lag0+10*lag1+30*lag2

*Impose the homogeneity and symmetry constraints
regress y dummy1 dummy2 dummy3 time timesq z0 z1 z2 x1 x2

*summation of betai's
lincom 5*z0+10*z1+30*z2

log close
exit

Output:

. clear

. capture log close

. log using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapte
> r-7\cypool.log,replace
(note: file Z:\home\pacha\github\advanced-international-trade\first-edition\Chapte
> r-7\cypool.log not found)
----------------------------------------------------------------------------------
      name:  <unnamed>
       log:  Z:\home\pacha\github\advanced-international-trade\first-edition\Chapt
> er-7\cypool.log
  log type:  text
 opened on:  19 Jun 2024, 13:49:29

. 
. insheet using Z:\home\pacha\github\advanced-international-trade\first-edition\Ch
> apter-7\cypool.csv
(19 vars, 65 obs)

. 
. regress iprice dummy1 dummy2 dummy3 time timesq lag0 lag1 lag2 /*
>         */ tariff usprice gprice income

      Source |       SS       df       MS              Number of obs =      65
-------------+------------------------------           F( 12,    52) =   28.69
       Model |   3.7792523    12  .314937692           Prob > F      =  0.0000
    Residual |  .570888473    52  .010978624           R-squared     =  0.8688
-------------+------------------------------           Adj R-squared =  0.8385
       Total |  4.35014078    64   .06797095           Root MSE      =  .10478

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      dummy1 |   .0415538    .039227     1.06   0.294    -.0371609    .1202686
      dummy2 |  -.0163882   .0377145    -0.43   0.666     -.092068    .0592915
      dummy3 |   .0336136   .0373974     0.90   0.373    -.0414297     .108657
        time |  -.0460622    .025957    -1.77   0.082    -.0981486    .0060242
      timesq |   .6966283   .3011555     2.31   0.025     .0923156    1.300941
        lag0 |   .4468833     .20907     2.14   0.037     .0273536    .8664129
        lag1 |  -.4474712   .3375047    -1.33   0.191    -1.124724    .2297816
        lag2 |   .1041952   .0844251     1.23   0.223    -.0652161    .2736065
      tariff |   1.129379   .1548965     7.29   0.000     .8185561    1.440201
     usprice |   .5715626   .5883761     0.97   0.336    -.6091005    1.752226
      gprice |   .0630112   .1045199     0.60   0.549    -.1467234    .2727457
      income |    .015869    .010022     1.58   0.119    -.0042417    .0359797
       _cons |    5.86047   2.524698     2.32   0.024     .7942919    10.92665
------------------------------------------------------------------------------

. 
. *i=0
. lincom lag0

 ( 1)  lag0 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .4468833     .20907     2.14   0.037     .0273536    .8664129
------------------------------------------------------------------------------

. 
. *i=1
. lincom lag0+lag1+lag2

 ( 1)  lag0 + lag1 + lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .1036072    .091221     1.14   0.261    -.0794411    .2866556
------------------------------------------------------------------------------

. 
. *i=2
. lincom lag0+2*lag1+4*lag2

 ( 1)  lag0 + 2*lag1 + 4*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |  -.0312784   .1532273    -0.20   0.839    -.3387515    .2761948
------------------------------------------------------------------------------

. 
. *i=3
. lincom lag0+3*lag1+9*lag2

 ( 1)  lag0 + 3*lag1 + 9*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .0422264   .0851726     0.50   0.622    -.1286849    .2131377
------------------------------------------------------------------------------

. 
. *i=4
. lincom lag0+4*lag1+16*lag2

 ( 1)  lag0 + 4*lag1 + 16*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .3241215   .2208683     1.47   0.148    -.1190832    .7673262
------------------------------------------------------------------------------

. 
. *summation of betai's
. lincom 5*lag0+10*lag1+30*lag2

 ( 1)  5*lag0 + 10*lag1 + 30*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |     .88556   .2128404     4.16   0.000     .4584645    1.312655
------------------------------------------------------------------------------

. 
. *Impose the homogeneity and symmetry constraints
. regress y dummy1 dummy2 dummy3 time timesq z0 z1 z2 x1 x2

      Source |       SS       df       MS              Number of obs =      65
-------------+------------------------------           F( 10,    54) = 1112.76
       Model |  126.137525    10  12.6137525           Prob > F      =  0.0000
    Residual |  .612117901    54  .011335517           R-squared     =  0.9952
-------------+------------------------------           Adj R-squared =  0.9943
       Total |  126.749643    64  1.98046316           Root MSE      =  .10647

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      dummy1 |   .0390208   .0398367     0.98   0.332     -.040847    .1188886
      dummy2 |  -.0079258   .0380454    -0.21   0.836    -.0842022    .0683506
      dummy3 |   .0384614    .037904     1.01   0.315    -.0375315    .1144543
        time |   -.016386   .0142608    -1.15   0.256    -.0449772    .0122052
      timesq |   .3842091   .2086319     1.84   0.071    -.0340725    .8024908
          z0 |   .4880678   .1718376     2.84   0.006     .1435541    .8325815
          z1 |   -.432728   .2915576    -1.48   0.144    -1.017266    .1518097
          z2 |   .0987337   .0738784     1.34   0.187    -.0493836    .2468511
          x1 |  -.0833764   .1803078    -0.46   0.646    -.4448718     .278119
          x2 |   -.009202   .0973665    -0.09   0.925      -.20441     .186006
       _cons |    8.96105      .8661    10.35   0.000     7.224624    10.69748
------------------------------------------------------------------------------

. 
. *summation of betai's
. lincom 5*z0+10*z1+30*z2

 ( 1)  5*z0 + 10*z1 + 30*z2 = 0

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |    1.07507   .1528333     7.03   0.000     .7686582    1.381483
------------------------------------------------------------------------------

. 
. log close
      name:  <unnamed>
       log:  Z:\home\pacha\github\advanced-international-trade\first-edition\Chapt
> er-7\cypool.log
  log type:  text
 closed on:  19 Jun 2024, 13:49:32
----------------------------------------------------------------------------------

. exit

end of do-file

Cyship

clear
capture log close

log using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapter-7\cyship.log,replace

insheet using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapter-7\cyship.csv
drop if time<=16
regress iprice dummy1 dummy2 dummy3 time timesq lag0 lag1 lag2 /*
     */ tariff usprice gprice income

*i=0
lincom lag0

*i=1
lincom lag0+lag1+lag2

*i=2
lincom lag0+2*lag1+4*lag2

*i=3
lincom lag0+3*lag1+9*lag2

*i=4
lincom lag0+4*lag1+16*lag2

*summation of betai's
lincom 5*lag0+10*lag1+30*lag2

*Impose the homogeneity and symmetry constraints
regress y dummy1 dummy2 dummy3 time timesq z0 z1 z2 x1 x2

*summation of betai's
lincom 5*z0+10*z1+30*z2

log close
exit

Output:

. clear

. capture log close

. 
. log using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapte
> r-7\cyship.log,replace
(note: file Z:\home\pacha\github\advanced-international-trade\first-edition\Chapte
> r-7\cyship.log not found)
----------------------------------------------------------------------------------
      name:  <unnamed>
       log:  Z:\home\pacha\github\advanced-international-trade\first-edition\Chapt
> er-7\cyship.log
  log type:  text
 opened on:  19 Jun 2024, 13:51:15

. 
. insheet using Z:\home\pacha\github\advanced-international-trade\first-edition\Ch
> apter-7\cyship.csv
(19 vars, 57 obs)

. drop if time<=16
(16 observations deleted)

. regress iprice dummy1 dummy2 dummy3 time timesq lag0 lag1 lag2 /*
>      */ tariff usprice gprice income

      Source |       SS       df       MS              Number of obs =      37
-------------+------------------------------           F( 12,    24) =   13.33
       Model |  2.66760727    12  .222300606           Prob > F      =  0.0000
    Residual |  .400138786    24  .016672449           R-squared     =  0.8696
-------------+------------------------------           Adj R-squared =  0.8043
       Total |  3.06774606    36  .085215168           Root MSE      =  .12912

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      dummy1 |   .0785462   .1458493     0.54   0.595    -.2224719    .3795643
      dummy2 |   .0405177   .1327231     0.31   0.763    -.2334092    .3144447
      dummy3 |   .0250007   .0625785     0.40   0.693     -.104155    .1541563
        time |  -.0778322   .0554157    -1.40   0.173    -.1922045    .0365401
      timesq |   1.035907    .568177     1.82   0.081    -.1367526    2.208567
        lag0 |   .7977086   .6650261     1.20   0.242    -.5748378    2.170255
        lag1 |  -1.112321   1.191004    -0.93   0.360    -3.570432    1.345791
        lag2 |   .2729264   .3031369     0.90   0.377    -.3527174    .8985702
      tariff |   1.388199   .2721709     5.10   0.000     .8264657    1.949932
     usprice |   1.142866   1.998888     0.57   0.573    -2.982636    5.268368
      gprice |   .1241107    .209419     0.59   0.559    -.3081089    .5563303
      income |  -.2151571   .5969111    -0.36   0.722    -1.447121    1.016807
       _cons |   4.611564   6.469095     0.71   0.483    -8.739992    17.96312
------------------------------------------------------------------------------

. 
. *i=0
. lincom lag0

 ( 1)  lag0 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .7977086   .6650261     1.20   0.242    -.5748378    2.170255
------------------------------------------------------------------------------

. 
. *i=1
. lincom lag0+lag1+lag2

 ( 1)  lag0 + lag1 + lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |  -.0416857   .2597043    -0.16   0.874     -.577689    .4943175
------------------------------------------------------------------------------

. 
. *i=2
. lincom lag0+2*lag1+4*lag2

 ( 1)  lag0 + 2*lag1 + 4*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |  -.3352272   .5234521    -0.64   0.528    -1.415579    .7451248
------------------------------------------------------------------------------

. 
. *i=3
. lincom lag0+3*lag1+9*lag2

 ( 1)  lag0 + 3*lag1 + 9*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |  -.0829159   .2158146    -0.38   0.704    -.5283353    .3625036
------------------------------------------------------------------------------

. 
. *i=4
. lincom lag0+4*lag1+16*lag2

 ( 1)  lag0 + 4*lag1 + 16*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .7152483   .7584352     0.94   0.355     -.850085    2.280582
------------------------------------------------------------------------------

. 
. *summation of betai's
. lincom 5*lag0+10*lag1+30*lag2

 ( 1)  5*lag0 + 10*lag1 + 30*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   1.053128   .5219069     2.02   0.055    -.0240347    2.130291
------------------------------------------------------------------------------

. 
. *Impose the homogeneity and symmetry constraints
. regress y dummy1 dummy2 dummy3 time timesq z0 z1 z2 x1 x2

      Source |       SS       df       MS              Number of obs =      37
-------------+------------------------------           F( 10,    26) =   14.13
       Model |  2.49470896    10  .249470896           Prob > F      =  0.0000
    Residual |   .45918364    26  .017660909           R-squared     =  0.8445
-------------+------------------------------           Adj R-squared =  0.7848
       Total |   2.9538926    36  .082052572           Root MSE      =  .13289

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      dummy1 |   .0455011   .0952729     0.48   0.637    -.1503351    .2413373
      dummy2 |   .0311428   .0889305     0.35   0.729    -.1516564    .2139419
      dummy3 |   .0367732   .0635252     0.58   0.568    -.0938049    .1673512
        time |  -.0260349   .0241189    -1.08   0.290    -.0756121    .0235423
      timesq |   .4997075   .3460414     1.44   0.161    -.2115907    1.211006
          z0 |   .7524749   .3159082     2.38   0.025     .1031163    1.401833
          z1 |   -.912172   .5807959    -1.57   0.128    -2.106015    .2816711
          z2 |   .2210294   .1505169     1.47   0.154    -.0883625    .5304214
          x1 |  -.1613882   .3756296    -0.43   0.671    -.9335059    .6107296
          x2 |  -.0247239   .1679367    -0.15   0.884    -.3699227    .3204749
       _cons |   10.24826   1.511092     6.78   0.000     7.142165    13.35435
------------------------------------------------------------------------------

. 
. *summation of betai's
. lincom 5*z0+10*z1+30*z2

 ( 1)  5*z0 + 10*z1 + 30*z2 = 0

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   1.271538   .2703125     4.70   0.000     .7159023    1.827173
------------------------------------------------------------------------------

. 
. log close
      name:  <unnamed>
       log:  Z:\home\pacha\github\advanced-international-trade\first-edition\Chapt
> er-7\cyship.log
  log type:  text
 closed on:  19 Jun 2024, 13:51:17
----------------------------------------------------------------------------------

. exit

end of do-file

Trucks

clear
capture log close

log using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapter-7\trucks.log, replace

insheet using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapter-7\trucks.csv
drop if time<=12
regress iprice time timesq lag0 lag1 lag2 tariff usprice income

*i=0
lincom lag0

*i=1
lincom lag0+lag1+lag2

*i=2
lincom lag0+2*lag1+4*lag2

*i=3
lincom lag0+3*lag1+9*lag2

*i=4
lincom lag0+4*lag1+16*lag2

*summation of betai's
lincom 5*lag0+10*lag1+30*lag2

*Impose the homogeneity and symmetry constraints
regress y time timesq z0 z1 z2 x1

*summation of betai's
lincom 5*z0+10*z1+30*z2

log close
exit

Output:

. clear

. capture log close

. 
. log using Z:\home\pacha\github\advanced-international-trade\first-edition\Chapte
> r-7\trucks.log, replace
(note: file Z:\home\pacha\github\advanced-international-trade\first-edition\Chapte
> r-7\trucks.log not found)
----------------------------------------------------------------------------------
      name:  <unnamed>
       log:  Z:\home\pacha\github\advanced-international-trade\first-edition\Chapt
> er-7\trucks.log
  log type:  text
 opened on:  19 Jun 2024, 13:52:25

. 
. insheet using Z:\home\pacha\github\advanced-international-trade\first-edition\Ch
> apter-7\trucks.csv
(14 vars, 53 obs)

. drop if time<=12
(12 observations deleted)

. regress iprice time timesq lag0 lag1 lag2 tariff usprice income

      Source |       SS       df       MS              Number of obs =      41
-------------+------------------------------           F(  8,    32) =  468.92
       Model |  2.20983016     8  .276228771           Prob > F      =  0.0000
    Residual |  .018850254    32   .00058907           R-squared     =  0.9915
-------------+------------------------------           Adj R-squared =  0.9894
       Total |  2.22868042    40   .05571701           Root MSE      =  .02427

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        time |   .0352992   .0115245     3.06   0.004     .0118245    .0587738
      timesq |  -.3687581   .0950987    -3.88   0.000    -.5624678   -.1750484
        lag0 |   .2817325   .0563137     5.00   0.000     .1670253    .3964397
        lag1 |  -.1750568    .103425    -1.69   0.100    -.3857266    .0356129
        lag2 |   .0322891   .0269044     1.20   0.239    -.0225134    .0870917
      tariff |   .5702031     .13745     4.15   0.000     .2902267    .8501795
     usprice |   .0294371    .396435     0.07   0.941    -.7780745    .8369488
      income |  -.0321876   .0586085    -0.55   0.587    -.1515693     .087194
       _cons |   8.195509   1.925592     4.26   0.000     4.273206    12.11781
------------------------------------------------------------------------------

. 
. *i=0
. lincom lag0

 ( 1)  lag0 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .2817325   .0563137     5.00   0.000     .1670253    .3964397
------------------------------------------------------------------------------

. 
. *i=1
. lincom lag0+lag1+lag2

 ( 1)  lag0 + lag1 + lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .1389648   .0300367     4.63   0.000      .077782    .2001476
------------------------------------------------------------------------------

. 
. *i=2
. lincom lag0+2*lag1+4*lag2

 ( 1)  lag0 + 2*lag1 + 4*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .0607753   .0495382     1.23   0.229    -.0401306    .1616813
------------------------------------------------------------------------------

. 
. *i=3
. lincom lag0+3*lag1+9*lag2

 ( 1)  lag0 + 3*lag1 + 9*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .0471641   .0279295     1.69   0.101    -.0097265    .1040548
------------------------------------------------------------------------------

. 
. *i=4
. lincom lag0+4*lag1+16*lag2

 ( 1)  lag0 + 4*lag1 + 16*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .0981312   .0787782     1.25   0.222    -.0623347    .2585971
------------------------------------------------------------------------------

. 
. *summation of betai's
. lincom 5*lag0+10*lag1+30*lag2

 ( 1)  5*lag0 + 10*lag1 + 30*lag2 = 0

------------------------------------------------------------------------------
      iprice |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .6267679   .0805593     7.78   0.000      .462674    .7908619
------------------------------------------------------------------------------

. 
. *Impose the homogeneity and symmetry constraints
. regress y time timesq z0 z1 z2 x1

      Source |       SS       df       MS              Number of obs =      41
-------------+------------------------------           F(  6,    34) =  791.27
       Model |  2.71482325     6  .452470541           Prob > F      =  0.0000
    Residual |  .019442165    34  .000571828           R-squared     =  0.9929
-------------+------------------------------           Adj R-squared =  0.9916
       Total |  2.73426541    40  .068356635           Root MSE      =  .02391

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        time |   .0243984   .0032516     7.50   0.000     .0177904    .0310064
      timesq |  -.2899041   .0503788    -5.75   0.000    -.3922861   -.1875221
          z0 |    .284604   .0551443     5.16   0.000     .1725374    .3966706
          z1 |  -.1985585   .0981501    -2.02   0.051    -.3980235    .0009066
          z2 |    .038167   .0254203     1.50   0.142    -.0134932    .0898273
          x1 |   .3967109   .0705105     5.63   0.000     .2534164    .5400055
       _cons |   6.402397   .3544569    18.06   0.000     5.682054     7.12274
------------------------------------------------------------------------------

. 
. *summation of betai's
. lincom 5*z0+10*z1+30*z2

 ( 1)  5*z0 + 10*z1 + 30*z2 = 0

------------------------------------------------------------------------------
           y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         (1) |   .5824464   .0618586     9.42   0.000     .4567346    .7081583
------------------------------------------------------------------------------

. 
. log close
      name:  <unnamed>
       log:  Z:\home\pacha\github\advanced-international-trade\first-edition\Chapt
> er-7\trucks.log
  log type:  text
 closed on:  19 Jun 2024, 13:52:28
----------------------------------------------------------------------------------

. exit

end of do-file

My code

# Packages ----

library(archive)
library(readr)
library(dplyr)
library(broom)

# Extract ----

fzip <- "first-edition/Chapter-7.zip"
dout <- gsub("\\.zip$", "", fzip)

if (!dir.exists(dout)) {
  archive_extract(fzip, dir = dout)
}

# Read and transform ----

fout <- paste0(dout, "/feenstra_93.rds")

if (!file.exists(fout)) {
  feenstra_93 <- list(
    cars = read_csv(paste0(dout, "/cars.csv")),
    cycon = read_csv(paste0(dout, "/cycon.csv")) %>%
      filter(time > 16 & time < 45),
    cypool = read_csv(paste0(dout, "/cypool.csv")),
    cyship = read_csv(paste0(dout, "/cyship.csv")) %>%
      filter(time > 16),
    trucks = read_csv(paste0(dout, "/trucks.csv")) %>%
      filter(time > 12)
  )

  saveRDS(feenstra_93, fout)
} else {
  feenstra_93 <- readRDS(fout)
}

# Models ----

## Cars ----

mod1 <- lm(
  iprice ~ time + timesq + lag0 + lag1 + lag2 + usprice + gprice + income,
  data = feenstra_93$cars
)

mod1_tidy <- tidy(mod1)

# i = 0

mod1_tidy %>%
  filter(term == "lag0")
# A tibble: 1 × 5
  term  estimate std.error statistic  p.value
  <chr>    <dbl>     <dbl>     <dbl>    <dbl>
1 lag0     0.444     0.101      4.39 0.000286
# i = 1
# use the delta method to calculate the standard errors
# define auxiliary variables and functions

mod1_vcov <- vcov(mod1)

mod1_summ <- summary(mod1)

w <- c(1, 1, 1)

std_error <- function(w, X, vars) {
  as.numeric(sqrt(w %*% X[vars, vars] %*% w))
}

p_value <- function(statistic, summary) {
  as.numeric(2 * pt(-abs(statistic), df = summary$df[2]))
}

mod1_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(w = w) %>%
  summarise(
    estimate = sum(estimate * w),
    std.error = std_error(w, mod1_vcov, c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, mod1_summ)
  )
# A tibble: 1 × 4
  estimate std.error statistic     p.value
     <dbl>     <dbl>     <dbl>       <dbl>
1    0.316    0.0417      7.59 0.000000261
# i = 2

w <- c(1, 2, 4)

mod1_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 2, 4)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, mod1_vcov, c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, mod1_summ)
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1    0.166    0.0783      2.12  0.0470
# i = 3

w <- c(1, 3, 9)

mod1_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 3, 9)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, mod1_vcov, c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, mod1_summ)
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1 -0.00794    0.0516    -0.154   0.879
# i = 4

w <- c(1, 4, 16)

mod1_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 4, 16)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, mod1_vcov, c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, mod1_summ)
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1   -0.205    0.0993     -2.06  0.0523
# summation of betai's

w <- c(5, 10, 30)

mod1_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = w) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, mod1_vcov, c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, mod1_summ)
  )
# A tibble: 1 × 4
  estimate std.error statistic     p.value
     <dbl>     <dbl>     <dbl>       <dbl>
1    0.713    0.0974      7.32 0.000000450
## Cycon ----

mod2 <- lm(
  iprice ~ dummy1 + dummy2 + dummy3 + time + timesq + lag0 + lag1 + lag2 +
    tariff + usprice + gprice + income,
  data = feenstra_93$cycon
)

mod2_tidy <- tidy(mod2)

# i = 0

mod2_tidy %>%
  filter(term == "lag0")
# A tibble: 1 × 5
  term  estimate std.error statistic p.value
  <chr>    <dbl>     <dbl>     <dbl>   <dbl>
1 lag0     0.288     0.255      1.13   0.276
# i = 1

w <- c(1, 1, 1)

mod2_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(w = w) %>%
  summarise(
    estimate = sum(estimate * w),
    std.error = std_error(w, vcov(mod2), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod2))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1    0.172    0.0947      1.82  0.0894
# i = 2

w <- c(1, 2, 4)

mod2_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 2, 4)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod2), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod2))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1    0.117     0.145     0.810   0.431
# i = 3

w <- c(1, 3, 9)

mod2_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 3, 9)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod2), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod2))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1    0.124    0.0837      1.48   0.159
# i = 4

w <- c(1, 4, 16)

mod2_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 4, 16)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod2), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod2))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1    0.192     0.230     0.833   0.418
# summation of betai's

w <- c(5, 10, 30)

mod2_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = w) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod2), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod2))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1    0.893     0.359      2.49  0.0252
## Cypool ----

mod3 <- lm(
  iprice ~ dummy1 + dummy2 + dummy3 + time + timesq + lag0 + lag1 + lag2 +
    tariff + usprice + gprice + income,
  data = feenstra_93$cypool
)

mod3_tidy <- tidy(mod3)

# i = 0

mod3_tidy %>%
  filter(term == "lag0")
# A tibble: 1 × 5
  term  estimate std.error statistic p.value
  <chr>    <dbl>     <dbl>     <dbl>   <dbl>
1 lag0     0.447     0.209      2.14  0.0373
# i = 1

w <- c(1, 1, 1)

mod3_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(w = w) %>%
  summarise(
    estimate = sum(estimate * w),
    std.error = std_error(w, vcov(mod3), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod3))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1    0.104    0.0912      1.14   0.261
# i = 2

w <- c(1, 2, 4)

mod3_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 2, 4)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod3), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod3))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1  -0.0313     0.153    -0.204   0.839
# i = 3

w <- c(1, 3, 9)

mod3_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 3, 9)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod3), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod3))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1   0.0422    0.0852     0.496   0.622
# i = 4

w <- c(1, 4, 16)

mod3_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 4, 16)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod3), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod3))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1    0.324     0.221      1.47   0.148
# summation of betai's

w <- c(5, 10, 30)

mod3_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = w) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod3), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod3))
  )
# A tibble: 1 × 4
  estimate std.error statistic  p.value
     <dbl>     <dbl>     <dbl>    <dbl>
1    0.886     0.213      4.16 0.000119
## Cyship ----

mod4 <- lm(
  iprice ~ dummy1 + dummy2 + dummy3 + time + timesq + lag0 + lag1 + lag2 +
    tariff + usprice + gprice + income,
  data = feenstra_93$cyship
)

mod4_tidy <- tidy(mod4)

# i = 0

mod4_tidy %>%
  filter(term == "lag0")
# A tibble: 1 × 5
  term  estimate std.error statistic p.value
  <chr>    <dbl>     <dbl>     <dbl>   <dbl>
1 lag0     0.798     0.665      1.20   0.242
# i = 1

w <- c(1, 1, 1)

mod4_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(w = w) %>%
  summarise(
    estimate = sum(estimate * w),
    std.error = std_error(w, vcov(mod4), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod4))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1  -0.0417     0.260    -0.160   0.874
# i = 2

w <- c(1, 2, 4)

mod4_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 2, 4)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod4), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod4))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1   -0.335     0.523    -0.640   0.528
# i = 3

w <- c(1, 3, 9)

mod4_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 3, 9)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod4), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod4))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1  -0.0829     0.216    -0.384   0.704
# i = 4

w <- c(1, 4, 16)

mod4_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 4, 16)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod4), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod4))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1    0.715     0.758     0.943   0.355
# summation of betai's

w <- c(5, 10, 30)

mod4_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = w) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod4), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod4))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1     1.05     0.522      2.02  0.0549
## Trucks ----

mod5 <- lm(
  iprice ~ time + timesq + lag0 + lag1 + lag2 + tariff + usprice + income,
  data = feenstra_93$trucks
)

mod5_tidy <- tidy(mod5)

# i = 0

mod5_tidy %>%
  filter(term == "lag0")
# A tibble: 1 × 5
  term  estimate std.error statistic   p.value
  <chr>    <dbl>     <dbl>     <dbl>     <dbl>
1 lag0     0.282    0.0563      5.00 0.0000197
# i = 1

w <- c(1, 1, 1)

mod5_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(w = w) %>%
  summarise(
    estimate = sum(estimate * w),
    std.error = std_error(w, vcov(mod5), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod5))
  )
# A tibble: 1 × 4
  estimate std.error statistic   p.value
     <dbl>     <dbl>     <dbl>     <dbl>
1    0.139    0.0300      4.63 0.0000586
# i = 2

w <- c(1, 2, 4)

mod5_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 2, 4)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod5), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod5))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1   0.0608    0.0495      1.23   0.229
# i = 3

w <- c(1, 3, 9)

mod5_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 3, 9)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod5), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod5))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1   0.0472    0.0279      1.69   0.101
# i = 4

w <- c(1, 4, 16)

mod5_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = c(1, 4, 16)) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod5), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod5))
  )
# A tibble: 1 × 4
  estimate std.error statistic p.value
     <dbl>     <dbl>     <dbl>   <dbl>
1   0.0981    0.0788      1.25   0.222
# summation of betai's

w <- c(5, 10, 30)

mod5_tidy %>%
  filter(term %in% c("lag0", "lag1", "lag2")) %>%
  mutate(weight = w) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod5), c("lag0", "lag1", "lag2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod5))
  )
# A tibble: 1 × 4
  estimate std.error statistic       p.value
     <dbl>     <dbl>     <dbl>         <dbl>
1    0.627    0.0806      7.78 0.00000000713

Exercise 2

Then replicate Feenstra’s Table 2 by imposing the tests of homogeneity and symmetry, shown in (7.35a) and (7.35b). Instead of conducting the Wald test, as done in Feenstra (1989), instead conduct the analogous F-test. Do you accept or reject the hypotheses of symmetry and homogeneity?

Feenstra’s code

Included in exercise 1.

My code

## Cars ----

# impose the homogeneity and symmetry constraints

mod1h <- lm(
  y ~ time + timesq + z0 + z1 + z2 + x1 + x2,
  data = feenstra_93$cars
)

mod1h_tidy <- tidy(mod1h)

# summation of betai's

w <- c(5, 10, 30)

mod1h_tidy %>%
  filter(term %in% c("z0", "z1", "z2")) %>%
  mutate(weight = w) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod1h), c("z0", "z1", "z2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod1h))
  )
# A tibble: 1 × 4
  estimate std.error statistic     p.value
     <dbl>     <dbl>     <dbl>       <dbl>
1    0.725    0.0956      7.58 0.000000194
## Cycon ----

# impose the homogeneity and symmetry constraints

mod2h <- lm(
  y ~ dummy1 + dummy2 + dummy3 + time + timesq + z0 + z1 + z2 + x1 + x2,
  data = feenstra_93$cycon
)

mod2h_tidy <- tidy(mod2h)

# summation of betai's

w <- c(5, 10, 30)

mod2h_tidy %>%
  filter(term %in% c("z0", "z1", "z2")) %>%
  mutate(weight = w) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod2h), c("z0", "z1", "z2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod2h))
  )
# A tibble: 1 × 4
  estimate std.error statistic    p.value
     <dbl>     <dbl>     <dbl>      <dbl>
1    0.971     0.145      6.72 0.00000362
## Cypool ----

# impose the homogeneity and symmetry constraints

mod3h <- lm(
  y ~ dummy1 + dummy2 + dummy3 + time + timesq + z0 + z1 + z2 + x1 + x2,
  data = feenstra_93$cypool
)

mod3h_tidy <- tidy(mod3h)

# summation of betai's

w <- c(5, 10, 30)

mod3h_tidy %>%
  filter(term %in% c("z0", "z1", "z2")) %>%
  mutate(weight = w) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod3h), c("z0", "z1", "z2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod3h))
  )
# A tibble: 1 × 4
  estimate std.error statistic       p.value
     <dbl>     <dbl>     <dbl>         <dbl>
1     1.08     0.153      7.03 0.00000000362
## Cyship ----

# impose the homogeneity and symmetry constraints

mod4h <- lm(
  y ~ dummy1 + dummy2 + dummy3 + time + timesq + z0 + z1 + z2 + x1 + x2,
  data = feenstra_93$cyship
)

mod4h_tidy <- tidy(mod4h)

# summation of betai's

w <- c(5, 10, 30)

mod4h_tidy %>%
  filter(term %in% c("z0", "z1", "z2")) %>%
  mutate(weight = w) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod4h), c("z0", "z1", "z2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod4h))
  )
# A tibble: 1 × 4
  estimate std.error statistic   p.value
     <dbl>     <dbl>     <dbl>     <dbl>
1     1.27     0.270      4.70 0.0000734
## Trucks ----

# impose the homogeneity and symmetry constraints

mod5h <- lm(
  y ~ time + timesq + z0 + z1 + z2 + x1,
  data = feenstra_93$trucks
)

mod5h_tidy <- tidy(mod5h)

# summation of betai's

w <- c(5, 10, 30)

mod5h_tidy %>%
  filter(term %in% c("z0", "z1", "z2")) %>%
  mutate(weight = w) %>%
  summarise(
    estimate = sum(estimate * weight),
    std.error = std_error(weight, vcov(mod5h), c("z0", "z1", "z2")),
    statistic = estimate / std.error,
    p.value = p_value(statistic, summary(mod5h))
  )
# A tibble: 1 × 4
  estimate std.error statistic  p.value
     <dbl>     <dbl>     <dbl>    <dbl>
1    0.582    0.0619      9.42 5.33e-11