307 |
Motivation
308 |
The faintr
package provides convenience function for the evaluation of a model fit, obtained with the brms
package, for a Bayesian regression model for data from a factorial design. If the original model fit used (default) dummy coding of factors, the faintr
package allow extraction of many more meaningful comparisons. For example, it is possible to directly compare the difference between cells which are not comparable by dummy coding, and it is also possible to compare means in sets of cells, so as to recover the outcomes of deviance coding.
309 |
310 |
318 |
Example
319 |
Consider a data set on pitch frequency in the speech of female and male speakers in polite and informal contexts.
320 |
332 |
The cell means of this data set are:
333 |
342 |
A Bayesian regression model for a factorial design with by-subject and by-item random intercepts can be obtained with the brms
package as follows:
343 |
345 |
The brm
function uses dummy coding per default. Look at the estimated coefficients:
346 |
352 |
The reference cell is where gender:F
and context:inf
, so female speakers in informal contexts. The estimated mean for the cell with data from male speakers in informal contexts is retrievable by adding the estimated coefficient genderM
in the output above from the estimated Intercept.
353 |
The faintr
package provides convenience functions to compare different (groups of) cells to each other, based on a model fit like the above. Although the fit of the regression model uses a particular reference cell for dummy-coding, other contrasts of relevance can be retrieved from the posterior samples. For example, if we want to compare two cell diagonally, say, male speakers in informal contexts against female speakers in polite contexts, we can do this:
354 |
365 |
We can also compare the effect of gender female against the grand mean, to retrieve the information normally obtained by deviance coding:
366 |
377 |
To explore all pairwise comparisons between design cells, try:
378 |
405 |
We can also extract the estimated means of each cell:
406 |
414 |
415 |
416 |
417 |
418 |
419 |
427 |
428 |
429 |
430 |
--------------------------------------------------------------------------------
/faintr/man/compare_groups.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/faintr_functions.R
3 | \name{compare_groups}
4 | \alias{compare_groups}
5 | \title{Compare means of two subsets of factorial design cells}
6 | \usage{
7 | compare_groups(model, higher, lower)
8 | }
9 | \arguments{
10 | \item{model}{Model fit from brms package.}
11 | }
12 | \value{
13 | list with posterior samples for each group, and the posterior probability that group 'higher' has a higher estimated coefficient in the posterior samples than the group 'lower'
14 | }
15 | \description{
16 | This function takes a brms model fit for a factorial design and a specification of two groups (subsets of design cells) to compare.
17 | A group is specified as a named list, specifiying the factors and their levels which to include in the group.
18 | It outputs the posterior mean of the 'higher' minus the 'lower' subset of cells, its 95 percent credible interval and the posterior probability that the 'higher' group has a higher mean than the the 'lower' group.
19 | For more information see \code{vignette('faintr_basics')}.
20 | }
21 | \examples{
22 | library(brms)
23 | m = brm(yield ~ N * P * K, npk)
24 | # this compares two single cells in the factorial design
25 | compare_groups(
26 | model = m,
27 | higher = list("N" = "1", "P" = "1", "K" = "1"),
28 | lower = list("N" = "0", "P" = "0", "K" = "1")
29 | )
30 | # this compares the average of N=1 cells to the grand mean
31 | # like in deviance conding
32 | compare_groups(
33 | model = m,
34 | higher = list("N" = "1"),
35 | lower = list()
36 | )
37 |
38 | }
39 | \keyword{brms}
40 | \keyword{design,}
41 | \keyword{factorial}
42 | \keyword{regression,}
43 |
--------------------------------------------------------------------------------
/faintr/man/faintr-package.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/faintr-package.R
3 | \docType{package}
4 | \name{faintr-package}
5 | \alias{faintr-package}
6 | \alias{faintr}
7 | \title{Factorial-design interpreter for Bayesian regression models}
8 | \description{
9 | he \pkg{faintr} package provides convenience functions for testing different hypotheses
10 | about factor level combinations for a Bayesian regression analysis of data from a
11 | factorial-design experiment. It builds on a regression model fitted with the help of
12 | the \pkg{brms} package. For more information see \href{https://michael-franke.github.io/bayes_mixed_regression_tutorial/faintr/doc/faintr_basics.html}{the basic tutorial online}.
13 | }
14 | \details{
15 | The package provides the following functions.
16 | \code{\link{get_factor_information}} extracts information about the factors
17 | and their (reference) levels used in the regression analysis.
18 | \code{\link{post_cells}} gives the estimated means for all
19 | design cells, and a complete pairwise comparison between cells.
20 | \code{\link{compare_groups}} allows the comparison of any pair of
21 | (subsets) of cells.
22 |
23 | For more information see \href{https://michael-franke.github.io/bayes_mixed_regression_tutorial/faintr/doc/faintr_basics.html}{the basic tutorial online}.
24 | }
25 | \seealso{
26 | \code{\link{brm}},
27 | \code{\link{brmsfit}}
28 | }
29 |
--------------------------------------------------------------------------------
/faintr/man/get_factor_information.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/faintr_functions.R
3 | \name{get_factor_information}
4 | \alias{get_factor_information}
5 | \title{Obtaining information about factors in regression model}
6 | \usage{
7 | get_factor_information(model)
8 | }
9 | \arguments{
10 | \item{model}{Model fit from brms package.}
11 | }
12 | \value{
13 | list with names of factors and their levels, including the reference levels (in dummy coding)
14 | }
15 | \description{
16 | For a model for a factorial design, fitted with brms, this function returns information about the factors used, their levels, and the reference levels.
17 | For more information see \code{vignette('faintr_basics')}.
18 | }
19 | \examples{
20 | library(brms)
21 | m = brm(yield ~ N * P * K, npk)
22 | get_factor_information(m)
23 | }
24 | \keyword{brms}
25 | \keyword{design,}
26 | \keyword{factorial}
27 | \keyword{regression,}
28 |
--------------------------------------------------------------------------------
/faintr/man/print.faintCompare.Rd:
--------------------------------------------------------------------------------
1 | % Generated by roxygen2: do not edit by hand
2 | % Please edit documentation in R/faintr_functions.R
3 | \name{print.faintCompare}
4 | \alias{print.faintCompare}
5 | \title{Print comparison object between factor groups}
6 | \usage{
7 | \method{print}{faintCompare}(obj)
8 | }
9 | \arguments{
10 | \item{model}{Model fit from brms package.}
11 | }
12 | \value{
13 | string
14 | }
15 | \description{
16 | Print comparison object between factor groups
17 | }
18 | \examples{
19 | print(model_fit)
20 | }
21 | \keyword{brms}
22 | \keyword{design,}
23 | \keyword{factorial}
24 | \keyword{regression,}
25 |
--------------------------------------------------------------------------------
/faintr/vignettes/faintr_basics.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "Comparing groups of factor levels with the `faintr` package"
3 | output: rmarkdown::html_vignette
4 | vignette: >
5 | %\VignetteIndexEntry{Comparing groups of factor levels with the `faintr` package}
6 | %\VignetteEngine{knitr::rmarkdown}
7 | \usepackage[utf8]{inputenc}
8 | ---
9 |
10 | ```{r setup, include=FALSE, echo = FALSE, message = FALSE}
11 | knitr::opts_chunk$set(echo=TRUE,
12 | warning=FALSE,
13 | message=FALSE,
14 | collapse = TRUE,
15 | cache = TRUE,
16 | dev.args = list(bg = 'transparent'),
17 | fig.align='center',
18 | fig.height = 3,
19 | fig.widht=4)
20 | library(tidyverse)
21 | theme_set(theme_bw() + theme(plot.background=element_blank()) )
22 | ```
23 |
24 | # Motivation
25 |
26 | The `faintr` package provides convenience function for the evaluation of a model fit, obtained with the `brms` package, for a Bayesian regression model for data from a factorial design. If the original model fit used (default) dummy coding of factors, the `faintr` package allow extraction of many more meaningful comparisons. For example, it is possible to directly compare the difference between cells which are not comparable by dummy coding, and it is also possible to compare means in sets of cells, so as to recover the outcomes of deviance coding.
27 |
28 | # Installation
29 |
30 | Install the `faintr` package with `devtools` from GitHub:
31 |
32 | ```{r, eval = F}
33 | devtools::install_github('michael-franke/bayes_mixed_regression_tutorial/faintr',
34 | build_vignettes = TRUE)
35 | library(faintr)
36 | ```
37 |
38 | ```{r, echo = F}
39 | library(faintr)
40 | ```
41 |
42 | # Example
43 |
44 | Consider a data set on pitch frequency in the speech of female and male speakers in polite and informal contexts.
45 |
46 | ```{r, error=FALSE, warning=FALSE, message=FALSE}
47 | library(tidyverse)
48 | politedata = read_csv('https://tinyurl.com/polite-data')
49 | head(politedata)
50 | ```
51 |
52 | The cell means of this data set are:
53 |
54 | ```{r}
55 | politedata %>% group_by(gender, context) %>% summarize(mean_pitch = mean(pitch))
56 | ```
57 |
58 |
59 | A Bayesian regression model for a factorial design with by-subject and by-item random intercepts can be obtained with the `brms` package as follows:
60 |
61 | ```{r, error=FALSE, warning=FALSE, message=FALSE, results="hide"}
62 | library(brms)
63 | m_dummy = brm(pitch ~ gender * context + (1 | subject + sentence), politedata)
64 | ```
65 |
66 | The `brm` function uses dummy coding per default. Look at the estimated coefficients:
67 |
68 | ```{r}
69 | fixef(m_dummy)
70 | ```
71 |
72 | The reference cell is where `gender:F` and `context:inf`, so female speakers in informal contexts. The estimated mean for the cell with data from male speakers in informal contexts is retrievable by adding the estimated coefficient `genderM` in the output above from the estimated Intercept.
73 |
74 | The `faintr` package provides convenience functions to compare different (groups of) cells to each other, based on a model fit like the above. Although the fit of the regression model uses a particular reference cell for dummy-coding, other contrasts of relevance can be retrieved from the posterior samples. For example, if we want to compare two cell diagonally, say, male speakers in informal contexts against female speakers in polite contexts, we can do this:
75 |
76 | ```{r}
77 | compare_groups(
78 | model = m_dummy,
79 | higher = list(gender = "F", context = "pol"),
80 | lower = list(gender = "M", context = "inf")
81 | )
82 | ```
83 |
84 | We can also compare the effect of gender female against the grand mean, to retrieve the information normally obtained by deviance coding:
85 |
86 | ```{r}
87 | compare_groups(
88 | model = m_dummy,
89 | higher = list(gender = "F"),
90 | lower = list()
91 | )
92 | ```
93 |
94 | To explore all pairwise comparisons between design cells, try:
95 |
96 | ```{r}
97 | post_cells(m_dummy)$all_cells_compared
98 | ```
99 |
100 | We can also extract the estimated means of each cell:
101 |
102 | ```{r}
103 | post_cells(m_dummy)$cell_summary
104 | ```
105 |
106 |
--------------------------------------------------------------------------------
/text/bmr_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michael-franke/bayes_mixed_regression_tutorial/74178c3076e00e792d2d04f0697ec550e6ce5f0c/text/bmr_tutorial.pdf
--------------------------------------------------------------------------------
/text/mfcommands.sty:
--------------------------------------------------------------------------------
1 | \ProvidesPackage{mycommands}
2 |
3 | % Math --------------------
4 | \newcommand{\set}[1]{\left\{#1\right\}}
5 | \newcommand{\tuple}[1]{\left \langle #1\right\rangle}
6 | \newcommand{\card}[1]{\left \lvert \, #1 \, \right\rvert}
7 | \newcommand{\abs}[1]{\lvert #1 \rvert}
8 | \newcommand{\setbar}{\ensuremath{\thinspace \mid \thinspace}}
9 | \newcommand{\probbar}{\ensuremath{\mid}}
10 | % \DeclareMathOperator*{\argmax}{arg\,max}
11 | % \DeclareMathOperator*{\argmin}{arg\,min}
12 | \newcommand{\df}{\rightarrow}
13 | \newcommand{\es}{\emptyset}
14 | \newcommand{\den}[1]{\left [\! \left [ #1 \right ]\! \right]}
15 | % \newcommand{\den}[1]{\left \llbracket #1 \right \rrbracket} % this would use fourier package which makes 'cases' environment bad
16 | \newcommand{\no}{\noindent}
17 | \newcommand{\hin}{"$\Rightarrow$" }
18 | \newcommand{\rueck}{"$\Leftarrow$" }
19 | \newcommand{\exs}{\vspace{.15cm}}
20 | \newcommand{\pow}[1]{\ensuremath{\mathcal{P}(#1)}} % Powerset
21 | \newcommand{\restr}{{\restriction}}
22 | \newcommand{\implicates}{\ensuremath{\leadsto}} % arrow for
23 | % implicatures in examples
24 | \newcommand{\update}[2]{\ensuremath{#1[#2]}}
25 | \newcommand{\myts}{\ensuremath{\thinspace}}
26 | \newcommand{\mycolon}{\ensuremath{\thinspace \colon \thinspace}}
27 | \newcommand{\mydot}{\ensuremath{\thinspace . \thinspace}}
28 |
29 |
30 | % \makeatletter
31 | % \newcommand{\prob}{\@ifstar
32 | % \simpleprob%
33 | % \condprob%
34 | % }
35 | % \def\simpleprob(#1){\ensuremath{\Pr(#1)}}
36 | % \def\condprob(#1|#2){\ensuremath{\Pr(#1 \,|\, #2)}}
37 | % \makeatother
38 |
39 | % General Text Markup--------------------
40 | \newcommand{\runex}[1]{\begin{center}#1\end{center}}
41 | \newcommand{\mydef}[1]{\textsc{#1}} % definitions
42 | \newcommand{\markdef}[1]{\textsc{#1}} % definitions; alternative
43 | \newcommand{\myment}[1]{\emph{#1}} % first mentions
44 | \newcommand{\myword}[1]{\textbf{\texttt{#1}}} % refering to the word
45 | \newcommand{\myemph}[1]{\emph{#1}} % emphasis
46 | \newenvironment{exnonum}{
47 | \begin{list}{}{
48 | \setlength{\leftmargin}{2.5em}
49 | \setlength{\rightmargin}{2.5em}
50 | %\setlength{\itemindent}{-1.5em}
51 | }
52 | }{
53 | \end{list}
54 | }
55 |
56 |
57 | % Slanted Fractions
58 | \newcommand{\myslantfrac}[2]{\msf{#1}{#2}}
59 | \newcommand{\msf}[2]{\ensuremath{\nicefrac{#1}{#2}}}
60 | \newcommand{\msftext}[2]{\nicefrac{#1}{#2}}
61 |
62 |
63 | % Symbols for Conditionals
64 | \newcommand{\cond}{\ensuremath{>}}
65 | \newcommand{\bicond}{\ensuremath{\Leftrightarrow}}
66 | \newcommand{\strcondWill}{\ensuremath{\boxRight}}
67 | \newcommand{\strcondMight}{\ensuremath{\DiamondRight}}
68 |
69 | % Signaling Games & IBR
70 | \newcommand{\sen}{\ensuremath{S}\xspace} % Sender variable
71 | \newcommand{\mysen}[1]{\ensuremath{\sen^{#1}}} % Sender of type XYZ
72 | \newcommand{\rec}{\ensuremath{R}\xspace} % Receiver variable
73 | \newcommand{\myrec}[1]{\ensuremath{\rec_{#1}}} % Receiver of type XYZ
74 | \newcommand{\States}{\ensuremath{T}\xspace} % Set of States
75 | \newcommand{\state}{\ensuremath{t}\xspace} % single states
76 | \newcommand{\mystate}[1]{\ensuremath{\state_{\text{#1}}}\xspace} %meaningful states
77 | \newcommand{\Messgs}{\ensuremath{M}\xspace} % Set of Messages
78 | \newcommand{\messg}{\ensuremath{m}\xspace} % single messages
79 | \newcommand{\mymessg}[1]{\ensuremath{\messg_{\text{#1}}}\xspace} %meaningful messages
80 | \newcommand{\cost}{\ensuremath\operatorname{C}} % cost function
81 | \newcommand{\Acts}{\ensuremath{A}\xspace} % Set of R-actions
82 | \newcommand{\act}{\ensuremath{a}\xspace} % single action
83 | \newcommand{\myact}[1]{\ensuremath{\act_{\text{#1}}}\xspace} %meaningful
84 | \newcommand{\Worlds}{\ensuremath{W}} % Worlds
85 | \newcommand{\world}{\ensuremath{w}} % single world
86 | \newcommand{\myworld}[1]{\ensuremath{\world_{\text{#1}}}} %named world
87 | \newcommand{\util}{\ensuremath{\operatorname{U}}} % Utility function
88 | \newcommand{\Util}{\ensuremath{\operatorname{U}}} % Utility function
89 | \newcommand{\utils}{\ensuremath{\operatorname{U}}} % Utility function
90 | \newcommand{\Utils}{\ensuremath{\operatorname{U}}} % Utility function
91 | \newcommand{\RealUtil}{\ensuremath{\operatorname{V}}} % material payoffs
92 | \newcommand{\Sstrat}{\ensuremath{\sigma}} % Behav/Probab Sender strategy
93 | \newcommand{\Sstrats}{\ensuremath{\mathcal{S}}} % Set of S-strategies
94 | \newcommand{\Spure}{\ensuremath{s}} % Pure sender strategy
95 | \newcommand{\Spures}{\ensuremath{\mathsf{S}}} % Set of pure sen strategies
96 | \newcommand{\Smixed}{\ensuremath{\tilde{s}}} % Mixed sender strategy
97 | \newcommand{\Smixeds}{\ensuremath{\Delta(\Messgs^\States)}}
98 | \newcommand{\SpuresW}{\ensuremath{\mathsf{S}}}
99 | \newcommand{\SpuresS}{\ensuremath{\mathsf{S}^{{\mathrm{S}}}}}
100 | \newcommand{\Rstrat}{\ensuremath{\rho}} % Behav/Probab Receiver strategy
101 | \newcommand{\Rstrats}{\ensuremath{\mathcal{R}}} % Set of R-Strategies
102 | \newcommand{\Rpure}{\ensuremath{r}} % Pure receiver strategy
103 | \newcommand{\Rpures}{\ensuremath{\mathsf{R}}} % Set of pure rec strategies
104 | \newcommand{\Rmixed}{\ensuremath{\tilde{r}}} % Mixed receiver strategy
105 | \newcommand{\Rmixeds}{\ensuremath{\Delta(\Acts^\Messgs)}}
106 | \newcommand{\RpuresW}{\ensuremath{\mathsf{R}}}
107 | \newcommand{\RpuresS}{\ensuremath{\mathsf{R}^{\mathrm{S}}}}
108 | \newcommand{\PureBR}{\ensuremath{\operatorname{BR}}} % Set of pure best responses
109 | \newcommand{\ProbBR}{\ensuremath{\operatorname{BR_{Prob}}}} % Set of mixed best responses
110 | \newcommand{\bel}{\ensuremath{\pi}}
111 | \newcommand{\Bels}{\ensuremath{\Pi}}
112 | \newcommand{\Sbel}{\ensuremath{\pi_{\sen}}}
113 | \newcommand{\Sbels}{\ensuremath{\Pi_{\sen}}}
114 | \newcommand{\Rbel}{\ensuremath{\pi_{\rec}}}
115 | \newcommand{\Rbels}{\ensuremath{\Pi_{\rec}}}
116 | \newcommand{\EU}{\ensuremath{\operatorname{EU}}} % Expected Utility
117 | \newcommand{\EV}{\ensuremath{\operatorname{EV}}} % Expected Response Utility
118 | \newcommand{\BR}{\ensuremath{\operatorname{BR}}} % Best Response
119 | \newcommand{\QR}{\ensuremath{\operatorname{QR}}} % Quantal Response
120 | \newcommand{\WBR}{\ensuremath{\text{{\relsize{-1}W}BR}}} % Weak Best Response
121 | \newcommand{\SBR}{\ensuremath{\text{{\relsize{-1}W}BR}}} % Strong Best Response
122 | \newcommand{\interpr}{\ensuremath{\delta}} % Interpretation strategy
123 |
124 | % OT Stuff
125 | \newcommand{\Gen}{\ensuremath{\operatorname{Gen}}} % Generator
126 | \newcommand{\Eval}{\ensuremath{\operatorname{Eval}}} % Evaluator
127 | \newcommand{\Con}{\ensuremath{\operatorname{Con}}} % Constraints
128 | \newcommand{\metsuc}{\ensuremath{\succ}} % Symbol for BiOT metric
129 | \newcommand{\metsuceq}{\ensuremath{\succeq}} % Symbol for BiOT metric
130 | \newcommand{\Go}[1]{\operatorname{Pool}_{#1}}
131 | \newcommand{\Oo}[1]{\operatorname{Opt}_{#1}}
132 | \newcommand{\Bo}[1]{\operatorname{Blo}_{#1}}
133 | \newcommand{\Gr}[1]{\operatorname{GAM^{\rho}}_{#1}}
134 | \newcommand{\Or}[1]{\operatorname{OPT^{\rho}}_{#1}}
135 | \newcommand{\Br}[1]{\operatorname{BLO^{\rho}}_{#1}}
136 |
137 | % Abbreviations/Acronyms:
138 | \newcommand{\acro}[1]{\textsc{#1}\xspace}
139 | \newcommand{\acros}[1]{\textsc{#1}{\relsize{-1}s}\xspace}
140 | \newcommand{\bc}{\acro{bc}} % Biscuit Conditional(s)
141 | \newcommand{\bcs}{\acros{bc}}
142 | \newcommand{\cbc}{\acro{cbc}} % Counterfactual BCs
143 | \newcommand{\cbcs}{\acros{cbc}}
144 | \newcommand{\ibr}{\acro{ibr}} % IBR model
145 | \newcommand{\iqr}{\acro{iqr}} % IQR model
146 | \newcommand{\rsa}{\acro{rsa}} % RSA model
147 | \newcommand{\ot}{\acro{ot}} % BiOT
148 | \newcommand{\biot}{\acro{b{\relsize{-1}i}ot}} % BiOT
149 | \newcommand{\tom}{\acro{t{\relsize{-1}o}m}} % ToM
150 | \newcommand{\fc}{\acro{fc}} % Free Choice
151 | \newcommand{\cp}{\acro{cp}} % Conditional Perfection
152 | \newcommand{\uc}{\acro{uc}} % Unconditional Readings
153 | \newcommand{\pbe}{\acro{pbe}} % Perfect Bayesian Equil.
154 | \newcommand{\pbes}{\acros{pbe}}
155 | \newcommand{\forind}{\acro{fi}} % forward induction
156 | \newcommand{\tcp}{\acro{tcp}} % truth ceteris paribus
157 | \newcommand{\cmr}{\acro{cmr}} % credible message rationalizability
158 | \newcommand{\cm}{\acro{cm}} % credible message (profile) (Rabin)
159 | \newcommand{\condition}[2]{\acro{#1}{#2}} % conditions
160 | \newcommand{\br}{\acro{br}} % best response (property)
161 | \newcommand{\wbr}{\acro{{\relsize{-1}w}br}} % weak best response (property)
162 | \newcommand{\sbr}{\acro{{\relsize{-1}s}br}} % strong best response (property)
163 | \newcommand{\curb}{\acro{curb}} % curb sets
164 | \newcommand{\gtp}{\acro{gtp}} % game theoretic pragmatics
165 | \newcommand{\sda}{\acro{sda}} % simplification of disjunctive antecedents
166 | \newcommand{\decprob}{\ensuremath{\mathcal{D}}}
167 | \newcommand{\ques}{\ensuremath{\mathfrak{Q}}}
168 | \newcommand{\vsi}{\acro{vsi}}
169 | \newcommand{\evsi}{\acro{evsi}}
170 | \newcommand{\uv}{\acro{uv}}
171 | \newcommand{\qud}{\acro{qud}}
172 | \newcommand{\NE}{\acro{ne}}
173 | \newcommand{\NEs}{\acros{ne}}
174 | \newcommand{\SNE}{\acro{sne}}
175 | \newcommand{\SNEs}{\acros{sne}}
176 | \newcommand{\SG}{\acro{sg}}
177 | \newcommand{\SGs}{\acros{sg}}
178 | \newcommand{\KO}{\textsc{ko\relsize{-1}bs}} % Kennedy's observation
179 | \newcommand{\EVP}{\acro{evp}} % extreme-value principle
180 | \newcommand{\illc}{\acro{illc}}
181 |
182 | % Evolution
183 | \newcommand{\EGT}{\acro{egt}}
184 | \newcommand{\ESS}{\acro{ess}}
185 | \newcommand{\ESSs}{\acros{ess}}
186 | \newcommand{\NSS}{\acro{nss}}
187 | \newcommand{\NSSs}{\acros{nss}}
188 | \newcommand{\sigsys}{\textsc{SigSys}\xspace} % signaling system
189 | \newcommand{\sigsyss}{\textsc{SigSys{\relsize{-1}s}}\xspace} % signaling system Plural
190 |
191 | \newcommand{\fin}{\rule{0mm}{1mm}\hfill{\rule{1.5cm}{0.2pt}}}
192 |
193 | %Properly typeset tilde for URLs
194 | \def\urltilde{\kern -.15em\lower .7ex\hbox{\~{}}\kern .04em}
195 |
196 |
197 | % Beamer footnote for references:
198 | \newcommand{\beamfn}[1]{
199 | \vfill
200 | \begin{footnotesize}
201 | \leftskip 0.1in
202 | \parindent -0.1in
203 | \hspace{-0.3cm}\rule{2cm}{0.01cm}\\ \vspace{-0.15cm}
204 | #1
205 | \end{footnotesize}
206 | }
207 |
208 | \newcommand{\myvec}[1]{\ensuremath{\mathbf{#1}}}
209 | \newcommand{\transpose}[1]{\ensuremath{\operatorname{T}(#1)}}
210 | \newcommand{\normalize}[1]{\ensuremath{\operatorname{N}(#1)}}
211 |
212 | \newcommand{\dn}[1]{\draftnote{#1}}
213 | \newcommand{\fn}[1]{\footnote{#1}}
214 |
215 | \newcommand{\stateunmarked}{\ensuremath{\state}\xspace}
216 | \newcommand{\statemarked}{\ensuremath{\state^*}\xspace}
217 | \newcommand{\messgunmarked}{\ensuremath{\messg}\xspace}
218 | \newcommand{\messgmarked}{\ensuremath{\messg^*}\xspace}
219 | \newcommand{\actunmarked}{\ensuremath{\act}\xspace}
220 | \newcommand{\actmarked}{\ensuremath{\act^*}\xspace}
221 |
222 | \newcommand{\sunmarked}{\ensuremath{\state}\xspace}
223 | \newcommand{\smarked}{\ensuremath{\state^*}\xspace}
224 | \newcommand{\munmarked}{\ensuremath{\messg}\xspace}
225 | \newcommand{\mmarked}{\ensuremath{\messg^*}\xspace}
226 | \newcommand{\aunmarked}{\ensuremath{\act}\xspace}
227 | \newcommand{\amarked}{\ensuremath{\act^*}\xspace}
228 |
229 | \newcommand{\ssome}{\mystate{\ensuremath{\exists\neg\forall}}}
230 | \newcommand{\sall}{\mystate{\ensuremath{\forall}}}
231 | \newcommand{\msome}{\mymessg{some}}
232 | \newcommand{\mall}{\mymessg{all}}
233 | \newcommand{\asome}{\myact{\ensuremath{\exists\neg\forall}}}
234 | \newcommand{\aall}{\myact{\ensuremath{\forall}}}
235 |
236 | % for repeating examples with gb4e
237 |
238 | \newcounter{myexememory}
239 | \newenvironment{exer}[1]
240 | {
241 | \setcounter{myexememory}{\value{exx}}
242 | \setcounter{exx}{\getrefnumber{#1}}
243 | \addtocounter{exx}{-1}
244 | \begin{exe}
245 | }
246 | {
247 | \end{exe}
248 | \setcounter{exx}{\value{myexememory}}
249 | }
250 |
251 | \newenvironment{nakedlist}{
252 | \begin{list}{\quad}{}
253 | }
254 | {
255 | \end{list}
256 | }
257 |
258 | \DefineNamedColor{named}{mycol}{cmyk}{0.6,0.6,0,0}
259 | \DefineNamedColor{named}{mygray}{cmyk}{0.05,0.05,0.05,0.05}
260 | \DefineNamedColor{named}{mygraylight}{cmyk}{0.017,0.017,0.017,0.017}
261 | \DefineNamedColor{named}{mycol2}{cmyk}{0.8,0,0.8,0.2}
262 | \definecolor{Red}{RGB}{178,34,34}
263 | \newcommand{\mf}[1]{\textcolor{Red}{[#1]}}
264 | \newcommand{\mycolh}[1]{{\textcolor{mycol2}{#1}}}
265 | \newcommand{\mymark}[1]{{\color{mycol}{#1}}}
266 |
267 | \DeclareMathOperator{\expo}{exp}
268 | \DeclareMathOperator*{\argmin}{arg\,min}
269 | \DeclareMathOperator*{\argmax}{arg\,max}
270 |
271 |
272 |
273 |
274 | % \usepackage{calc}
275 | \newsavebox\CBox
276 | \newcommand\msout[2][0.5pt]{%
277 | \ifmmode\sbox\CBox{$#2$}\else\sbox\CBox{#2}\fi%
278 | \makebox[0pt][l]{\usebox\CBox}%
279 | \rule[0.5\ht\CBox-#1/2]{\wd\CBox}{#1}}
280 |
281 | \newcommand{\greensquare}{\raisebox{1.5pt}{\textcolor{Green}{\Large{\ensuremath{\blacksquare}}}}}
282 | \newcommand{\bluecircle}{\textcolor{blue}{\Huge{\ensuremath{\bullet}}}}
283 | \newcommand{\greencircle}{\textcolor{Green}{\Huge{\ensuremath{\bullet}}}}
284 |
285 | \newcommand{\greensquareS}{\raisebox{1.5pt}{\textcolor{Green}{\normalsize{\ensuremath{\blacksquare}}}}}
286 | \newcommand{\greensquareSS}{\raisebox{1.5pt}{\textcolor{Green}{\footnotesize{\ensuremath{\blacksquare}}}}}
287 | \newcommand{\bluecircleS}{\textcolor{blue}{\Large{\ensuremath{\bullet}}}}
288 | \newcommand{\greencircleS}{\textcolor{Green}{\Large{\ensuremath{\bullet}}}}
289 |
290 | \newcommand{\soc}{\ensuremath{\theta}\xspace}
--------------------------------------------------------------------------------
/text/mfenvironments.sty:
--------------------------------------------------------------------------------
1 | \NeedsTeXFormat{LaTeX2e}
2 | \ProvidesPackage{myenvironments}[2010/03/29 Personal Environments]
3 |
4 |
5 | \newtheoremstyle{Satz}
6 | {} %Space above
7 | {1em} %Space below
8 | {\normalfont} %Body font
9 | {} %Indent amount (empty = no indent,
10 | %\parindent = para indent)
11 | {\normalfont} %Thm head font
12 | {.} %Punctuation after thm head
13 | {.8em} %Space after thm head: " " = normal interword
14 | %space; \newline = linebreak
15 | {\bfseries\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}}
16 | %Thm head spec (can be left empty, meaning
17 | %`normal')
18 |
19 | \theoremstyle{Satz}
20 | \newtheorem{theorem}{Theorem}
21 | \newtheorem{lemma}[theorem]{Lemma}
22 | \newtheorem{definition}[theorem]{Definition}
23 | \newtheorem{proposition}[theorem]{Proposition}
24 | \newtheorem{fact}[theorem]{Fact}
25 | \newtheorem{claim}[theorem]{Claim}
26 | \newtheorem{remark}[theorem]{Remark}
27 | \newtheorem{exercise}{Exercise}
28 | \newtheorem{problem}{Problem}
29 | \newtheorem{corollary}[theorem]{Corollary}
30 | \newtheorem{example}[theorem]{Example}
31 |
32 | \newtheoremstyle{Bsp}
33 | {} %Space above
34 | {1em} %Space below
35 | {\itshape} %Body font
36 | {} %Indent amount (empty = no indent,
37 | %\parindent = para indent)
38 | {\normalfont} %Thm head font
39 | {.} %Punctuation after thm head
40 | {.8em} %Space after thm head: " " = normal interword
41 | %space; \newline = linebreak
42 | {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}}
43 | %Thm head spec (can be left empty, meaning
44 | %`normal')
45 | \theoremstyle{Bsp}
46 | % \newtheorem{example}[theorem]{Example}
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/text/mfpackages.sty:
--------------------------------------------------------------------------------
1 | \NeedsTeXFormat{LaTeX2e}
2 | \ProvidesPackage{mfpackages}[2010/03/29 Personalized Packages Michael Franke]
3 |
4 | \newif\ifpala
5 | \palafalse
6 |
7 | \newif\ifnobib
8 | \nobibtrue
9 |
10 | \newif\ifnosubcap
11 | \nosubcaptrue
12 |
13 | \newif\ifnohyper
14 | \nohypertrue
15 |
16 | \newif\ifnoams
17 | \noamstrue
18 |
19 | \newif\ifnotik
20 | \notiktrue
21 |
22 | \newif\ifnograph
23 | \nographtrue
24 |
25 | \newif\ifnoGB
26 | \noGBtrue
27 |
28 | \DeclareOption{palatino}{
29 | \palatrue
30 | }
31 |
32 | \DeclareOption{nobiblatex}{
33 | \nobibfalse
34 | }
35 |
36 | \DeclareOption{nosubcaption}{
37 | \nosubcapfalse
38 | }
39 |
40 | \DeclareOption{nohyperref}{
41 | \nohyperfalse
42 | }
43 |
44 | \DeclareOption{noamsthm}{
45 | \noamsfalse
46 | }
47 |
48 | \DeclareOption{notikz}{
49 | \notikfalse
50 | }
51 |
52 | \DeclareOption{nographicx}{
53 | \nographfalse
54 | }
55 |
56 | \DeclareOption{nogb4e}{
57 | \noGBfalse
58 | }
59 |
60 | \ProcessOptions\relax
61 |
62 | \RequirePackage{amsmath} % Formeln
63 | \RequirePackage{amsfonts} % Fonts for Formulas
64 | \RequirePackage{amssymb}
65 |
66 | \ifnoams
67 | \RequirePackage{amsthm}
68 | \fi
69 |
70 | \RequirePackage{dsfont} % double stroke fonts
71 |
72 | \ifnograph
73 | \RequirePackage[final]{graphicx}
74 | \fi
75 | \RequirePackage{booktabs}
76 | \RequirePackage{enumerate}
77 | \RequirePackage{paralist}
78 |
79 | \RequirePackage[all]{xy}
80 | \RequirePackage{url}
81 |
82 | \ifnoGB
83 | \RequirePackage{gb4e}
84 | \noautomath
85 | \renewcommand{\eachwordtwo}{\relsize{-1}} % format translation in glosses
86 | % \renewcommand{\trans}{\vskip.15\baselineskip\relsize{-1}}
87 | \renewcommand{\trans}{\vskip.15\baselineskip}
88 | \fi
89 |
90 |
91 |
92 | % \RequirePackage{fourier} % double brackets for \den{}
93 |
94 | \RequirePackage{lipsum}
95 | \RequirePackage{txfonts} % for strict implication symbols
96 | \RequirePackage{soul}
97 | \RequirePackage{relsize} % provides command \relsize{+/-x} for relative
98 | % font size changes
99 | \RequirePackage[ngerman,english]{babel}
100 | \RequirePackage[utf8]{inputenc}
101 | \RequirePackage[T1]{fontenc}
102 | % \RequirePackage{subfig}
103 | \RequirePackage{xypic}
104 | \RequirePackage{multicol}
105 |
106 |
107 | \ifnosubcap
108 | \RequirePackage{subcaption}
109 | \fi
110 |
111 | \ifnotik
112 | \RequirePackage{tikz}
113 | \usetikzlibrary{arrows,shapes,automata,backgrounds,petri,fit,decorations.pathmorphing}
114 | \fi
115 |
116 | \RequirePackage{units}
117 |
118 | \RequirePackage{refcount} % for proper repetition of gb4e examples
119 |
120 | \RequirePackage{dialogue}
121 |
122 | % \RequirePackage{attrib} % for right-aligned references at the end of
123 | % % quotes; part of Frankenstein bundle, but
124 | % \renewcommand\PreTrib {} % overwrite these commands, from attrib.sty
125 | % \renewcommand\PostTrib {} % to suppress additional brackets around
126 | % % attributions
127 |
128 | \RequirePackage{setspace}
129 |
130 | \RequirePackage[colorinlistoftodos,color=lightgray!20,bordercolor=blue,textsize=footnotesize]{todonotes}
131 |
132 | \RequirePackage{xspace} % for \xspace in definition of acronyms etc.
133 |
134 | \ifpala
135 | \RequirePackage[sc,osf]{mathpazo}
136 | \linespread{1.12}
137 | \fi
138 |
139 | \ifnobib
140 | \RequirePackage[style=authoryear-comp, % Citation marks as [Jef65]
141 | natbib=true, % Natbib-style cite macros \citeauthor &c.
142 | hyperref=true, % Cites in pdf are links to bib
143 | % (hyperref conf.)
144 | maxnames=3, % truncate name lists if more than 2
145 | % names appear
146 | doi=true, % no doi's
147 | url=true, % no url's
148 | sortcites=false, % do NOT sort cites in the style of the
149 | % bibliography
150 | %backref=true % insert backrefs in reference section
151 | ]{biblatex}
152 | \fi
153 |
154 |
155 |
156 |
157 | \ifnohyper
158 | \RequirePackage[final, % override "draft" which means "no nothing"
159 | colorlinks, % rather than outlining them in boxes
160 | linkcolor=black, % override truly awful colour choices
161 | citecolor=black, % (ditto)
162 | urlcolor=black, % (ditto)
163 | plainpages=false, % to overcome complaints with multiple
164 | pdfpagelabels, % multiple page 1-s due to preface
165 | hypertexnames=false % solves warning, but interferes with
166 | % index and \autoref apparently
167 | ]{hyperref}
168 | \fi
--------------------------------------------------------------------------------
/text/pics/basic_data_plot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michael-franke/bayes_mixed_regression_tutorial/74178c3076e00e792d2d04f0697ec550e6ce5f0c/text/pics/basic_data_plot.pdf
--------------------------------------------------------------------------------
/text/pics/posterior_density_FE.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michael-franke/bayes_mixed_regression_tutorial/74178c3076e00e792d2d04f0697ec550e6ce5f0c/text/pics/posterior_density_FE.pdf
--------------------------------------------------------------------------------
/text/pics/posterior_density_cell_means.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michael-franke/bayes_mixed_regression_tutorial/74178c3076e00e792d2d04f0697ec550e6ce5f0c/text/pics/posterior_density_cell_means.pdf
--------------------------------------------------------------------------------
/text/pics/pp_check_FE.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michael-franke/bayes_mixed_regression_tutorial/74178c3076e00e792d2d04f0697ec550e6ce5f0c/text/pics/pp_check_FE.pdf
--------------------------------------------------------------------------------
/text/pics/pp_check_FE_noGender.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michael-franke/bayes_mixed_regression_tutorial/74178c3076e00e792d2d04f0697ec550e6ce5f0c/text/pics/pp_check_FE_noGender.pdf
--------------------------------------------------------------------------------
/text/pics/pp_checks_plot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/michael-franke/bayes_mixed_regression_tutorial/74178c3076e00e792d2d04f0697ec550e6ce5f0c/text/pics/pp_checks_plot.pdf
--------------------------------------------------------------------------------
/text/pics/prior_like_post.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |