% NOTE -- ONLY EDIT THE .Rnw FILE!!!  The .tex file is
% likely to be overwritten.



\setkeys{Gin}{width=\textwidth}

\begin{frame}
  \frametitle{Item Response Models}
  \begin{itemize}
  \item Models for binary (or ordered categorical) data that are
    cross-classified according to subject and item are sometimes
    called \Emph{Item Response} or \Emph{IRT} (Item Response Theory)
    models.
  \item There is a long history of models for such data with many
    contributors.  Only recently have statisticians become aware of
    this literature and considered how such models could be framed in
    the context of GLMMs.
  \item Even when approaching IRT models as GLMMs they were not
    expressed as GLMMs with crossed random effects, because of
    software limitations.
  \item Because \code{glmer} can fit GLMMs with crossed random
    effects, we can approach such models as GLMMs with random effects
    for subject and item.
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Data from a study of verbal aggression}
  \begin{itemize}
  \item Results on a study of verbal aggression, used as an example
    through the book \Emph{Expanatory Item Response Models}, edited by
    De Boeck and Wilson (Springer, 2004) are available as the data set
    \code{VerbAgg}, in the ``long'' format.
  \item The items correspond to scenarios for which the subject
    was asked if they would curse, scold or shout.
  \item The scenarios are classified according to the behavior mode
    (want versus do) and according to the situation (self-to-blame
    versus other-to-blame).
  \item The subjects are classified by sex. Each subject's score on a
    separately administered anger index (STAXI) is given.
  \item The response was recorded on a three-level ordinal scale
    (``no'', ``perhaps'' and ``yes''). We will consider a dichotomous
    version, \code{r2}.
  \end{itemize}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Structure of VerbAgg data}
  \begin{itemize}
  \item We also check that the item-level covariates and the
    person-level covariates are consistently defined.
  \end{itemize}
\begin{Schunk}
\begin{Sinput}
> str(VerbAgg)
\end{Sinput}
\begin{Soutput}
'data.frame':	7584 obs. of  9 variables:
 $ Anger : int  20 11 17 21 17 21 39 21 24 16 ...
 $ Gender: Factor w/ 2 levels "M","F": 2 2 1 1 1 1 1 1 1 1 ...
 $ item  : Factor w/ 24 levels "S1wantcurse",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ resp  : Ord.factor w/ 3 levels "no"<"perhaps"<..: 1 1 2 2 2 3 3 1 1 3 ...
 $ id    : Factor w/ 316 levels "1","2","3","4",..: 1 2 3 4 5 6 7 8 9 10 ...
 $ btype : Factor w/ 3 levels "curse","scold",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ situ  : Factor w/ 2 levels "other","self": 1 1 1 1 1 1 1 1 1 1 ...
 $ mode  : Factor w/ 2 levels "want","do": 1 1 1 1 1 1 1 1 1 1 ...
 $ r2    : Factor w/ 2 levels "N","Y": 1 1 2 2 2 2 2 1 1 2 ...
\end{Soutput}
\begin{Sinput}
> stopifnot(nrow(unique(subset(VerbAgg, select = c(item, 
+     btype, situ, mode)))) == 24, nrow(unique(subset(VerbAgg, 
+     select = c(id, Anger, Gender)))) == 316)
\end{Sinput}
\end{Schunk}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Influence of item-level covariates}
  \begin{itemize}
  \item We can check the proportions of responses for combinations of
    item-level covariates
  \end{itemize}
\begin{Schunk}
\begin{Sinput}
> round(100 * ftable(prop.table(xtabs(~mode + situ + 
+     resp, VerbAgg), 1:2)), 1)
\end{Sinput}
\begin{Soutput}
           resp   no perhaps  yes
mode situ                        
want other      37.7    30.0 32.3
     self       55.9    29.1 15.0
do   other      49.8    27.2 23.0
     self       66.2    23.5 10.3
\end{Soutput}
\end{Schunk}
\end{frame}


\begin{frame}[fragile]
  \frametitle{Influence of person-level covariates}
\includegraphics{figs/item-VerbAggxy}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Initial model fit}
\begin{Schunk}
\begin{Soutput}
Generalized linear mixed model fit by the Laplace approximation 
Formula: r2 ~ Anger * Gender + situ + btype + mode + (1 | id) + (1 | item) 
   Data: VerbAgg 
  AIC  BIC logLik deviance
 8156 8225  -4068     8136
Random effects:
 Groups Name        Variance Std.Dev.
 id     (Intercept) 1.79337  1.33917 
 item   (Intercept) 0.11715  0.34226 
Number of obs: 7584, groups: id, 316; item, 24
Fixed effects:
               Estimate Std. Error z value Pr(>|z|)
