• Linear Mixed Models in Linguistics and Psychology
  • Preface
    • 0.1 Prerequisites
    • 0.2 How to read this book
    • 0.3 Online materials
    • 0.4 Software needed
    • 0.5 Acknowledgements
  • About the Authors
  • I Foundational ideas
  • 1 Some important facts about distributions
    • 1.1 Discrete random variables: An example using the Binomial distribution
      • 1.1.1 The mean and variance of the Binomial distribution
      • 1.1.2 What information does a probability distribution provide?
    • 1.2 Continuous random variables: An example using the Normal distribution
    • 1.3 Other common distributions
      • 1.3.1 The t-distribution
      • 1.3.2 The Gamma distribution
      • 1.3.3 The Exponential distribution
    • 1.4 Bivariate and multivariate distributions
      • 1.4.1 Example 1: Discrete bivariate distributions
      • 1.4.2 Example 2: Continuous bivariate distributions
      • 1.4.3 Generate simulated bivariate (multivariate) data
    • 1.5 Likelihood and maximum likelihood estimation
      • 1.5.1 The importance of the MLE
    • 1.6 Summary of useful R functions relating to univariate distributions
    • 1.7 Summary of random variable theory
    • 1.8 Further reading
    • 1.9 Exercises
      • 1.9.1 Practice using the pnorm function
      • 1.9.2 Practice using the qnorm function
      • 1.9.3 Maximum likelihood estimation 1
      • 1.9.4 Maximum likelihood estimation 2
      • 1.9.5 Generating bivariate data
      • 1.9.6 Generating multivariate data
  • 2 Hypothetical repeated sampling and the t-test
    • 2.1 Some terminology surrounding typical experiment designs in linguistics and psychology
    • 2.2 The central limit theorem using simulation
    • 2.3 Three examples of the sampling distribution
    • 2.4 The confidence interval, and what it’s good for
    • 2.5 Hypothesis testing: The one sample t-test
      • 2.5.1 The one-sample t-test
      • 2.5.2 Type I, II error, and power
      • 2.5.3 How to compute power for the one-sample t-test
      • 2.5.4 The p-value
      • 2.5.5 Type M and S error in the face of low power
      • 2.5.6 Searching for significance
    • 2.6 The two-sample t-test vs. the paired t-test
      • 2.6.1 Common mistakes involving the t-test
    • 2.7 Exercises
      • 2.7.1 Practice using qt
      • 2.7.2 Computing the p-value
      • 2.7.3 Computing the t-value
      • 2.7.4 Type I and II error
      • 2.7.5 Practice with the paired t-test
  • 3 Linear models and linear mixed models
    • 3.1 From the t-test to the linear (mixed) model
    • 3.2 Sum coding
    • 3.3 Checking model assumptions
    • 3.4 From the paired t-test to the linear mixed model
    • 3.5 Linear mixed models
      • 3.5.1 Model type 1: Varying intercepts
      • 3.5.2 The formal statement of the varying intercepts model
      • 3.5.3 Model type 2: Varying intercepts and slopes, without a correlation
      • 3.5.4 Model type 3: Varying intercepts and varying slopes, with correlation
    • 3.6 Shrinkage in linear mixed models
    • 3.7 Summary
    • 3.8 Exercises
      • 3.8.1 By-subjects t-test
      • 3.8.2 Fitting a linear mixed model
      • 3.8.3 t-test vs. linear mixed model
      • 3.8.4 Power calculation using power.t.test
      • 3.8.5 Residuals
      • 3.8.6 Understanding contrast coding
      • 3.8.7 Understanding the fixed-effects output
      • 3.8.8 Understanding the null hypothesis test
  • 4 Hypothesis testing using the likelihood ratio test
    • 4.1 The likelihood ratio test: The theory
    • 4.2 A practical example using simulated data
    • 4.3 A real-life example: The English relative clause data
    • 4.4 Exercises
      • 4.4.1 Chinese relative clauses
      • 4.4.2 Agreement attraction in comprehension
      • 4.4.3 The grammaticality illusion
  • 5 Linear modeling theory
    • 5.1 A quick review of some basic concepts in matrix algebra
      • 5.1.1 Matrix addition, subtraction, and multiplication
      • 5.1.2 Diagonal matrix and identity matrix
      • 5.1.3 Powers of matrices
      • 5.1.4 Inverse of a matrix
      • 5.1.5 Linear independence, and rank
    • 5.2 The essentials of linear modeling theory
      • 5.2.1 Least squares estimation: Geometric argument
      • 5.2.2 The expectation and variance of the parameters beta
      • 5.2.3 Hypothesis testing using Analysis of variance (ANOVA)
      • 5.2.4 Some further important topics in linear modeling
      • 5.2.5 Generalized linear models
    • 5.3 Exercises
      • 5.3.1 Estimating the parameters in a linear model
      • 5.3.2 Using ANOVA to carry out hypothesis testing
      • 5.3.3 Computing ANOVA by hand
      • 5.3.4 Generalized linear (mixed) model
  • 6 Contrast coding
    • 6.1 Basic concepts illustrated using a two-level factor
      • 6.1.1 Default contrast coding: Treatment contrasts
      • 6.1.2 Defining hypotheses
      • 6.1.3 Sum contrasts
      • 6.1.4 Cell means parameterization and posterior comparisons
    • 6.2 The hypothesis matrix illustrated with a three-level factor
      • 6.2.1 Sum contrasts
      • 6.2.2 The hypothesis matrix
      • 6.2.3 Generating contrasts: The hypr package
    • 6.3 Further examples of contrasts illustrated with a factor with four levels
      • 6.3.1 Repeated contrasts
      • 6.3.2 Contrasts in linear regression analysis: The design or model matrix
      • 6.3.3 Polynomial contrasts
    • 6.4 What makes a good set of contrasts?
      • 6.4.1 Centered contrasts
      • 6.4.2 Orthogonal contrasts
      • 6.4.3 The role of the intercept in non-centered contrasts
    • 6.5 Summary
  • 7 Contrast coding for designs with two predictor variables
    • 7.1 Contrast coding in a factorial 2 x 2 design
      • 7.1.1 The difference between an ANOVA and a multiple regression
      • 7.1.2 Nested effects
      • 7.1.3 Interactions between contrasts
    • 7.2 One factor and one covariate
      • 7.2.1 Estimating a group-difference and controlling for a covariate
      • 7.2.2 Estimating differences in slopes
    • 7.3 Interactions in generalized linear models (with non-linear link functions)
    • 7.4 Summary
  • 8 Using simulation to understand your model
    • 8.1 A reminder: The maximal linear mixed model
    • 8.2 Obtain estimates from a previous study
    • 8.3 Decide on a range of plausible values of the effect size
    • 8.4 Extract parameter estimates
    • 8.5 Define a function for generating data
      • 8.5.1 Generate a Latin-square design
      • 8.5.2 Generate data row-by-row
    • 8.6 Repeated generation of data to compute power
    • 8.7 What you can now do
    • 8.8 Using the package designr to simulate data and compute power
      • 8.8.1 Simulating data with two conditions
      • 8.8.2 Simulating data in factorial designs
    • 8.9 Exercises
      • 8.9.1 Drawing a power curve given a range of effect sizes
      • 8.9.2 Power and log-transformation
      • 8.9.3 Evaluating models by generating simulated data
      • 8.9.4 Using simulation to check parameter recovery
      • 8.9.5 Sample size calculations using simulation
  • 9 Understanding the multiple comparisons problem
  • 10 Model selection
  • References
  • Published with bookdown

Linear Mixed Models in Linguistics and Psychology: A Comprehensive Introduction

Chapter 9 Understanding the multiple comparisons problem

to-do

library(knitr)
library(kableExtra)
library(tidyverse)
library(brms)
library(bcogsci)
library(papaja)
library(afex)
library(MASS)
library(hypr)