Skip to content

Commit 017865f

Browse files
committed
Updated MLE.md
1 parent 17a4abf commit 017865f

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

docs/book/struct_est/MLE.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,50 @@ def trunc_norm_pdf(xvals, mu, sigma, cut_lb=None, cut_ub=None):
204204
return pdf_vals
205205
```
206206

207+
Let's plot the histogram of the intermediate macroeconomics test scores overlayed by two different truncated nameal distributions, each of which with different arbitrary properties. We want to examine what types of properties make the distribution look more or less like the underlying data.
208+
209+
```{code-cell} ipython3
210+
:tags: ["remove-output"]
211+
212+
# Plot histogram
213+
num_bins = 30
214+
count, bins, ignored = plt.hist(data, num_bins, density=True,
215+
edgecolor='k')
216+
plt.title('Intermediate macro scores: 2011-2012', fontsize=15)
217+
plt.xlabel(r'Total points')
218+
plt.ylabel(r'Percent of scores')
219+
plt.xlim([0, 550]) # This gives the xmin and xmax to be plotted"
220+
221+
# Plot smooth line with distribution 1
222+
dist_pts = np.linspace(0, 450, 500)
223+
mu_1 = 380
224+
sig_1 = 150
225+
plt.plot(dist_pts, trunc_norm_pdf(dist_pts, mu_1, sig_1, 0, 450),
226+
linewidth=2, color='r', label='1: $\mu$=380,$\sigma$=150')
227+
plt.legend(loc='upper left')
228+
229+
# Plot smooth line with distribution 2
230+
mu_2 = 360
231+
sig_2 = 60
232+
plt.plot(dist_pts, trunc_norm_pdf(dist_pts, mu_2, sig_2, 0, 450),
233+
linewidth=2, color='g', label='2: $\mu$=360,$\sigma$=60')
234+
plt.legend(loc='upper left')
235+
236+
plt.show()
237+
```
238+
239+
```{figure} ../../../images/mle/Econ381scores_2truncs.png
240+
---
241+
height: 500px
242+
name: FigMLE_EconScores2truncs
243+
---
244+
Intermediate macroeconomics midterm scores over two semesters with two arbitrary truncated normal distributions
245+
```
246+
247+
Which distribution will have the biggest log likelihood function? Why?
248+
249+
Let's compute the log likelihood function for this data for both of these distributions.
250+
207251

208252
(SecMLE_LinReg)=
209253
## Linear regression with MLE
171 KB
Loading

0 commit comments

Comments
 (0)