*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-4-05-01-2012, replace; /* ***************************************************************************** */ /* ** TABLE 4: Specification (1): Baseline model (AD+SG) ** */ /* ***************************************************************************** */ clear; use "SETA_estim_final_05-01-2012.dta"; sort cntry_ind year; by cntry_ind year: gen dup1=cond(_N==1,0,_n); drop if dup1>1; drop dup1; tsset cntry_ind year, yearly; /* 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 ln_concrat4 = ln_concrat4/1000; replace ln_totemp_L1= ln_totemp_L1/1000; replace val_out_L1= val_out_L1/1000; replace inv_ship_L1 =inv_ship_L1/1000; *Generate the interacted continuous variables; gen MDXS_imp= ln_inv_es_id_elast_sum*gr_imp_L1; *FIRST GET THE COMMON POLITICAL ECONOMY DATA AVAILABLE SAMPLE IN MEMORY; dprobit AD_or_SG_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1 ln_concrat4 ln_totemp_L1 val_out_L1 inv_ship_L1, robust; keep if e(sample)==1; *As a dprobit; dprobit AD_or_SG_imposed gr_imp_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 gr_imp_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 AD_imposed gr_imp_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(gr_imp_L1); egen av_elast=mean(ln_inv_es_id_elast_sum); gen me_imports= (_b[gr_imp_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 gr_imp_L1; egen gr_imp_L1_mean= mean(gr_imp_L1); egen gr_imp_L1_sd=sd(gr_imp_L1); gen gr_imp_L1_saved=gr_imp_L1; *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); gen ln_inv_es_id_elast_sum_saved=ln_inv_es_id_elast_sum; *Generate local variables equal to the mean and std dev of the RXR; egen chg_rxr_L1_mean= mean(chg_rxr_L1); egen chg_rxr_L1_sd=sd(chg_rxr_L1); gen chg_rxr_L1_saved=chg_rxr_L1; *Generate local variables equal to the mean and std dev of the standard deviation of the growth rate of imports; egen sd_imp_gr_mean= mean(sd_imp_gr); egen sd_imp_gr_sd=sd(sd_imp_gr); gen sd_imp_gr_saved=sd_imp_gr; *Part 1: Consider the effect on the probability of a one std deviation shock to import growth; replace gr_imp_L1= gr_imp_L1_mean + gr_imp_L1_sd; predict x_beta_2; sum x_beta_2; gen MDXS_imp_saved=MDXS_imp; replace MDXS_imp= ln_inv_es_id_elast_sum*(gr_imp_L1_mean+gr_imp_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 gr_imp_L1=gr_imp_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= gr_imp_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; *Part 3: Consider the effect of a one standard deviation shock to: RXR; *First, change those values back to the means; replace ln_inv_es_id_elast_sum=ln_inv_es_id_elast_sum_saved; replace MDXS_imp=MDXS_imp_saved; /* ***************************************************************************** */ *Check that this (x_beta_7) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_7; sum x_beta_7; replace chg_rxr_L1= chg_rxr_L1_mean + chg_rxr_L1_sd; /* ***************************************************************************** */ /* THIS (x_beta_8) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE RXR */ predict x_beta_8; sum x_beta_8; *Part 4: Consider the effect of a one standard deviation shock to: standard deviation of growth of imports; *First, change those values back to the means; replace chg_rxr_L1=chg_rxr_L1_saved; /* ***************************************************************************** */ *Check that this (x_beta_9) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_9; sum x_beta_9; replace sd_imp_gr= sd_imp_gr_mean + sd_imp_gr_sd; /* ***************************************************************************** */ /* THIS (x_beta_10) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE standard deviation of growth of imports */ predict x_beta_10; sum x_beta_10; /* ***************************************************************************** */ /* ** TABLE 4: Specification (2): Baseline model + political economy characteristics ** */ /* ***************************************************************************** */ clear; use "SETA_estim_final_05-01-2012.dta"; sort cntry_ind year; by cntry_ind year: gen dup1=cond(_N==1,0,_n); drop if dup1>1; drop dup1; tsset cntry_ind year, yearly; /* 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 ln_concrat4 = ln_concrat4/1000; replace ln_totemp_L1= ln_totemp_L1/1000; replace val_out_L1= val_out_L1/1000; replace inv_ship_L1 =inv_ship_L1/1000; *Generate the interacted continuous variables; gen MDXS_imp= ln_inv_es_id_elast_sum*gr_imp_L1; *As a dprobit; dprobit AD_or_SG_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1 ln_concrat4 ln_totemp_L1 val_out_L1 inv_ship_L1, robust; mfx compute; *As a probit, with interaction; probit AD_or_SG_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1 ln_concrat4 ln_totemp_L1 val_out_L1 inv_ship_L1, robust; keep if e(sample)==1; sum AD_or_SG_imposed AD_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1 ln_concrat4 ln_totemp_L1 val_out_L1 inv_ship_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(gr_imp_L1); egen av_elast=mean(ln_inv_es_id_elast_sum); gen me_imports= (_b[gr_imp_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 gr_imp_L1; egen gr_imp_L1_mean= mean(gr_imp_L1); egen gr_imp_L1_sd=sd(gr_imp_L1); gen gr_imp_L1_saved=gr_imp_L1; *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); gen ln_inv_es_id_elast_sum_saved=ln_inv_es_id_elast_sum; *Generate local variables equal to the mean and std dev of the RXR; egen chg_rxr_L1_mean= mean(chg_rxr_L1); egen chg_rxr_L1_sd=sd(chg_rxr_L1); gen chg_rxr_L1_saved=chg_rxr_L1; *Generate local variables equal to the mean and std dev of the standard deviation of the growth rate of imports; egen sd_imp_gr_mean= mean(sd_imp_gr); egen sd_imp_gr_sd=sd(sd_imp_gr); gen sd_imp_gr_saved=sd_imp_gr; *Generate local variables equal to the mean and std dev of the standard deviation of the concentration ratio; egen ln_concrat4_mean= mean(ln_concrat4); egen ln_concrat4_sd=sd(ln_concrat4); gen ln_concrat4_saved=ln_concrat4; *Generate local variables equal to the mean and std dev of the standard deviation of the log level of total employment; egen ln_totemp_L1_mean= mean(ln_totemp_L1); egen ln_totemp_L1_sd=sd(ln_totemp_L1); gen ln_totemp_L1_saved=ln_totemp_L1; *Generate local variables equal to the mean and std dev of the standard deviation of the ratio of value-added to output; egen val_out_L1_mean= mean(val_out_L1); egen val_out_L1_sd=sd(val_out_L1); gen val_out_L1_saved=val_out_L1; *Generate local variables equal to the mean and std dev of the standard deviation of the percent change in inventories/shipments; egen inv_ship_L1_mean= mean(inv_ship_L1); egen inv_ship_L1_sd=sd(inv_ship_L1); gen inv_ship_L1_saved=inv_ship_L1; *Part 1: Consider the effect on the probability of a one std deviation shock to import growth; replace gr_imp_L1= gr_imp_L1_mean + gr_imp_L1_sd; predict x_beta_2; sum x_beta_2; gen MDXS_imp_saved=MDXS_imp; replace MDXS_imp= ln_inv_es_id_elast_sum*(gr_imp_L1_mean+gr_imp_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 gr_imp_L1=gr_imp_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= gr_imp_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; *Part 3: Consider the effect of a one standard deviation shock to: RXR; *First, change those values back to the means; replace ln_inv_es_id_elast_sum=ln_inv_es_id_elast_sum_saved; replace MDXS_imp=MDXS_imp_saved; /* ***************************************************************************** */ *Check that this (x_beta_7) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_7; sum x_beta_7; replace chg_rxr_L1= chg_rxr_L1_mean + chg_rxr_L1_sd; /* ***************************************************************************** */ /* THIS (x_beta_8) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE RXR */ predict x_beta_8; sum x_beta_8; *Part 4: Consider the effect of a one standard deviation shock to: standard deviation of growth of imports; *First, change those values back to the means; replace chg_rxr_L1=chg_rxr_L1_saved; /* ***************************************************************************** */ *Check that this (x_beta_9) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_9; sum x_beta_9; replace sd_imp_gr= sd_imp_gr_mean + sd_imp_gr_sd; /* ***************************************************************************** */ /* THIS (x_beta_10) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE standard deviation of growth of imports */ predict x_beta_10; sum x_beta_10; *Part 5: Consider the effect of a one standard deviation shock to: standard deviation of concentration ratio; *First, change those values back to the means; replace sd_imp_gr=sd_imp_gr_saved; /* ***************************************************************************** */ *Check that this (x_beta_11) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_11; sum x_beta_11; replace ln_concrat4= ln_concrat4_mean + ln_concrat4_sd; /* ***************************************************************************** */ /* THIS (x_beta_12) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE concentration ratio */ predict x_beta_12; sum x_beta_12; *Part 6: Consider the effect of a one standard deviation shock to: standard deviation of total employment; *First, change those values back to the means; replace ln_concrat4=ln_concrat4_saved; /* ***************************************************************************** */ *Check that this (x_beta_13) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_13; sum x_beta_13; replace ln_totemp_L1= ln_totemp_L1_mean + ln_totemp_L1_sd; /* ***************************************************************************** */ /* THIS (x_beta_14) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE log level of employment */ predict x_beta_14; sum x_beta_14; *Part 7: Consider the effect of a one standard deviation shock to: value added over output ratio; *First, change those values back to the means; replace ln_totemp_L1=ln_totemp_L1_saved; /* ***************************************************************************** */ *Check that this (x_beta_15) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_15; sum x_beta_15; replace val_out_L1= val_out_L1_mean + val_out_L1_sd; /* ***************************************************************************** */ /* THIS (x_beta_16) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE value added to output ratio */ predict x_beta_16; sum x_beta_16; *Part 8: Consider the effect of a one standard deviation shock to: percent change in inventories over shipments; *First, change those values back to the means; replace val_out_L1=val_out_L1_saved; /* ***************************************************************************** */ *Check that this (x_beta_17) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_17; sum x_beta_17; replace inv_ship_L1= inv_ship_L1_mean + inv_ship_L1_sd; /* ***************************************************************************** */ /* THIS (x_beta_18) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE percent change in inventories over shipments */ predict x_beta_18; sum x_beta_18; *First, change those values back to the means; replace inv_ship_L1=inv_ship_L1_saved; /* ***************************************************************************** */ /* ** TABLE 4: Specification (3): Baseline model + political economy characteristics plus steel and chemical dummies ** */ /* ***************************************************************************** */ clear; use "SETA_estim_final_05-01-2012.dta"; gen real_naics=real(NAICS); *note the 5 digit aggregated naics industries are still strings; gen steel=1 if real_naics==33111; replace steel=1 if real_naics==33122; replace steel=1 if real_naics==33151; replace steel=0 if steel==.; gen chem=1 if real_naics==32511; replace chem=1 if real_naics==32512; replace chem=1 if real_naics==32513; replace chem=1 if real_naics==325181; replace chem=1 if real_naics==325182; replace chem=1 if real_naics==325188; replace chem=1 if real_naics==32519; replace chem=0 if chem==.; sort cntry_ind year; by cntry_ind year: gen dup1=cond(_N==1,0,_n); drop if dup1>1; drop dup1; tsset cntry_ind year, yearly; /* 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 ln_concrat4 = ln_concrat4/1000; replace ln_totemp_L1= ln_totemp_L1/1000; replace val_out_L1= val_out_L1/1000; replace inv_ship_L1 =inv_ship_L1/1000; *Generate the interacted continuous variables; gen MDXS_imp= ln_inv_es_id_elast_sum*gr_imp_L1; *As a dprobit; dprobit AD_or_SG_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1 ln_concrat4 ln_totemp_L1 val_out_L1 inv_ship_L1 steel chem, robust; mfx compute; *As a probit, with interaction; probit AD_or_SG_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1 ln_concrat4 ln_totemp_L1 val_out_L1 inv_ship_L1 steel chem, robust; keep if e(sample)==1; sum AD_or_SG_imposed AD_imposed gr_imp_L1 sd_imp_gr ln_inv_es_id_elast_sum MDXS_imp chg_rxr_L1 ln_concrat4 ln_totemp_L1 val_out_L1 inv_ship_L1 steel chem; *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(gr_imp_L1); egen av_elast=mean(ln_inv_es_id_elast_sum); gen me_imports= (_b[gr_imp_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 gr_imp_L1; egen gr_imp_L1_mean= mean(gr_imp_L1); egen gr_imp_L1_sd=sd(gr_imp_L1); gen gr_imp_L1_saved=gr_imp_L1; *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); gen ln_inv_es_id_elast_sum_saved=ln_inv_es_id_elast_sum; *Generate local variables equal to the mean and std dev of the RXR; egen chg_rxr_L1_mean= mean(chg_rxr_L1); egen chg_rxr_L1_sd=sd(chg_rxr_L1); gen chg_rxr_L1_saved=chg_rxr_L1; *Generate local variables equal to the mean and std dev of the standard deviation of the growth rate of imports; egen sd_imp_gr_mean= mean(sd_imp_gr); egen sd_imp_gr_sd=sd(sd_imp_gr); gen sd_imp_gr_saved=sd_imp_gr; *Generate local variables equal to the mean and std dev of the standard deviation of the concentration ratio; egen ln_concrat4_mean= mean(ln_concrat4); egen ln_concrat4_sd=sd(ln_concrat4); gen ln_concrat4_saved=ln_concrat4; *Generate local variables equal to the mean and std dev of the standard deviation of the log level of total employment; egen ln_totemp_L1_mean= mean(ln_totemp_L1); egen ln_totemp_L1_sd=sd(ln_totemp_L1); gen ln_totemp_L1_saved=ln_totemp_L1; *Generate local variables equal to the mean and std dev of the standard deviation of the ratio of value-added to output; egen val_out_L1_mean= mean(val_out_L1); egen val_out_L1_sd=sd(val_out_L1); gen val_out_L1_saved=val_out_L1; *Generate local variables equal to the mean and std dev of the standard deviation of the percent change in inventories/shipments; egen inv_ship_L1_mean= mean(inv_ship_L1); egen inv_ship_L1_sd=sd(inv_ship_L1); gen inv_ship_L1_saved=inv_ship_L1; *Generate local variables equal to the mean and std dev of the standard deviation of steel indicator; egen steel_mean= mean(steel); egen steel_sd=sd(steel); gen steel_saved=steel; *Generate local variables equal to the mean and std dev of the standard deviation of chemical indicator; egen chem_mean= mean(chem); egen chem_sd=sd(chem); gen chem_saved=chem; *Part 1: Consider the effect on the probability of a one std deviation shock to import growth; replace gr_imp_L1= gr_imp_L1_mean + gr_imp_L1_sd; predict x_beta_2; sum x_beta_2; gen MDXS_imp_saved=MDXS_imp; replace MDXS_imp= ln_inv_es_id_elast_sum*(gr_imp_L1_mean+gr_imp_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 gr_imp_L1=gr_imp_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= gr_imp_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; *Part 3: Consider the effect of a one standard deviation shock to: RXR; *First, change those values back to the means; replace ln_inv_es_id_elast_sum=ln_inv_es_id_elast_sum_saved; replace MDXS_imp=MDXS_imp_saved; /* ***************************************************************************** */ *Check that this (x_beta_7) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_7; sum x_beta_7; replace chg_rxr_L1= chg_rxr_L1_mean + chg_rxr_L1_sd; /* ***************************************************************************** */ /* THIS (x_beta_8) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE RXR */ predict x_beta_8; sum x_beta_8; *Part 4: Consider the effect of a one standard deviation shock to: standard deviation of growth of imports; *First, change those values back to the means; replace chg_rxr_L1=chg_rxr_L1_saved; /* ***************************************************************************** */ *Check that this (x_beta_9) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_9; sum x_beta_9; replace sd_imp_gr= sd_imp_gr_mean + sd_imp_gr_sd; /* ***************************************************************************** */ /* THIS (x_beta_10) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE standard deviation of growth of imports */ predict x_beta_10; sum x_beta_10; *Part 5: Consider the effect of a one standard deviation shock to: standard deviation of concentration ratio; *First, change those values back to the means; replace sd_imp_gr=sd_imp_gr_saved; /* ***************************************************************************** */ *Check that this (x_beta_11) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_11; sum x_beta_11; replace ln_concrat4= ln_concrat4_mean + ln_concrat4_sd; /* ***************************************************************************** */ /* THIS (x_beta_12) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE concentration ratio */ predict x_beta_12; sum x_beta_12; *Part 6: Consider the effect of a one standard deviation shock to: standard deviation of total employment; *First, change those values back to the means; replace ln_concrat4=ln_concrat4_saved; /* ***************************************************************************** */ *Check that this (x_beta_13) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_13; sum x_beta_13; replace ln_totemp_L1= ln_totemp_L1_mean + ln_totemp_L1_sd; /* ***************************************************************************** */ /* THIS (x_beta_14) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE log level of employment */ predict x_beta_14; sum x_beta_14; *Part 7: Consider the effect of a one standard deviation shock to: value added over output ratio; *First, change those values back to the means; replace ln_totemp_L1=ln_totemp_L1_saved; /* ***************************************************************************** */ *Check that this (x_beta_15) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_15; sum x_beta_15; replace val_out_L1= val_out_L1_mean + val_out_L1_sd; /* ***************************************************************************** */ /* THIS (x_beta_16) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE value added to output ratio */ predict x_beta_16; sum x_beta_16; *Part 8: Consider the effect of a one standard deviation shock to: percent change in inventories over shipments; *First, change those values back to the means; replace val_out_L1=val_out_L1_saved; /* ***************************************************************************** */ *Check that this (x_beta_17) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_17; sum x_beta_17; replace inv_ship_L1= inv_ship_L1_mean + inv_ship_L1_sd; /* ***************************************************************************** */ /* THIS (x_beta_18) IS THE EFFECT ON THE PROBABILITY OF A ONE STD DEV INCREASE TO THE percent change in inventories over shipments */ predict x_beta_18; sum x_beta_18; *Part 9: Consider the effect of a 0/1 shock and one std dev shock to: steel dummy variable; *First, change those values back to the means; replace inv_ship_L1=inv_ship_L1_saved; /* ***************************************************************************** */ *Check that this (x_beta_19) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_19; sum x_beta_19; replace steel=0; /* ***************************************************************************** */ /* THIS (x_beta_20) IS THE PROBABILITY OF AD at data when steel = 0 */ predict x_beta_20; sum x_beta_20; replace steel=1; /* ***************************************************************************** */ /* THIS (x_beta_21) IS THE PROBABILITY OF AD at data when steel = 1 */ predict x_beta_21; sum x_beta_21; replace steel=steel_mean+steel_sd; /* ***************************************************************************** */ /* THIS (x_beta_22) IS THE PROBABILITY OF AD at data when steel is at mean + sd */ predict x_beta_22; sum x_beta_22; *Part 10: Consider the effect of a 0/1 shock and one std dev shock to: chemicals dummy variable; *First, change those values back to the means; replace steel=steel_saved; /* ***************************************************************************** */ *Check that this (x_beta_23) is the same as x_beta_1 so the original data is reloaded into memory; predict x_beta_23; sum x_beta_23; replace chem=0; /* ***************************************************************************** */ /* THIS (x_beta_24) IS THE PROBABILITY OF AD at data when chem = 0 */ predict x_beta_24; sum x_beta_24; replace chem=1; /* ***************************************************************************** */ /* THIS (x_beta_25) IS THE PROBABILITY OF AD at data when chem = 1 */ predict x_beta_25; sum x_beta_25; replace chem=chem_mean+chem_sd; /* ***************************************************************************** */ /* THIS (x_beta_26) IS THE PROBABILITY OF AD at data when chemicals is at mean + sd */ predict x_beta_26; sum x_beta_26; log close;