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.
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 (data.table)
# 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)) {
# fill = TRUE is required because of missing commas in the CSV files
feenstra_93 <- list (
cars = fread (paste0 (dout, "/cars.csv" ), fill = TRUE )[! is.na (time)],
cycon = fread (paste0 (dout, "/cycon.csv" ), fill = TRUE )[! is.na (time) & time > 16 & time < 45 ],
cypool = fread (paste0 (dout, "/cypool.csv" ), fill = TRUE )[! is.na (time)],
cyship = fread (paste0 (dout, "/cyship.csv" ), fill = TRUE )[! is.na (time) & time > 16 ],
trucks = fread (paste0 (dout, "/trucks.csv" ), fill = TRUE )[! is.na (time) & 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_coef <- as.data.table (summary (mod1)$ coefficients, keep.rownames = "term" )
setnames (mod1_coef, c ("term" , "estimate" , "std.error" , "statistic" , "p.value" ))
mod1_vcov <- vcov (mod1)
mod1_summ <- summary (mod1)
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 ]))
}
# i = 0
mod1_coef[term == "lag0" ]
term estimate std.error statistic p.value
<char> <num> <num> <num> <num>
1: lag0 0.4435322 0.1011437 4.385168 0.0002859465
# i = 1
w <- c (1 , 1 , 1 )
lag_est <- coef (mod1)[c ("lag0" , "lag1" , "lag2" )]
estimate <- sum (lag_est * w)
se <- std_error (w, mod1_vcov, c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, mod1_summ))
estimate std.error statistic p.value
3.162427e-01 4.166899e-02 7.589401e+00 2.605144e-07
# i = 2
w <- c (1 , 2 , 4 )
estimate <- sum (lag_est * w)
se <- std_error (w, mod1_vcov, c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, mod1_summ))
estimate std.error statistic p.value
0.16575132 0.07828462 2.11729096 0.04696217
# i = 3
w <- c (1 , 3 , 9 )
estimate <- sum (lag_est * w)
se <- std_error (w, mod1_vcov, c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, mod1_summ))
estimate std.error statistic p.value
-0.007941888 0.051644810 -0.153779014 0.879325077
# i = 4
w <- c (1 , 4 , 16 )
estimate <- sum (lag_est * w)
se <- std_error (w, mod1_vcov, c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, mod1_summ))
estimate std.error statistic p.value
-0.20483695 0.09925713 -2.06370022 0.05226543
# summation of betai's
w <- c (5 , 10 , 30 )
estimate <- sum (lag_est * w)
se <- std_error (w, mod1_vcov, c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, mod1_summ))
estimate std.error statistic p.value
7.127474e-01 9.741615e-02 7.316521e+00 4.501795e-07
## Cycon ----
mod2 <- lm (
iprice ~ dummy1 + dummy2 + dummy3 + time + timesq + lag0 + lag1 + lag2 +
tariff + usprice + gprice + income,
data = feenstra_93$ cycon
)
mod2_coef <- as.data.table (summary (mod2)$ coefficients, keep.rownames = "term" )
setnames (mod2_coef, c ("term" , "estimate" , "std.error" , "statistic" , "p.value" ))
# i = 0
mod2_coef[term == "lag0" ]
term estimate std.error statistic p.value
<char> <num> <num> <num> <num>
1: lag0 0.287991 0.254638 1.130982 0.2758218
# i = 1
w <- c (1 , 1 , 1 )
lag_est <- coef (mod2)[c ("lag0" , "lag1" , "lag2" )]
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod2), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod2)))
estimate std.error statistic p.value
0.17207631 0.09474356 1.81623222 0.08937153
# i = 2
w <- c (1 , 2 , 4 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod2), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod2)))
estimate std.error statistic p.value
0.1174212 0.1450443 0.8095540 0.4308520
# i = 3
w <- c (1 , 3 , 9 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod2), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod2)))
estimate std.error statistic p.value
0.12402561 0.08374317 1.48102359 0.15929915
# i = 4
w <- c (1 , 4 , 16 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod2), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod2)))
estimate std.error statistic p.value
0.1918896 0.2302308 0.8334662 0.4176566
# summation of betai's
w <- c (5 , 10 , 30 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod2), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod2)))
estimate std.error statistic p.value
0.89340370 0.35949734 2.48514690 0.02523436
## Cypool ----
mod3 <- lm (
iprice ~ dummy1 + dummy2 + dummy3 + time + timesq + lag0 + lag1 + lag2 +
tariff + usprice + gprice + income,
data = feenstra_93$ cypool
)
mod3_coef <- as.data.table (summary (mod3)$ coefficients, keep.rownames = "term" )
setnames (mod3_coef, c ("term" , "estimate" , "std.error" , "statistic" , "p.value" ))
# i = 0
mod3_coef[term == "lag0" ]
term estimate std.error statistic p.value
<char> <num> <num> <num> <num>
1: lag0 0.4468806 0.2090703 2.137465 0.03728214
# i = 1
w <- c (1 , 1 , 1 )
lag_est <- coef (mod3)[c ("lag0" , "lag1" , "lag2" )]
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod3), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod3)))
estimate std.error statistic p.value
0.10360821 0.09122104 1.13579284 0.26125106
# i = 2
w <- c (1 , 2 , 4 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod3), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod3)))
estimate std.error statistic p.value
-0.03127621 0.15322748 -0.20411620 0.83905946
# i = 3
w <- c (1 , 3 , 9 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod3), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod3)))
estimate std.error statistic p.value
0.04222730 0.08517266 0.49578471 0.62213529
# i = 4
w <- c (1 , 4 , 16 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod3), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod3)))
estimate std.error statistic p.value
0.3241187 0.2208685 1.4674736 0.1482700
# summation of betai's
w <- c (5 , 10 , 30 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod3), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod3)))
estimate std.error statistic p.value
0.8855585977 0.2128405823 4.1606661098 0.0001193281
## Cyship ----
mod4 <- lm (
iprice ~ dummy1 + dummy2 + dummy3 + time + timesq + lag0 + lag1 + lag2 +
tariff + usprice + gprice + income,
data = feenstra_93$ cyship
)
mod4_coef <- as.data.table (summary (mod4)$ coefficients, keep.rownames = "term" )
setnames (mod4_coef, c ("term" , "estimate" , "std.error" , "statistic" , "p.value" ))
# i = 0
mod4_coef[term == "lag0" ]
term estimate std.error statistic p.value
<char> <num> <num> <num> <num>
1: lag0 0.7976815 0.6650264 1.199474 0.2420521
# i = 1
w <- c (1 , 1 , 1 )
lag_est <- coef (mod4)[c ("lag0" , "lag1" , "lag2" )]
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod4), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod4)))
estimate std.error statistic p.value
-0.0416758 0.2597041 -0.1604742 0.8738506
# i = 2
w <- c (1 , 2 , 4 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod4), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod4)))
estimate std.error statistic p.value
-0.3352056 0.5234520 -0.6403750 0.5279960
# i = 3
w <- c (1 , 3 , 9 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod4), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod4)))
estimate std.error statistic p.value
-0.08290784 0.21581485 -0.38416187 0.70424114
# i = 4
w <- c (1 , 4 , 16 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod4), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod4)))
estimate std.error statistic p.value
0.7152174 0.7584346 0.9430180 0.3550685
# summation of betai's
w <- c (5 , 10 , 30 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod4), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod4)))
estimate std.error statistic p.value
1.05310971 0.52190686 2.01781161 0.05492435
## Trucks ----
mod5 <- lm (
iprice ~ time + timesq + lag0 + lag1 + lag2 + tariff + usprice + income,
data = feenstra_93$ trucks
)
mod5_coef <- as.data.table (summary (mod5)$ coefficients, keep.rownames = "term" )
setnames (mod5_coef, c ("term" , "estimate" , "std.error" , "statistic" , "p.value" ))
# i = 0
mod5_coef[term == "lag0" ]
term estimate std.error statistic p.value
<char> <num> <num> <num> <num>
1: lag0 0.2817314 0.05631354 5.002907 1.970452e-05
# i = 1
w <- c (1 , 1 , 1 )
lag_est <- coef (mod5)[c ("lag0" , "lag1" , "lag2" )]
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod5), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod5)))
estimate std.error statistic p.value
0.1389647853 0.0300366567 4.6265064296 0.0000586432
# i = 2
w <- c (1 , 2 , 4 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod5), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod5)))
estimate std.error statistic p.value
0.06077573 0.04953807 1.22684902 0.22882972
# i = 3
w <- c (1 , 3 , 9 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod5), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod5)))
estimate std.error statistic p.value
0.04716422 0.02792952 1.68868740 0.10100264
# i = 4
w <- c (1 , 4 , 16 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod5), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod5)))
estimate std.error statistic p.value
0.09813027 0.07877802 1.24565543 0.22193467
# summation of betai's
w <- c (5 , 10 , 30 )
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod5), c ("lag0" , "lag1" , "lag2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod5)))
estimate std.error statistic p.value
6.267664e-01 8.055932e-02 7.780185e+00 7.134880e-09
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
)
# summation of betai's
w <- c (5 , 10 , 30 )
lag_est <- coef (mod1h)[c ("z0" , "z1" , "z2" )]
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod1h), c ("z0" , "z1" , "z2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod1h)))
estimate std.error statistic p.value
7.246473e-01 9.563029e-02 7.577592e+00 1.943114e-07
## Cycon ----
# impose the homogeneity and symmetry constraints
mod2h <- lm (
y ~ dummy1 + dummy2 + dummy3 + time + timesq + z0 + z1 + z2 + x1 + x2,
data = feenstra_93$ cycon
)
# summation of betai's
w <- c (5 , 10 , 30 )
lag_est <- coef (mod2h)[c ("z0" , "z1" , "z2" )]
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod2h), c ("z0" , "z1" , "z2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod2h)))
estimate std.error statistic p.value
9.709568e-01 1.445614e-01 6.716570e+00 3.616733e-06
## Cypool ----
# impose the homogeneity and symmetry constraints
mod3h <- lm (
y ~ dummy1 + dummy2 + dummy3 + time + timesq + z0 + z1 + z2 + x1 + x2,
data = feenstra_93$ cypool
)
# summation of betai's
w <- c (5 , 10 , 30 )
lag_est <- coef (mod3h)[c ("z0" , "z1" , "z2" )]
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod3h), c ("z0" , "z1" , "z2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod3h)))
estimate std.error statistic p.value
1.075070e+00 1.528332e-01 7.034269e+00 3.624482e-09
## Cyship ----
# impose the homogeneity and symmetry constraints
mod4h <- lm (
y ~ dummy1 + dummy2 + dummy3 + time + timesq + z0 + z1 + z2 + x1 + x2,
data = feenstra_93$ cyship
)
# summation of betai's
w <- c (5 , 10 , 30 )
lag_est <- coef (mod4h)[c ("z0" , "z1" , "z2" )]
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod4h), c ("z0" , "z1" , "z2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod4h)))
estimate std.error statistic p.value
1.2715325412 0.2703109468 4.7039624417 0.0000734274
## Trucks ----
# impose the homogeneity and symmetry constraints
mod5h <- lm (
y ~ time + timesq + z0 + z1 + z2 + x1,
data = feenstra_93$ trucks
)
# summation of betai's
w <- c (5 , 10 , 30 )
lag_est <- coef (mod5h)[c ("z0" , "z1" , "z2" )]
estimate <- sum (lag_est * w)
se <- std_error (w, vcov (mod5h), c ("z0" , "z1" , "z2" ))
stat <- estimate / se
c (estimate = estimate, std.error = se, statistic = stat, p.value = p_value (stat, summary (mod5h)))
estimate std.error statistic p.value
5.824437e-01 6.185913e-02 9.415647e+00 5.327349e-11