GOAL: To plot a semi-elasticity at different levels of another variable based on a regression with multiple fixed effects.
PROBLEM: margins does not calculate the semi-elasticities.
I. Preliminaries
I am estimating the following extended gravity equation for one year:
\[ \log{\left(\text{Trade}_{ijp} \right)} = \exp{\Bigg\{ \delta_{ik} + \delta_{jk} + \delta_{ij} + \beta_D \Big[ \log{ \left( \text{Dist}_{ij} \right) } \times \text{RS}_p \Big] + \beta_C \Big[ \mu_i \times \text{RS}_p \Big] + \beta_{CD} \Big[ \mu_i \times \log{ \left( \text{Dist}_{ij} \right) } \times \text{RS}_p \Big] \Bigg\}} \eta_{ij} \]
where:
II. Problem with margins
I want to calculate the semi-elasticity of trade with respect to a marginal increase in the proxy for institutional quality (lower case mu) for different values of log distance. First, I saved the main percentiles of log distance in memory:
In my first attempt, I wrote:
Comments:
- Since I am interested in the semi-elasticity, I use eydx.
- Since the variable mu is continuous, I add the option continuous
Although I did not get an error message, most estimates are "not estimable":
Based on the discussion in this post, I tried to fix this by adding noestimcheck as an option:
Unfortunately, this made things worse and now I get the following error message:
Could anybody help me understand what am I missing? I am using Stata 18 (SE) on Windows 11.
Thanks!
Luis
PROBLEM: margins does not calculate the semi-elasticities.
I. Preliminaries
I am estimating the following extended gravity equation for one year:
\[ \log{\left(\text{Trade}_{ijp} \right)} = \exp{\Bigg\{ \delta_{ik} + \delta_{jk} + \delta_{ij} + \beta_D \Big[ \log{ \left( \text{Dist}_{ij} \right) } \times \text{RS}_p \Big] + \beta_C \Big[ \mu_i \times \text{RS}_p \Big] + \beta_{CD} \Big[ \mu_i \times \log{ \left( \text{Dist}_{ij} \right) } \times \text{RS}_p \Big] \Bigg\}} \eta_{ij} \]
where:
- i and j index the exporter and importer, respectively;
- p and k index products and industries, respectively (industries may produce many products, but each product belongs to only one industry);
- The lowercase deltas represent fixed effects (exporter-industry, importer-industry and country-pair);
- RS is a binary variable indicating if the good is "specific"; and
- The lower case mu represents a proxy for the "quality" of contract enforcement institutions, normalized to take values from 0 (worse) to 1 (best).
- The error term (lower case eta) is assumed independent from the regressors with conditional expected value 1.
Code:
ppmlhdfe value 1.RS##c.mu##c.ldist, a(ctry_x#sector ctry_m#sector ctry_x#ctry_m) vce(cluster ctry_x#ctry_m) d
I want to calculate the semi-elasticity of trade with respect to a marginal increase in the proxy for institutional quality (lower case mu) for different values of log distance. First, I saved the main percentiles of log distance in memory:
Code:
summarize ldist, detail local mean = `r(mean)'
Code:
margins, eydx(mu) at(ldist== (`r(p1)' `r(p5)' `r(p10)' `r(p25)' `r(mean)' `r(p50)' `r(p75)' `r(p90)' `r(p95)' `r(p99)') RS == 1) continuous
- Since I am interested in the semi-elasticity, I use eydx.
- Since the variable mu is continuous, I add the option continuous
Although I did not get an error message, most estimates are "not estimable":
Code:
------------------------------------------------------------------------------ | Delta-method | ey/dx std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- mu | _at | 1 | . (not estimable) 2 | . (not estimable) 3 | . (not estimable) 4 | . (not estimable) 5 | . (not estimable) 6 | . (not estimable) 7 | . (not estimable) 8 | . (not estimable) 9 | . (not estimable) 10 | . (not estimable) ------------------------------------------------------------------------------
Code:
margins, eydx(mu) at(ldist== (`r(p1)' `r(p5)' `r(p10)' `r(p25)' `r(mean)' `r(p50)' `r(p75)' `r(p90)' `r(p95)' `r(p99)') RS == 1) continuous noestimcheck
Code:
could not calculate numerical derivatives -- discontinuous region with missing values encountered
Thanks!
Luis
Comment