- Guess 2 parameter values
- Using the guessed parameter values construct some model consistent values for each observation
- Create a binary variable based on the model consistent values, split at the median determining "high" and "low".
- Run an IV regression using the original data (that wasn't constructed by the model) but with an interaction term for "high" from step 3.
- Check L2 norm between the coefficients from the regression and the means of the "high" and "low" group.
- Rinse and repeat until step 5 is minimized.
Code:
*1. Choose parameter values gen k = *guess1_1* gen scale = *guess1_2* *2. Calculate model consistent elasticities ** relevant code which generates variable T for each observation** *3. Cut by median & calculate model measures egen median_T = median(T) gen High = T > median_T qui sum T if High == 0 gen model_low = r(mean) qui sum T if High == 1 gen model_high = r(mean) *4A. Calculate interaction terms for IV gen lnxXHigh = lnx * High gen zXHigh = z*High *4B. Calculate empirical measures qui ivreghdfe lnY High (lnx lnxXHigh = z zXHigh) if a(c y ym) cluster(c) gen empirical_low = _b[lnx] gen empirical_high = _b[lnx] + _b[lnxXHigh] *5. Euclidean distance gen euc_distance = sqrt((empirical_low - model_low)^2 +(empirical_high-model_high)^2)
0 Response to Programming minimum distance estimator using optimize
Post a Comment