You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Macroeconomic midterm scores and three truncated normal distributions
443
444
```
444
445
446
+
447
+
(SecSMM_CodeExmp_MacrTest_2mI)=
445
448
#### Two moments, identity weighting matrix
446
449
Let's try estimating the parameters $\mu$ and $\sigma$ from the truncated normal distribution by SMM, assuming that we know the cutoff values for the distribution of scores $c_{lb}=0$ and $c_{ub}=450$. What moments should we use? Let's try the mean and variance of the data. These two statistics of the data are defined by:
447
450
@@ -844,8 +847,8 @@ def criterion(params, *args):
844
847
mu = scalar, mean of the normally distributed random variable
845
848
sigma = scalar > 0, standard deviation of the normally
846
849
distributed random variable
847
-
args = length 5 tuple,
848
-
(xvals, unif_vals, cut_lb, cut_ub, W_hat)
850
+
args = length 6 tuple,
851
+
(xvals, unif_vals, cut_lb, cut_ub, W_hat, simple)
849
852
xvals = (N,) vector, values of the truncated normally
850
853
distributed random variable
851
854
unif_vals = (N, S) matrix, matrix of draws from U(0,1) distribution.
@@ -859,6 +862,8 @@ def criterion(params, *args):
859
862
distribution. Values below this cutoff have zero
860
863
probability
861
864
W_hat = (R, R) matrix, estimate of optimal weighting matrix
865
+
simple = Boolean, =True if error vec is simple difference,
866
+
=False if error vec is percent difference
862
867
863
868
OTHER FUNCTIONS AND FILES CALLED BY THIS FUNCTION:
@@ -940,7 +945,7 @@ print("Results from scipy.opmtimize.minimize:")
940
945
print(results1_1)
941
946
```
942
947
943
-
Let's plot the PDF implied by these SMM estimates $(\hat{\mu}_{SMM},\hat{\sigma}_{SMM})=(612.337, 197.264)$ against the histogram of the data in {numref}`Figure %s <FigSMM_EconScoreSMM1>` below.
948
+
Let's plot the PDF implied by these SMM estimates $(\hat{\mu}_{SMM},\hat{\sigma}_{SMM})=(612.337, 197.264)$ against the histogram of the data in {numref}`Figure %s <FigSMM_Econ381_SMM1>` below.
SMM-estimated PDF function and data histogram, 2 moments, identity weighting matrix, Econ 381 scores (2011-2012)
971
976
```
972
977
973
-
That looks just like the maximum likelihood estimate from the {ref}`Chap_MaxLikeli` chapter. Let's see what the criterion function looks like for different values of $\mu$ and $\sigma$.
978
+
That looks just like the maximum likelihood estimate from the {ref}`Chap_MaxLikeli` chapter. {numref}`Figure %s <FigSMM_Econ381_crit1>` below shows what the minimizer is doing. The figure shows the criterion function surface for different of $\mu$ and $\sigma$ in the truncated normal distribution. The minimizer is searching for the parameter values that give the lowest criterion function value.
ax.set_title('Criterion function for values of mu and sigma')
998
-
ax.set_xlabel(r'$\sigma$')
999
-
ax.set_ylabel(r'$\mu$')
1003
+
ax.set_xlabel(r'$\mu$')
1004
+
ax.set_ylabel(r'$\sigma$')
1000
1005
ax.set_zlabel(r'Crit. func.')
1006
+
plt.tight_layout()
1001
1007
1002
1008
plt.show()
1003
1009
```
1004
1010
1011
+
```{figure} ../../../images/smm/Econ381_crit1.png
1012
+
---
1013
+
height: 500px
1014
+
name: FigSMM_Econ381_crit1
1015
+
---
1016
+
Criterion function surface for values of $\mu$ and $\sigma$ for SMM estimation of truncated normal with two moments and identity weighting matrix (SMM estimate shown as red dot)
1017
+
```
1018
+
1019
+
Let's compute the SMM estimator for the variance-covariance matrix $\hat{\Sigma}_{SMM}$ of our SMM estimates $\hat{\theta}_{SMM}$ using the equation in Section {ref}`SecSMM_VarCovTheta` based on the Jacobian $d(\tilde{x},x|\hat{\theta}_{SMM})$ of the moment error vector $e(\tilde{x},x|\hat{\theta}_{SMM})$ from the criterion function at the estimated (optimal) parameter values $\hat{\theta}_{SMM}$. We first write a function that computes the Jacobian matrix $d(x|\hat{\theta}_{SMM})$, which has shape $2\times 2$ in this case with two moments $R=2$.
This SMM estimation methodology of estimating $\mu$ and $\sigma$ from the truncated normal distribution to fit the distribution of Econ 381 test scores using two moments from the data and using the identity matrix as the optimal weighting matrix is not very precise. The standard errors for the estimates of $\hat{mu}$ and $\hat{sigma}$ are bigger than their values.
1068
+
1069
+
In the next section, we see if we can get more accurate estimates (lower criterion function values) of $\hat{mu}$ and $\hat{sigma}$ with more precise standard errors by using the two-step optimal weighting matrix described in Section {ref}`SecSMM_W_2step`.
1070
+
1071
+
1072
+
(SecSMM_CodeExmp_MacrTest_2m2st)=
1073
+
#### Two moments, two-step optimal weighting matrix
1074
+
Similar to the maximum likelihood estimation problem in Chapter {ref}`Chap_MaxLikeli`, it looks like the minimum value of the criterion function shown in {numref}`Figure %s <FigSMM_Econ381_crit1>` is roughly equal for a specific portion increase of $\mu$ and $\sigma$ together. That is, the estimation problem with these two moments probably has a correspondence of values of $\mu$ and $\sigma$ that give roughly the same minimum criterion function value. This issue has two possible solutions.
1075
+
1076
+
1. Maybe we need the two-step variance covariance estimator to calculate a "more" optimal weighting matrix $W$.
1077
+
2. Maybe our two moments aren't very good moments for fitting the data.
#### Four moments, identity matrix weighting matrix
1186
+
1187
+
Using a better weighting matrix didn't improve our estimates or fit very much---the estimates of $\hat{mu}$ and $\hat{\sigma}$ and the corresponding minimum criterion function value. But it did improve our standard errors. But even with the optimal weighting matrix, our standard errors still look pretty big. This might mean that we did not choose good moments for fitting the data. Let's try some different moments. How about four moments to match.
1188
+
1189
+
1. The percent of observations greater than 430 (between 430 and 450)
1190
+
2. The percent of observations between 320 and 430
1191
+
3. The percent of observations between 220 and 320
1192
+
4. The percent of observations less than 220 (between 0 and 220)
1193
+
1194
+
This means we are using four moments $R=4$ to identify two paramters $\mu$ and $\sigma$ ($K=2$). This problem is now overidentified ($R>K$). This is often a desired approach for SMM estimation.
1195
+
1196
+
1197
+
(SecSMM_CodeExmp_MacrTest_4m2st)=
1198
+
#### Four moments, two-step optimal weighting matrix
0 commit comments