Skip to content

Commit

Permalink
minor slide updates
Browse files Browse the repository at this point in the history
  • Loading branch information
avehtari committed Nov 27, 2024
1 parent 215c2ed commit 6166424
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 58 deletions.
Binary file modified project_work/slides_presentation_example.pdf
Binary file not shown.
127 changes: 69 additions & 58 deletions project_work/slides_presentation_example.tex
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,37 @@
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{booktabs}
\usepackage{listings}
\usepackage{lstbayes}
\usepackage{microtype}

% minted
\usepackage{minted}
\setminted{highlightcolor=yellow!25}
\newmintinline{r}{}
% The following is adjusted from
% https://tex.stackexchange.com/questions/548592/changing-all-colors-to-black-white-using-minted-sty
\makeatletter
\newcommand{\minted@style@bw}{%
\renewcommand\fcolorbox[3][]{##3}%
\renewcommand\textcolor[3][]{##3}%
\color{gray}
}
% define new minted option "gray"
\minted@def@opt@switch{gray}
\fvset{formatcom*={%
\ifthenelse{\equal{\minted@get@opt{gray}{true}}{true}}
{\minted@style@bw}{}%
}}
\makeatother
% The following is ajusted from
% https://tex.stackexchange.com/questions/74459/remove-space-before-colorbox
\newcommand{\reducedstrut}{\vrule width 0pt height .9\ht\strutbox depth .9\dp\strutbox\relax}
\newcommand{\highlight}[1]{%
\begingroup
\setlength{\fboxsep}{0pt}%
\colorbox{yellow!30}{\reducedstrut\detokenize{#1}\/}%
\endgroup
}

\usepackage{natbib}
\bibliographystyle{apalike}

Expand Down Expand Up @@ -224,6 +251,14 @@

\begin{document}

\begin{frame}[fragile]{Make brms silent}

\begin{minted}[fontsize=\footnotesize]{r}
fit <- brm(..., silent=2, refresh=0)
\end{minted}

\end{frame}

\begin{frame}

\centering
Expand Down Expand Up @@ -328,13 +363,12 @@
\begin{itemize}
\item no difference
\end{itemize}
{\footnotesize
\begin{lstlisting}
\begin{minted}[fontsize=\footnotesize]{r}
elpd_diff se_diff
RHS prior 0.0 0.0
Gaussian prior -1.1 2.2
\end{lstlisting}
}
\end{minted}

\end{itemize}

\end{frame}
Expand All @@ -348,32 +382,26 @@
\begin{itemize}
\item no difference
\end{itemize}
{\scriptsize
\begin{lstlisting}
\begin{minted}[fontsize=\footnotesize]{r}
elpd_diff se_diff
RHS prior 0.0 0.0
Gaussian prior -1.1 2.2
\end{lstlisting}
}
{\scriptsize
\begin{lstlisting}
\end{minted}

\begin{minted}[fontsize=\footnotesize]{r}
Computed from 4000 by 250 log-likelihood matrix

Estimate SE
elpd_loo -723.9 9.4
p_loo 13.4 1.2
looic 1447.9 18.8
------
Monte Carlo SE of elpd_loo is 0.1.

Pareto k diagnostic values:
Count Pct. Min. n_eff
(-Inf, 0.5] (good) 249 99.6% 1374
(0.5, 0.7] (ok) 1 0.4% 724
(0.7, 1] (bad) 0 0.0% <NA>
(1, Inf) (very bad) 0 0.0% <NA>
\end{lstlisting}
}
MCSE of elpd_loo is 0.1.
MCSE and ESS estimates assume MCMC draws (r_eff in [0.6, 1.2]).

All Pareto k estimates are good (k < 0.7).
See help('pareto-k-diagnostic') for details.
\end{minted}

\end{itemize}

Expand Down Expand Up @@ -406,12 +434,10 @@

For example:

{\footnotesize
\begin{lstlisting}
\begin{minted}[fontsize=\footnotesize]{r}
theme_set(bayesplot::theme_default(base_family = "sans",
base_size=16))
\end{lstlisting}
}
base_size=16))
\end{minted}

\end{frame}

Expand Down Expand Up @@ -655,8 +681,7 @@

Gaussian linear model with regularized horseshoe prior

{\tiny
\begin{lstlisting}
\begin{minted}[fontsize=\tiny]{stan}
// generated with brms 2.14.4
functions {
vector horseshoe(vector z, vector lambda, real tau, real c2) {
Expand Down Expand Up @@ -723,9 +748,7 @@
// actual population-level intercept
real b_Intercept = Intercept - dot_product(means_X, b);
}
\end{lstlisting}
}

\end{minted}

\end{frame}

Expand Down Expand Up @@ -782,44 +805,33 @@
{\Large\color{navyblue} Hierarchical example: Rats growth curves}

Simple linear model
{\footnotesize
\begin{lstlisting}
fit_1 <- stan_glm(weight ~ age, data=dfrats)
\end{lstlisting}
}
\begin{minted}[fontsize=\footnotesize]{r}
fit_1 <- brm(weight ~ age, data=dfrats)
\end{minted}

Linear model with hierarchical intercept
{\footnotesize
\begin{lstlisting}
fit_2 <- stan_glmer(weight ~ age + (1 | rat), data=dfrats)
\end{lstlisting}
}
\begin{minted}[fontsize=\footnotesize]{r}
fit_2 <- brm(weight ~ age + (1 | rat), data=dfrats)
\end{minted}

Linear model with hierarchical intercept and slope
{\footnotesize
\begin{lstlisting}
fit_3 <- stan_glmer(weight ~ age + (age | rat), data=dfrats)
\end{lstlisting}
}
\begin{minted}[fontsize=\footnotesize]{r}
fit_3 <- brm(weight ~ age + (age | rat), data=dfrats)
\end{minted}

\uncover<2->{
Instead of \texttt{stan\_glm(er)}, use \texttt{brm} to get the Stan code, too.
}
\end{frame}

\begin{frame}[fragile]

{\Large\color{navyblue} Hierarchical example: Rats growth curves}

Leave-one-out cross-validation
{\footnotesize
\begin{lstlisting}
\begin{minted}[fontsize=\footnotesize]{r}
elpd_diff se_diff
hierarchical intercept and slope 0.0 0.0
hierarchical intercept -23.6 9.3
simple linear model -109.6 13.3
\end{lstlisting}
}
\end{minted}


\end{frame}
Expand All @@ -829,14 +841,12 @@
{\Large\color{navyblue} Hierarchical example: Rats growth curves}

Leave-one-out cross-validation
{\footnotesize
\begin{lstlisting}
\begin{minted}[fontsize=\footnotesize]{r}
elpd_diff se_diff
hierarchical intercept and slope 0.0 0.0
hierarchical intercept -23.6 9.3
simple linear model -109.6 13.3
\end{lstlisting}
}
\end{minted}

% Leave-one-out cross-validation stacking model weights
% {\footnotesize
Expand Down Expand Up @@ -1656,4 +1666,5 @@
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-command-extra-options: "-shell-escape"
%%% End:
Binary file modified slides/BDA_lecture_11a.pdf
Binary file not shown.

0 comments on commit 6166424

Please sign in to comment.