*This dofile estimates AD Probits on 5-6 digit NAICS data for AER revision. #delimit ; clear; set mem 700m; set more off; * set path; * (this is the only time that the absolute path is set in this code); cd "C:\mypath" ; log using Estimation-Table-3-05-01-2012, replace; /* ***************************************************************************** */ /* ** Table 3: Specification (1): Baseline model, substitute level change in import penetration or import growth variable ** */ /* ***************************************************************************** */ clear; use "SETA_estim_final_05-01-2012.dta"; /* RESCALE VARIABLES */ replace gr_imp_L1=gr_imp_L1/10000; replace sd_imp_gr= sd_imp_gr/100; replace ln_inv_es_id_elast_sum= ln_inv_es_id_elast_sum/1000; replace chg_rxr_L1= chg_rxr_L1/1000; replace D_cnty_i_mkt_sh_L1= D_cnty_i_mkt_sh_L1/100; *Generate the interacted continuous variables; gen MDXS_imp= ln_inv_es_id_elast_sum*D_cnty_i_mkt_sh_L1; gen MDXS_imp_old= ln_inv_es_id_elast_sum*gr_imp_L1; *FIRST RUN MODEL ON TABLE 2 SAMPLE OF DATA TO GET THE SAME OBSERVATIONS INTO MEMORY; dprobit AD_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp_old chg_rxr_L1, robust; keep if e(sample)==1; *As a dprobit; dprobit AD_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1, robust; mfx compute; *As a probit, with interaction; probit AD_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1, robust; keep if e(sample)==1; sum AD_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1; *Calculate marginal effects; *To verify code, start by recreating dprobit coefficients; predict x_beta1, xb; egen av_xbeta1=mean(x_beta1); scalar phi1=normalden(av_xbeta1); scalar list phi1; matrix marg=phi1*e(b); matrix list marg; *Next, calculate the interaction terms we’re interested in; egen av_imp_gr=mean(D_cnty_i_mkt_sh_L1); egen av_elast=mean(ln_inv_es_id_elast_sum); gen me_imports= (_b[D_cnty_i_mkt_sh_L1]+_b[MDXS_imp]*av_elast)*phi1; gen me_elast= (_b[ln_inv_es_id_elast_sum]+_b[MDXS_imp]*av_imp_gr)*phi1; /* ***************************************************************************** */ /* THESE ARE THE MARGINAL EFFECTS ESTIMATES INCLUDING THE DIRECT AND INDIRECT EFFECTS FOR THE VARIABLES OF INTEREST */ sum me_imports; sum me_elast; *Calculate std errors of marginal effects; *To verify code, start by recreating dprobit coefficients; *Note that when working with the probit command, “robust,” the vce matrix is robust and the associated std errors are the “robust” std errors from dprobit; *define the VCE matrix; matrix varcov=e(V); matrix list varcov; *extract the diagonal of the vce matrix; matrix vc_row=vecdiag(varcov); *construct a new matrix with zeros on the off-diagonal; matrix vc_diag=diag(vc_row); *take the square root of the diagonal elements; matrix std_err=cholesky(vc_diag); *scale up to marginal effects; matrix std_err_marg=phi1*std_err; matrix std_err_scaled=vecdiag(std_err_marg); matrix list std_err_scaled; matrix list varcov; gen var_me_imp =varcov[1,1]+(varcov[4,4]*(av_elast^2)) +2*av_elast*varcov[1,4]; gen sqrt_var_imp=var_me_imp^(.5); gen std_err_me_imp=sqrt_var_imp*phi1; gen var_me_elast=varcov[3,3] +(varcov[4,4]*(av_imp_gr^2))+2*av_imp_gr*varcov[3,4]; gen sqrt_var_elast=var_me_elast^(.5); gen std_err_me_elast=sqrt_var_elast*phi1; /* ***************************************************************************** */ /* THESE ARE THE STANDARD ERRORS OF THE MARGINAL EFFECTS ESTIMATES INCLUDING THE DIRECT AND INDIRECT EFFECTS FOR THE VARIABLES OF INTEREST */ sum std_err_me_imp; sum std_err_me_elast; ************************************************************************************************; *PREDICTION: quantify the effect on the prob of a one std dev shock for interaction terms; ************************************************************************************************; *Calculate the predicted value at the mean of the dataset; predict x_beta_1; sum x_beta_1; *Generate local variables equal to the mean and std dev of D_cnty_i_mkt_sh_L1; egen D_cnty_i_mkt_sh_L1_mean= mean(D_cnty_i_mkt_sh_L1); egen D_cnty_i_mkt_sh_L1_sd=sd(D_cnty_i_mkt_sh_L1); gen D_cnty_i_mkt_sh_L1_saved=D_cnty_i_mkt_sh_L1; replace D_cnty_i_mkt_sh_L1= D_cnty_i_mkt_sh_L1_mean + D_cnty_i_mkt_sh_L1_sd; *Generate local variables equal to the mean and std dev of the elasticities; egen ln_inv_es_id_elast_sum_mean= mean(ln_inv_es_id_elast_sum); egen ln_inv_es_id_elast_sum_sd=sd(ln_inv_es_id_elast_sum); *Part 1: Consider the effect on the probability of a one std deviation shock to import growth; predict x_beta_2; sum x_beta_2; gen MDXS_imp_saved=MDXS_imp; replace MDXS_imp= ln_inv_es_id_elast_sum*(D_cnty_i_mkt_sh_L1_mean+D_cnty_i_mkt_sh_L1_sd); /* ***************************************************************************** */ /* THIS (x_beta_3) IS THE FULL INTERRACTED EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO IMP GROWTH */ predict x_beta_3; sum x_beta_3; *Part 2: Consider the effect of a one standard deviation shock to the elasticity measure; *First, change those values back to the means; replace D_cnty_i_mkt_sh_L1=D_cnty_i_mkt_sh_L1_saved; replace MDXS_imp=MDXS_imp_saved; /* ***************************************************************************** */ *Check that this (x_beta_4) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_4; sum x_beta_4; replace ln_inv_es_id_elast_sum= ln_inv_es_id_elast_sum_mean + ln_inv_es_id_elast_sum_sd; predict x_beta_5; sum x_beta_5; replace MDXS_imp= D_cnty_i_mkt_sh_L1*(ln_inv_es_id_elast_sum_mean+ln_inv_es_id_elast_sum_sd); /* ***************************************************************************** */ /* THIS (x_beta_6) IS THE FULL INTERRACTED EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE ELASTICITY MEASURE */ predict x_beta_6; sum x_beta_6; /* ***************************************************************************** */ /* ** Table 3: Specification (2): Top 10 import sources only ** */ /* ***************************************************************************** */ clear; use "SETA_estim_final_05-01-2012.dta"; keep if country=="Canada" | country=="Japan" | country=="Mexico" | country=="China" | country=="Germany" | country=="Taiwan" | country=="United Kingdom" | country=="South Korea" | country=="France" | country=="Italy" | country=="Malaysia" ; /* RESCALE VARIABLES */ replace gr_imp_L1=gr_imp_L1/10000; replace sd_imp_gr= sd_imp_gr/100; replace ln_inv_es_id_elast_sum= ln_inv_es_id_elast_sum/1000; replace chg_rxr_L1= chg_rxr_L1/1000; replace D_cnty_i_mkt_sh_L1= D_cnty_i_mkt_sh_L1/100; *Generate the interacted continuous variables; gen MDXS_imp= ln_inv_es_id_elast_sum*D_cnty_i_mkt_sh_L1; gen MDXS_imp_old= ln_inv_es_id_elast_sum*gr_imp_L1; *FIRST RUN MODEL ON TABLE 2 SAMPLE OF DATA TO GET THE SAME OBSERVATIONS INTO MEMORY; dprobit AD_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp_old chg_rxr_L1, robust; keep if e(sample)==1; *As a dprobit; dprobit AD_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1, robust; mfx compute; *As a probit, with interaction; probit AD_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1, robust; keep if e(sample)==1; sum AD_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1; *Calculate marginal effects; *To verify code, start by recreating dprobit coefficients; predict x_beta1, xb; egen av_xbeta1=mean(x_beta1); scalar phi1=normalden(av_xbeta1); scalar list phi1; matrix marg=phi1*e(b); matrix list marg; *Next, calculate the interaction terms we’re interested in; egen av_imp_gr=mean(D_cnty_i_mkt_sh_L1); egen av_elast=mean(ln_inv_es_id_elast_sum); gen me_imports= (_b[D_cnty_i_mkt_sh_L1]+_b[MDXS_imp]*av_elast)*phi1; gen me_elast= (_b[ln_inv_es_id_elast_sum]+_b[MDXS_imp]*av_imp_gr)*phi1; /* ***************************************************************************** */ /* THESE ARE THE MARGINAL EFFECTS ESTIMATES INCLUDING THE DIRECT AND INDIRECT EFFECTS FOR THE VARIABLES OF INTEREST */ sum me_imports; sum me_elast; *Calculate std errors of marginal effects; *To verify code, start by recreating dprobit coefficients; *Note that when working with the probit command, “robust,” the vce matrix is robust and the associated std errors are the “robust” std errors from dprobit; *define the VCE matrix; matrix varcov=e(V); matrix list varcov; *extract the diagonal of the vce matrix; matrix vc_row=vecdiag(varcov); *construct a new matrix with zeros on the off-diagonal; matrix vc_diag=diag(vc_row); *take the square root of the diagonal elements; matrix std_err=cholesky(vc_diag); *scale up to marginal effects; matrix std_err_marg=phi1*std_err; matrix std_err_scaled=vecdiag(std_err_marg); matrix list std_err_scaled; matrix list varcov; gen var_me_imp =varcov[1,1]+(varcov[4,4]*(av_elast^2)) +2*av_elast*varcov[1,4]; gen sqrt_var_imp=var_me_imp^(.5); gen std_err_me_imp=sqrt_var_imp*phi1; gen var_me_elast=varcov[3,3] +(varcov[4,4]*(av_imp_gr^2))+2*av_imp_gr*varcov[3,4]; gen sqrt_var_elast=var_me_elast^(.5); gen std_err_me_elast=sqrt_var_elast*phi1; /* ***************************************************************************** */ /* THESE ARE THE STANDARD ERRORS OF THE MARGINAL EFFECTS ESTIMATES INCLUDING THE DIRECT AND INDIRECT EFFECTS FOR THE VARIABLES OF INTEREST */ sum std_err_me_imp; sum std_err_me_elast; ************************************************************************************************; *PREDICTION: quantify the effect on the prob of a one std dev shock for interaction terms; ************************************************************************************************; *Calculate the predicted value at the mean of the dataset; predict x_beta_1; sum x_beta_1; *Generate local variables equal to the mean and std dev of D_cnty_i_mkt_sh_L1; egen D_cnty_i_mkt_sh_L1_mean= mean(D_cnty_i_mkt_sh_L1); egen D_cnty_i_mkt_sh_L1_sd=sd(D_cnty_i_mkt_sh_L1); gen D_cnty_i_mkt_sh_L1_saved=D_cnty_i_mkt_sh_L1; replace D_cnty_i_mkt_sh_L1= D_cnty_i_mkt_sh_L1_mean + D_cnty_i_mkt_sh_L1_sd; *Generate local variables equal to the mean and std dev of the elasticities; egen ln_inv_es_id_elast_sum_mean= mean(ln_inv_es_id_elast_sum); egen ln_inv_es_id_elast_sum_sd=sd(ln_inv_es_id_elast_sum); *Part 1: Consider the effect on the probability of a one std deviation shock to import growth; predict x_beta_2; sum x_beta_2; gen MDXS_imp_saved=MDXS_imp; replace MDXS_imp= ln_inv_es_id_elast_sum*(D_cnty_i_mkt_sh_L1_mean+D_cnty_i_mkt_sh_L1_sd); /* ***************************************************************************** */ /* THIS (x_beta_3) IS THE FULL INTERRACTED EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO IMP GROWTH */ predict x_beta_3; sum x_beta_3; *Part 2: Consider the effect of a one standard deviation shock to the elasticity measure; *First, change those values back to the means; replace D_cnty_i_mkt_sh_L1=D_cnty_i_mkt_sh_L1_saved; replace MDXS_imp=MDXS_imp_saved; /* ***************************************************************************** */ *Check that this (x_beta_4) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_4; sum x_beta_4; replace ln_inv_es_id_elast_sum= ln_inv_es_id_elast_sum_mean + ln_inv_es_id_elast_sum_sd; predict x_beta_5; sum x_beta_5; replace MDXS_imp= D_cnty_i_mkt_sh_L1*(ln_inv_es_id_elast_sum_mean+ln_inv_es_id_elast_sum_sd); /* ***************************************************************************** */ /* THIS (x_beta_6) IS THE FULL INTERRACTED EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE ELASTICITY MEASURE */ predict x_beta_6; sum x_beta_6; /* ***************************************************************************** */ /* ** Table 3: Specification (3): AD+SG, Top 10 import sources only, Back to Probit ** */ /* ***************************************************************************** */ #delimit; clear; use "SETA_estim_final_05-01-2012.dta"; keep if country=="Canada" | country=="Japan" | country=="Mexico" | country=="China" | country=="Germany" | country=="Taiwan" | country=="United Kingdom" | country=="South Korea" | country=="France" | country=="Italy" | country=="Malaysia" ; /* RESCALE VARIABLES */ replace gr_imp_L1=gr_imp_L1/10000; replace sd_imp_gr= sd_imp_gr/100; replace ln_inv_es_id_elast_sum= ln_inv_es_id_elast_sum/1000; replace chg_rxr_L1= chg_rxr_L1/1000; replace D_cnty_i_mkt_sh_L1= D_cnty_i_mkt_sh_L1/100; *Generate the interacted continuous variables; gen MDXS_imp= ln_inv_es_id_elast_sum*D_cnty_i_mkt_sh_L1; gen MDXS_imp_old= ln_inv_es_id_elast_sum*gr_imp_L1; *FIRST RUN MODEL ON TABLE 2 SAMPLE OF DATA TO GET THE SAME OBSERVATIONS INTO MEMORY; dprobit AD_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp_old chg_rxr_L1, robust; keep if e(sample)==1; *As a dprobit; dprobit AD_or_SG_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1, robust; mfx compute; *As a probit, with interaction; probit AD_or_SG_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1, robust; keep if e(sample)==1; sum AD_or_SG_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1; *Calculate marginal effects; *To verify code, start by recreating dprobit coefficients; predict x_beta1, xb; egen av_xbeta1=mean(x_beta1); scalar phi1=normalden(av_xbeta1); scalar list phi1; matrix marg=phi1*e(b); matrix list marg; *Next, calculate the interaction terms we’re interested in; egen av_imp_gr=mean(D_cnty_i_mkt_sh_L1); egen av_elast=mean(ln_inv_es_id_elast_sum); gen me_imports= (_b[D_cnty_i_mkt_sh_L1]+_b[MDXS_imp]*av_elast)*phi1; gen me_elast= (_b[ln_inv_es_id_elast_sum]+_b[MDXS_imp]*av_imp_gr)*phi1; /* ***************************************************************************** */ /* THESE ARE THE MARGINAL EFFECTS ESTIMATES INCLUDING THE DIRECT AND INDIRECT EFFECTS FOR THE VARIABLES OF INTEREST */ sum me_imports; sum me_elast; *Calculate std errors of marginal effects; *To verify code, start by recreating dprobit coefficients; *Note that when working with the probit command, “robust,” the vce matrix is robust and the associated std errors are the “robust” std errors from dprobit; *define the VCE matrix; matrix varcov=e(V); matrix list varcov; *extract the diagonal of the vce matrix; matrix vc_row=vecdiag(varcov); *construct a new matrix with zeros on the off-diagonal; matrix vc_diag=diag(vc_row); *take the square root of the diagonal elements; matrix std_err=cholesky(vc_diag); *scale up to marginal effects; matrix std_err_marg=phi1*std_err; matrix std_err_scaled=vecdiag(std_err_marg); matrix list std_err_scaled; matrix list varcov; gen var_me_imp =varcov[1,1]+(varcov[4,4]*(av_elast^2)) +2*av_elast*varcov[1,4]; gen sqrt_var_imp=var_me_imp^(.5); gen std_err_me_imp=sqrt_var_imp*phi1; gen var_me_elast=varcov[3,3] +(varcov[4,4]*(av_imp_gr^2))+2*av_imp_gr*varcov[3,4]; gen sqrt_var_elast=var_me_elast^(.5); gen std_err_me_elast=sqrt_var_elast*phi1; /* ***************************************************************************** */ /* THESE ARE THE STANDARD ERRORS OF THE MARGINAL EFFECTS ESTIMATES INCLUDING THE DIRECT AND INDIRECT EFFECTS FOR THE VARIABLES OF INTEREST */ sum std_err_me_imp; sum std_err_me_elast; ************************************************************************************************; *PREDICTION: quantify the effect on the prob of a one std dev shock for interaction terms; ************************************************************************************************; *Calculate the predicted value at the mean of the dataset; predict x_beta_1; sum x_beta_1; *Generate local variables equal to the mean and std dev of D_cnty_i_mkt_sh_L1; egen D_cnty_i_mkt_sh_L1_mean= mean(D_cnty_i_mkt_sh_L1); egen D_cnty_i_mkt_sh_L1_sd=sd(D_cnty_i_mkt_sh_L1); gen D_cnty_i_mkt_sh_L1_saved=D_cnty_i_mkt_sh_L1; replace D_cnty_i_mkt_sh_L1= D_cnty_i_mkt_sh_L1_mean + D_cnty_i_mkt_sh_L1_sd; *Generate local variables equal to the mean and std dev of the elasticities; egen ln_inv_es_id_elast_sum_mean= mean(ln_inv_es_id_elast_sum); egen ln_inv_es_id_elast_sum_sd=sd(ln_inv_es_id_elast_sum); *Part 1: Consider the effect on the probability of a one std deviation shock to import growth; predict x_beta_2; sum x_beta_2; gen MDXS_imp_saved=MDXS_imp; replace MDXS_imp= ln_inv_es_id_elast_sum*(D_cnty_i_mkt_sh_L1_mean+D_cnty_i_mkt_sh_L1_sd); /* ***************************************************************************** */ /* THIS (x_beta_3) IS THE FULL INTERRACTED EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO IMP GROWTH */ predict x_beta_3; sum x_beta_3; *Part 2: Consider the effect of a one standard deviation shock to the elasticity measure; *First, change those values back to the means; replace D_cnty_i_mkt_sh_L1=D_cnty_i_mkt_sh_L1_saved; replace MDXS_imp=MDXS_imp_saved; /* ***************************************************************************** */ *Check that this (x_beta_4) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_4; sum x_beta_4; replace ln_inv_es_id_elast_sum= ln_inv_es_id_elast_sum_mean + ln_inv_es_id_elast_sum_sd; predict x_beta_5; sum x_beta_5; replace MDXS_imp= D_cnty_i_mkt_sh_L1*(ln_inv_es_id_elast_sum_mean+ln_inv_es_id_elast_sum_sd); /* ***************************************************************************** */ /* THIS (x_beta_6) IS THE FULL INTERRACTED EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE ELASTICITY MEASURE */ predict x_beta_6; sum x_beta_6; /* ***************************************************************************** */ /* ** Table 3: Specification (4): China only, AD+SG ** */ /* ***************************************************************************** */ #delimit; clear; use "SETA_estim_final_05-01-2012.dta"; keep if country=="China" ; /* RESCALE VARIABLES */ replace gr_imp_L1=gr_imp_L1/10000; replace sd_imp_gr= sd_imp_gr/100; replace ln_inv_es_id_elast_sum= ln_inv_es_id_elast_sum/1000; replace chg_rxr_L1= chg_rxr_L1/1000; replace D_cnty_i_mkt_sh_L1= D_cnty_i_mkt_sh_L1/100; *Generate the interacted continuous variables; gen MDXS_imp= ln_inv_es_id_elast_sum*D_cnty_i_mkt_sh_L1; gen MDXS_imp_old= ln_inv_es_id_elast_sum*gr_imp_L1; *FIRST RUN MODEL ON TABLE 2 SAMPLE OF DATA TO GET THE SAME OBSERVATIONS INTO MEMORY; dprobit AD_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp_old chg_rxr_L1, robust; keep if e(sample)==1; *As a dprobit; dprobit AD_or_SG_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1, robust; mfx compute; *As a probit, with interaction; probit AD_or_SG_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1, robust; keep if e(sample)==1; sum AD_or_SG_imposed D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1; *Calculate marginal effects; *To verify code, start by recreating dprobit coefficients; predict x_beta1, xb; egen av_xbeta1=mean(x_beta1); scalar phi1=normalden(av_xbeta1); scalar list phi1; matrix marg=phi1*e(b); matrix list marg; *Next, calculate the interaction terms we’re interested in; egen av_imp_gr=mean(D_cnty_i_mkt_sh_L1); egen av_elast=mean(ln_inv_es_id_elast_sum); gen me_imports= (_b[D_cnty_i_mkt_sh_L1]+_b[MDXS_imp]*av_elast)*phi1; gen me_elast= (_b[ln_inv_es_id_elast_sum]+_b[MDXS_imp]*av_imp_gr)*phi1; /* ***************************************************************************** */ /* THESE ARE THE MARGINAL EFFECTS ESTIMATES INCLUDING THE DIRECT AND INDIRECT EFFECTS FOR THE VARIABLES OF INTEREST */ sum me_imports; sum me_elast; *Calculate std errors of marginal effects; *To verify code, start by recreating dprobit coefficients; *Note that when working with the probit command, “robust,” the vce matrix is robust and the associated std errors are the “robust” std errors from dprobit; *define the VCE matrix; matrix varcov=e(V); matrix list varcov; *extract the diagonal of the vce matrix; matrix vc_row=vecdiag(varcov); *construct a new matrix with zeros on the off-diagonal; matrix vc_diag=diag(vc_row); *take the square root of the diagonal elements; matrix std_err=cholesky(vc_diag); *scale up to marginal effects; matrix std_err_marg=phi1*std_err; matrix std_err_scaled=vecdiag(std_err_marg); matrix list std_err_scaled; matrix list varcov; gen var_me_imp =varcov[1,1]+(varcov[4,4]*(av_elast^2)) +2*av_elast*varcov[1,4]; gen sqrt_var_imp=var_me_imp^(.5); gen std_err_me_imp=sqrt_var_imp*phi1; gen var_me_elast=varcov[3,3] +(varcov[4,4]*(av_imp_gr^2))+2*av_imp_gr*varcov[3,4]; gen sqrt_var_elast=var_me_elast^(.5); gen std_err_me_elast=sqrt_var_elast*phi1; /* ***************************************************************************** */ /* THESE ARE THE STANDARD ERRORS OF THE MARGINAL EFFECTS ESTIMATES INCLUDING THE DIRECT AND INDIRECT EFFECTS FOR THE VARIABLES OF INTEREST */ sum std_err_me_imp; sum std_err_me_elast; ************************************************************************************************; *PREDICTION: quantify the effect on the prob of a one std dev shock for interaction terms; ************************************************************************************************; *Calculate the predicted value at the mean of the dataset; predict x_beta_1; sum x_beta_1; *Generate local variables equal to the mean and std dev of D_cnty_i_mkt_sh_L1; egen D_cnty_i_mkt_sh_L1_mean= mean(D_cnty_i_mkt_sh_L1); egen D_cnty_i_mkt_sh_L1_sd=sd(D_cnty_i_mkt_sh_L1); gen D_cnty_i_mkt_sh_L1_saved=D_cnty_i_mkt_sh_L1; replace D_cnty_i_mkt_sh_L1= D_cnty_i_mkt_sh_L1_mean + D_cnty_i_mkt_sh_L1_sd; *Generate local variables equal to the mean and std dev of the elasticities; egen ln_inv_es_id_elast_sum_mean= mean(ln_inv_es_id_elast_sum); egen ln_inv_es_id_elast_sum_sd=sd(ln_inv_es_id_elast_sum); *Part 1: Consider the effect on the probability of a one std deviation shock to import growth; predict x_beta_2; sum x_beta_2; gen MDXS_imp_saved=MDXS_imp; replace MDXS_imp= ln_inv_es_id_elast_sum*(D_cnty_i_mkt_sh_L1_mean+D_cnty_i_mkt_sh_L1_sd); /* ***************************************************************************** */ /* THIS (x_beta_3) IS THE FULL INTERRACTED EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO IMP GROWTH */ predict x_beta_3; sum x_beta_3; *Part 2: Consider the effect of a one standard deviation shock to the elasticity measure; *First, change those values back to the means; replace D_cnty_i_mkt_sh_L1=D_cnty_i_mkt_sh_L1_saved; replace MDXS_imp=MDXS_imp_saved; /* ***************************************************************************** */ *Check that this (x_beta_4) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_4; sum x_beta_4; replace ln_inv_es_id_elast_sum= ln_inv_es_id_elast_sum_mean + ln_inv_es_id_elast_sum_sd; predict x_beta_5; sum x_beta_5; replace MDXS_imp= D_cnty_i_mkt_sh_L1*(ln_inv_es_id_elast_sum_mean+ln_inv_es_id_elast_sum_sd); /* ***************************************************************************** */ /* THIS (x_beta_6) IS THE FULL INTERACTED EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE ELASTICITY MEASURE */ predict x_beta_6; sum x_beta_6; /* ***************************************************************************** */ /* ** Table 3: Specification (5): Tobit with AD Tariffs on LHS, Top 10 import sources only ** */ /* ***************************************************************************** */ clear; use "SETA_estim_final_05-01-2012.dta"; keep if country=="Canada" | country=="Japan" | country=="Mexico" | country=="China" | country=="Germany" | country=="Taiwan" | country=="United Kingdom" | country=="South Korea" | country=="France" | country=="Italy" | country=="Malaysia" ; /* RESCALE VARIABLES */ replace gr_imp_L1=gr_imp_L1/10000; replace sd_imp_gr= sd_imp_gr/100; replace ln_inv_es_id_elast_sum= ln_inv_es_id_elast_sum/1000; replace chg_rxr_L1= chg_rxr_L1/1000; replace D_cnty_i_mkt_sh_L1= D_cnty_i_mkt_sh_L1/100; *Generate the interacted continuous variables; gen MDXS_imp= ln_inv_es_id_elast_sum*D_cnty_i_mkt_sh_L1; gen MDXS_imp_old= ln_inv_es_id_elast_sum*gr_imp_L1; *FIRST RUN MODEL ON TABLE 2 SAMPLE OF DATA TO GET THE SAME OBSERVATIONS INTO MEMORY; dprobit AD_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp_old chg_rxr_L1, robust; keep if e(sample)==1; *Generate duty variable; gen ln_ad_duty=ln(1+(AD_DUTY/100)); replace ln_ad_duty=0 if ln_duty==.; tobit ln_ad_duty D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1, ll(0) robust; mfx compute; keep if e(sample)==1; sum AD_imposed AD_DUTY ln_ad_duty D_cnty_i_mkt_sh_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1; *Next, calculate the interaction terms we’re interested in; egen av_imp_gr=mean(D_cnty_i_mkt_sh_L1); egen av_elast=mean(ln_inv_es_id_elast_sum); gen imports_beta= _b[D_cnty_i_mkt_sh_L1]+_b[MDXS_imp]*av_elast; gen elast_beta= _b[ln_inv_es_id_elast_sum]+_b[MDXS_imp]*av_imp_gr; *Calculate std errors; *define the VCE matrix; matrix varcov=e(V); matrix list varcov; *extract the diagonal of the vce matrix; matrix vc_row=vecdiag(varcov); *construct a new matrix with zeros on the off-diagonal; matrix vc_diag=diag(vc_row); *take the square root of the diagonal elements; matrix std_err=cholesky(vc_diag); matrix list std_err; matrix list varcov; gen var_imp_beta =varcov[1,1]+(varcov[4,4]*(av_elast^2)) +2*av_elast*varcov[1,4]; gen std_err_imp_beta=var_imp_beta^(.5); gen var_elast_beta=varcov[3,3] +(varcov[4,4]*(av_imp_gr^2))+2*av_imp_gr*varcov[3,4]; gen std_err_elast_beta=var_elast_beta^(.5); /* ***************************************************************************** */ /* THESE ARE THE MARGINAL EFFECTS ESTIMATES INCLUDING THE DIRECT AND INDIRECT EFFECTS FOR THE VARIABLES OF INTEREST */ sum imports_beta; sum elast_beta; /* ***************************************************************************** */ /* THESE ARE THE STANDARD ERRORS OF THE MARGINAL EFFECTS ESTIMATES INCLUDING THE DIRECT AND INDIRECT EFFECTS FOR THE VARIABLES OF INTEREST */ sum std_err_imp_beta; sum std_err_elast_beta; ************************************************************************************************; *PREDICTION: quantify the effect on the prob of a one std dev shock for interaction terms; ************************************************************************************************; *Calculate the predicted value at the mean of the dataset; predict x_beta_1; sum x_beta_1; *Generate local variables equal to the mean and std dev of D_cnty_i_mkt_sh_L1; egen D_cnty_i_mkt_sh_L1_mean= mean(D_cnty_i_mkt_sh_L1); egen D_cnty_i_mkt_sh_L1_sd=sd(D_cnty_i_mkt_sh_L1); gen D_cnty_i_mkt_sh_L1_saved=D_cnty_i_mkt_sh_L1; replace D_cnty_i_mkt_sh_L1= D_cnty_i_mkt_sh_L1_mean + D_cnty_i_mkt_sh_L1_sd; *Generate local variables equal to the mean and std dev of the elasticities; egen ln_inv_es_id_elast_sum_mean= mean(ln_inv_es_id_elast_sum); egen ln_inv_es_id_elast_sum_sd=sd(ln_inv_es_id_elast_sum); *Part 1: Consider the effect on the probability of a one std deviation shock to import growth; predict x_beta_2; sum x_beta_2; gen MDXS_imp_saved=MDXS_imp; replace MDXS_imp= ln_inv_es_id_elast_sum*(D_cnty_i_mkt_sh_L1_mean+D_cnty_i_mkt_sh_L1_sd); /* ***************************************************************************** */ /* THIS (x_beta_3) IS THE FULL INTERRACTED EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO IMP GROWTH */ predict x_beta_3; sum x_beta_3; *Part 2: Consider the effect of a one standard deviation shock to the elasticity measure; *First, change those values back to the means; replace D_cnty_i_mkt_sh_L1=D_cnty_i_mkt_sh_L1_saved; replace MDXS_imp=MDXS_imp_saved; /* ***************************************************************************** */ *Check that this (x_beta_4) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_4; sum x_beta_4; replace ln_inv_es_id_elast_sum= ln_inv_es_id_elast_sum_mean + ln_inv_es_id_elast_sum_sd; predict x_beta_5; sum x_beta_5; replace MDXS_imp= D_cnty_i_mkt_sh_L1*(ln_inv_es_id_elast_sum_mean+ln_inv_es_id_elast_sum_sd); /* ***************************************************************************** */ /* THIS (x_beta_6) IS THE FULL INTERRACTED EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE ELASTICITY MEASURE */ predict x_beta_6; sum x_beta_6; /* WHAT ARE SUMMARY STATISTICS CONDITIONAL ON AN AD TARIFF BEING IMPOSED? */ keep if e(sample)==1; keep if AD_DUTY>0; drop if AD_DUTY==.; sum AD_DUTY ln_ad_duty; log close;