-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.Rmd
126 lines (98 loc) · 6.87 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
title: "Linear Mixed Models in Linguistics and Psychology: A Comprehensive Introduction"
author: "Shravan Vasishth, Daniel Schad, Audrey Bürki, Reinhold Kliegl"
date: "`r Sys.Date()`"
knit: "bookdown::render_book"
documentclass: krantz
bibliography: [FreqBook.bib]
biblio-style: apalike
link-citations: yes
colorlinks: yes
lot: false
lof: false
fontsize: 12pt
pdf_document:
extra_dependencies: ["gb4e","tikz"]
site: bookdown::bookdown_site
description: "Linear Mixed Models for Linguistics and Psychology: A Comprehensive Introduction"
url: 'https\://github.com/vasishth/Freq_CogSci'
github-repo: https\://github.com/vasishth/Freq_CogSci
cover-image: images/temporarycover.jpg
output:
bookdown::gitbook:
highlight: tango
---
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(
tidy.opts = list(width.cutoff = 50),
tidy = FALSE
)
options(
htmltools.dir.version = FALSE, formatR.indent = 2,
width = 55, digits = 4, warnPartialMatchAttr = FALSE, warnPartialMatchDollar = FALSE
)
local({
r <- getOption("repos")
if (!length(r) || identical(unname(r["CRAN"]), "@CRAN@")) {
r["CRAN"] <- "https://cran.rstudio.com"
}
options(repos = r)
})
lapply(c("DT", "citr", "formatR", "svglite"), function(pkg) {
if (system.file(package = pkg) == "") install.packages(pkg)
})
```
# Preface {-}
```{r eval=FALSE,fig.align='center', echo=FALSE, include=identical(knitr:::pandoc_to(), 'html'), fig.link='https://www.crcpress.com/product/isbn/9781138700109'}
knitr::include_graphics("images/temporarycover.jpg", dpi = NA)
```
This book (once completed! :) is intended to be a relatively complete introduction to the application of linear mixed models in areas related to linguistics and psychology; throughout, we use the programming language R. Our target audience is cognitive scientists (e.g., linguists and psychologists) who carry out behavioral experiments, and who are interested in learning the foundational ideas behind modern statistical methodology from the ground up and in a principled manner.
Many excellent introductory textbooks already exist that discuss data analysis in great detail. Our book is different from existing books in two respects. First, our main focus is on showing how to analyze data from planned experiments involving repeated measures; this type of experimental data involves complexities that are distinct from the problems one encounters when analyzing observational data. We aim to provide many examples, with different types of dependent measures collected in a variety of experimental paradigms, including
eyetracking data (visual world and reading experiments), response time data (e.g., self-paced reading, picture naming), event-related potential data, ratings (e.g., acceptability ratings), yes/no responses (e.g., speeded grammaticality judgements), and accuracy data. Second, from the very outset, we stress a particular workflow that has as its centerpiece data simulation; we aim to teach a philosophy that involves thinking about the assumed underlying generative process, *even before the data are collected*. By the "generative process", we mean the underlying assumptions about the "process" that produced the data; what exactly this means will presently become clear.
The data analysis approach that we hope to teach through this book (once this book is in its final form) involves a cycle of experiment design analysis and model validation using simulated data.
## Prerequisites {-}
This book assumes high school arithmetic and algebra. Elementary concepts of probability theory are assumed; the sum and the product rules, and the fact that the probabilities of all possible events must sum to 1, are the extent of the knowledge assumed. We also expect that the reader already knows basic constructs in the programming language R [@R-base], such as writing for-loops. For newcomers to R, we will eventually provide a quick introduction in the appendix that covers all the constructs used in the book (this has not yet been done). For those lacking background in R, there are many good online resources on R that they can consult as needed. Examples are: [R for data science](https://r4ds.had.co.nz/), and [Efficient R programming](https://csgillespie.github.io/efficientR/). We also assume that the reader has done some data analysis previously, either in linguistics or psychology. This should not be the first statistics-related book they read. The reader should have encountered concepts like parameters and parameter estimation.
## How to read this book {-}
The chapters in this book are intended to be read in sequence.
to-do: add a Mackay type chapter ordering for different scenarios.
## Online materials {-}
The entire book, including all data and source code, is available online from [https://github.com/vasishth/Freq\_CogSci](https://github.com/vasishth/Freq_CogSci). Solutions to the exercises will be provided (to-do).
The data and some useful functions used in this book can be accessed by installing the R package `lingpsych` available from: https://github.com/vasishth/lingpsych.
The package can be installed by first installing the `devtools` package, and then by typing:
`devtools::install_github("vasishth/lingpsych")`
## Software needed {-}
Before you start, please install
- [R](https://cran.r-project.org/) (and [RStudio](https://www.rstudio.com/) or any other IDE)
- The R packages `MASS`, `dplyr`, `purrr`, `readr`, `extraDistr`, `ggplot2`, `bivariate`,`intoo`,`barsurf`, `SIN`, `kableExtra`, `tidyverse`,`hypr`,`designr`
- These can be installed in the usual way: `install.packages(c("MASS", "dplyr", "purrr", "readr", "extraDistr", "ggplot2","bivariate","intoo","barsurf","SIN",
"kableExtra","tidyverse","hypr","designr","dobson"))`.
In every R session, we'll need to set a seed (this ensures that the random numbers are always the same).
```{r load, cache =FALSE, message=FALSE,include=FALSE}
set.seed(42)
library(MASS)
## be careful to load dplyr after MASS
library(dplyr)
library(purrr)
library(readr)
library(extraDistr)
library(ggplot2)
library(intoo)
library(barsurf)
library(bivariate)
library(SIN)
library(kableExtra)
library(tidyverse)
library(hypr)
library(designr)
library(lme4)
```
## Acknowledgements {-}
We are grateful to the many generations of students at the University of Potsdam, various summer schools at ESSLLI, the LOT winter school, other short courses we have taught at various institutions, and the annual summer school on Statistical Methods for Linguistics and Psychology (SMLP) at the University of Potsdam (vasishth.github.io/smlp). The participants in these courses helped us considerably in improving the material presented here. Special thanks to Anthe Sevenants for his many corrections to the online drafts. We are also grateful to members of Vasishth lab for comments on earlier drafts of this book.
```{block2, type='flushright', html.tag='p'}
Shravan Vasishth,
Daniel Schad,
Audrey Bürki,
Reinhold Kliegl,
Potsdam, Germany
```