(Intercept)    0.531954   0.433782   1.226  0.22008
Anger          0.058490   0.019474   3.003  0.00267
GenderF        0.402523   0.782316   0.515  0.60688
situself      -1.054279   0.151192  -6.973 3.10e-12
btypescold    -1.059810   0.184156  -5.755 8.67e-09
btypeshout    -2.103818   0.186515 -11.280  < 2e-16
modedo        -0.707055   0.151005  -4.682 2.84e-06
Anger:GenderF -0.004111   0.038170  -0.108  0.91424
\end{Soutput}
\end{Schunk}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Removing non-significant gender effects}
\begin{Schunk}
\begin{Soutput}
Generalized linear mixed model fit by the Laplace approximation 
Formula: r2 ~ Anger + situ + btype + mode + (1 | id) + (1 | item) 
   Data: VerbAgg 
  AIC  BIC logLik deviance
 8155 8210  -4069     8139
Random effects:
 Groups Name        Variance Std.Dev.
 id     (Intercept) 1.81157  1.34595 
 item   (Intercept) 0.11720  0.34235 
Number of obs: 7584, groups: id, 316; item, 24
Fixed effects:
            Estimate Std. Error z value Pr(>|z|)
(Intercept)  0.63927    0.38334   1.668 0.095391
Anger        0.05685    0.01682   3.380 0.000726
situself    -1.05437    0.15122  -6.972 3.12e-12
btypescold  -1.05973    0.18419  -5.753 8.75e-09
btypeshout  -2.10392    0.18655 -11.278  < 2e-16
modedo      -0.70726    0.15104  -4.683 2.83e-06
\end{Soutput}
\end{Schunk}
\end{frame}


\begin{frame}[fragile]
  \frametitle{Allowing situational/behavior random effects by person} 
\begin{Schunk}
\begin{Soutput}
Generalized linear mixed model fit by the Laplace approximation 
Formula: r2 ~ Anger + situ + btype + mode + (1 | id:btype) + (1 | id:situ) +      (1 | id:mode) + (1 | id) + (1 | item) 
   Data: VerbAgg 
  AIC  BIC logLik deviance
 7751 7827  -3865     7729
Random effects:
 Groups   Name        Variance Std.Dev.
 id:btype (Intercept) 1.41069  1.18772 
 id:mode  (Intercept) 0.80916  0.89953 
 id:situ  (Intercept) 0.61539  0.78447 
 id       (Intercept) 1.70950  1.30748 
 item     (Intercept) 0.17213  0.41489 
Number of obs: 7584, groups: id:btype, 948; id:mode, 632; id:situ, 632; id, 316; item, 24
Fixed effects:
            Estimate Std. Error z value Pr(>|z|)
(Intercept)  0.79167    0.48183   1.643 0.100375
Anger        0.07483    0.02107   3.551 0.000384
situself    -1.35742    0.19199  -7.070 1.55e-12
btypescold  -1.36067    0.24118  -5.642 1.68e-08
btypeshout  -2.69333    0.24372 -11.051  < 2e-16
modedo      -0.94095    0.19503  -4.825 1.40e-06
\end{Soutput}
\end{Schunk}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Item-specific random effects}
\includegraphics{figs/item-itemREplot3}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Person-specific random effects - Intercept}
\includegraphics{figs/item-idREplot3}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Correlated random effects by person} 
\begin{Schunk}
\begin{Soutput}
Generalized linear mixed model fit by the Laplace approximation 
Formula: r2 ~ Anger + situ + btype + mode + (1 + situ + btype + mode |      id) + (1 | item) 
   Data: VerbAgg 
  AIC  BIC logLik deviance
 7727 7880  -3842     7683
Random effects:
 Groups Name        Variance Std.Dev. Corr                
 id     (Intercept) 4.53799  2.13025                      
        situself    1.31455  1.14654  -0.521              
        btypescold  1.62188  1.27353  -0.085 -0.247       
        btypeshout  4.03049  2.00761  -0.374  0.010  0.423
        modedo      1.68341  1.29746  -0.295  0.112  0.102
 item   (Intercept) 0.18222  0.42687                      
  0.104 
        
Number of obs: 7584, groups: id, 316; item, 24

Fixed effects:
            Estimate Std. Error z value Pr(>|z|)
(Intercept)  0.98354    0.47248   2.082  0.03738
Anger        0.06564    0.02041   3.217  0.00130
situself    -1.37646    0.19723  -6.979 2.97e-12
btypescold  -1.30375    0.23811  -5.475 4.37e-08
btypeshout  -2.73191    0.25666 -10.644  < 2e-16
modedo      -0.97882    0.20000  -4.894 9.88e-07
\end{Soutput}
\end{Schunk}
\end{frame}

