---
title: 'CSSS/POLS 510 MLE Lab'
subtitle: "Lab 9. Count Data"
author: Minji Jeong
classoption: xcolor=dvipsnames
output:
  beamer_presentation:
    colortheme: seahorse
    fonttheme: structurebold
    theme: cambridgeUS
    highlight: default
linkcolor: blue
editor_options: 
  chunk_output_type: console
header-includes:
 \usepackage{float}
 \usepackage{xcolor}
---

# Housekeeping 
- Homework 4 answer key will be uploaded on Chris's website (Lab 9) 
  - Grades will be posted next week 
- Homework 5 is due December 3 (Wed) 4:30pm
  - Submit a pdf file showing all your code for computation/visualization
    - Comment the part that causes knitting problem  
  - Answer key will be uploaded on Chris's website (Lab 9)
  - Grades will be posted during the last week of the quarter 
- No lab on December 5 (Office hours only)  
- Agenda
  - Review Multinomial Logit
  - Preview Homework 5
  - Modeling count data


# Recap
Where are we at right now?

1. Learn distribution and MLE $\rightarrow$ HW1 & HW2

2. Logit model $\rightarrow$ HW3

3. Ordered Probit model $\rightarrow$ HW4

4. Multinomial logit model $\rightarrow$ HW5



# Review: Simulating QoI (Multinomial Logit)

1. Estimate: MLE $\hat{\beta}_{(M+1)\times(P+1)}$ and its variance $\hat{V}(\hat{\beta}_{(M+1)\times(P+1)})$\
$\textcolor{red}{\rightarrow  \texttt{optim(), multinom()}}$


2. Simulate estimation uncertainty from a multivariate normal distribution:\
      Draw $\tilde{\beta} \sim MVN \big[\hat{\beta}, \hat{V}(\hat{\beta})\big]$\
$\textcolor{red}{\rightarrow  \texttt{MASS::mvrnorm()}}$


3. Create hypothetical scenarios of your substantive interest:\
      Choose valuese of X: $X_c$ 
$\textcolor{red}{\rightarrow  \texttt{simcf::cfmake(), cfchange()} \dots}$


# Review: Simulating QoI (Multinomial Logit)

4. Calculate expected values:\
      $\tilde{\pi_c} = g(X_c, \tilde{\beta})$ \


5. Compute EVs, First Differences or Relative Risks\
      EV: $\mathbb{E}(y = j|X_{c1},\tilde{\beta})$\
      $\textcolor{red}{\rightarrow  \texttt{simcf::mlogitsimev()} \dots}$\
      FD: $\mathbb{E}(y = j|X_{c2},\tilde{\beta},) - \mathbb{E}(y = j|X_{c1},\tilde{\beta})$\
      $\textcolor{red}{\rightarrow  \texttt{simcf::mlogitsimfd()} \dots}$\
      RR: $\frac{\mathbb{E}(y = j|X_{c2},\tilde{\beta})}{\mathbb{E}(y = j|X_{c1},\tilde{\beta})}$\
      $\textcolor{red}{\rightarrow  \texttt{simcf::mlogitsimrr()} \dots}$\

# Last words
Statistics (and programming) should be intuitive 
  \begin{itemize}
    \item If I can't explain the result in a simple manner, I don't understand it
    \item Statistics is a tool; your research design is first
    \item You run the model; don’t let the model run you
  \end{itemize}

Model results are unintelligible unless...
  \begin{itemize}
    \item You interpret and communicate them in meaningful ways\\
    \item \textit{Substantively meaningful} quantities of interest (QoI) and counterfactual scenarios \\
    \item Visualization is critical \\
       Avoid WYGWYS (What you get is what you see)\\
       
   \end{itemize}


# Last words
Computers (and AI) are powerful yet not so smart
  \begin{itemize}
    \item They execute what you instruct them, \textit{literally}
    \item When mistakes happen, it is usually us who make mistakes \\
    (but, sometimes AI makes mistakes too)
    \item No replacement of sound statistical judgement
    \item Don't be held hostage to particular code, functions or packages  
    \item "No default, all manual" is a virtue of \texttt{simcf} and \texttt{tile}
    \item Run incrementally when you face new \texttt{loop} and \texttt{function}: Reading ability is also critical
    \item Watch out for typo 
  \end{itemize}


# Evaluation

What I am responsible of... 
  \begin{itemize}
    \item Teaching in Lab sessions\\
    \item Grading of your homework\\    
    \item Response to your questions and other communication\\ 
  \end{itemize}
What I am Not...
  \begin{itemize}
    \item Course contents\\
    \item Number and difficulty of problem sets\\    
    \item How questions in problem sets are structured and phrased\\ 
    \item How answers should be graded\\ 
  \end{itemize}

# 

\Huge

\centerline{F I N}
