I Preliminaries
1
General Introduction
1.1
Learning goals
1.2
Course structure
1.3
Tools used in this course
1.4
Topics covered (and not covered) in the course
1.5
Data sets covered
1.6
Installation
1.7
Example schedule (12-week course)
2
Basics of R
2.1
First steps
2.1.1
Functions
2.1.2
Variables
2.1.3
Literate coding
2.1.4
Objects
2.1.5
Packages
2.1.6
Getting help
2.2
Data types
2.2.1
Numeric vectors & matrices
2.2.2
Booleans
2.2.3
Special values
2.2.4
Characters (= strings)
2.2.5
Factors
2.2.6
Lists, data frames & tibbles
2.3
Functions
2.3.1
Some important built-in functions
2.3.2
Defining your own functions
2.4
Loops and maps
2.4.1
For-loops
2.4.2
Functional iterators
2.5
Piping
2.5.1
Excursion: More on pipes in R
2.5.2
Excursion: Multiple assignments, or “unpacking”
2.6
Rmarkdown
II Data
3
Data, variables & experimental designs
3.1
What is data?
3.2
Different kinds of data
3.3
On the notion of “variables”
3.4
Basics of experimental design
3.4.1
What to analyze? – Dependent variables
3.4.2
Conditions, trials, items
3.4.3
Sample size
4
Data Wrangling
4.1
Data in, data out
4.2
Tidy data
4.2.1
Running example
4.2.2
Definition of
tidy data
4.2.3
Excursion: non-redundant data
4.3
Data manipulation: the basics
4.3.1
Pivoting
4.3.2
Subsetting rows & columns
4.3.3
Tidy selection of column names
4.3.4
Adding, changing and renaming columns
4.3.5
Splitting and uniting columns
4.3.6
Sorting a data set
4.3.7
Combining tibbles
4.4
Grouped operations
4.5
Case study: the King of France
4.5.1
Cleaning the data
5
Summary statistics
5.1
Counts and proportions
5.1.1
Loading and inspecting the data
5.1.2
Obtaining counts with
n
,
count
and
tally
5.2
Central tendency and dispersion
5.2.1
The data for the remainder of the chapter
5.2.2
Measures of central tendency
5.2.3
Measures of dispersion
5.2.4
Excursion: Quantifying confidence with bootstrapping
5.3
Covariance and correlation
5.3.1
Covariance
5.3.2
Correlation
6
Data Visualization
6.1
Motivating example: Anscombe’s quartet
6.2
Visualization: the good, the bad and the infographic
6.3
Basics of
ggplot
6.3.1
Incremental composition of a plot
6.3.2
Elements in the layered grammar of graphs
6.3.3
Layers and groups
6.3.4
Grouping
6.3.5
Example of a customized plot
6.4
A rendezvous with popular geoms
6.4.1
Scatter plots with
geom_point
6.4.2
Smooth
6.4.3
Line
6.4.4
Bar plot
6.4.5
Plotting distributions: histograms, boxplots, densities and violins
6.4.6
Rugs
6.4.7
Annotation
6.5
Faceting
6.6
Customization etc.
6.6.1
Themes
6.6.2
Guides
6.6.3
Axes, ticks and tick labels
6.6.4
Labels
6.6.5
Combining & arranging plots
6.6.6
LaTeX expressions in plot labels
III Bayesian Data Analysis
7
Basics of Probability Theory
7.1
Probability
7.1.1
Outcomes, events, observations
7.1.2
Probability distributions
7.1.3
Interpretations of probability
7.1.4
Distributions as samples
7.2
Structured events & marginal distributions
7.2.1
Probability table for a flip-and-draw scenario
7.2.2
Structured events and joint-probability distributions
7.2.3
Marginalization
7.3
Conditional probability
7.3.1
Bayes rule
7.3.2
Stochastic (in-)dependence
7.4
Random variables
7.4.1
Notation & terminology
7.4.2
Cumulative distribution functions, mass & density
7.4.3
Expected value & variance
7.4.4
Composite random variables
7.5
Probability distributions in R
8
Statistical models
8.1
Statistical models
8.2
Notation & graphical representation
8.2.1
Formula notation
8.2.2
Graphical notation
8.3
Parameters, priors, and prior predictions
8.3.1
What’s a model parameter?
8.3.2
Priors over parameters
8.3.3
Prior predictions
9
Bayesian parameter estimation
9.1
Bayes rule for parameter estimation
9.1.1
Definitions and terminology
9.1.2
The effects of prior and likelihood on the posterior
9.1.3
Computing Bayesian posteriors with conjugate priors
9.1.4
Excursion: Sequential updating
9.1.5
Posterior predictive distribution
9.2
Point-valued and interval-ranged estimates
9.2.1
Point-valued estimates
9.2.2
Interval-ranged estimates
9.2.3
Computing Bayesian estimates
9.2.4
Excursion: Computing MLEs and MAPs in R
9.3
Approximating the posterior
9.3.1
Of apples and trees: Markov Chain Monte Carlo sampling
9.3.2
Excursion: Probabilistic modeling with Stan
9.4
Estimating the parameters of a Normal distribution
9.4.1
Uninformative priors
9.4.2
Conjugate priors
9.4.3
Estimating the difference between group means
10
Model Comparison
10.1
Case study: recall models
10.2
Akaike Information Criterion
10.3
Bayes factors
10.3.1
Grid approximation
10.3.2
Naive Monte Carlo
10.3.3
Excursion: Bridge sampling
11
Bayesian hypothesis testing
11.1
Statistical hypotheses
11.2
Data and models for this chapter
11.2.1
24/7
11.2.2
Simon task
11.3
Testing via posterior estimation
11.3.1
Example: 24/7
11.3.2
Example: Simon Task
11.4
Testing via model comparison
11.4.1
The Savage-Dickey method
11.4.2
Encompassing models
IV Applied (generalized) linear modeling
12
Linear regression
12.1
Ordinary least squares regression
12.1.1
Prediction without any further information
12.1.2
Prediction with knowledge of unemployment rate
12.1.3
Linear regression: general problem formulation
12.1.4
Finding the OLS-solution
12.2
A maximum-likelihood approach
12.2.1
A likelihood-based model
12.2.2
Finding the MLE-solution with
optim
12.2.3
Finding the MLE-solution with
glm
12.2.4
Finding the MLE-solution with math
12.3
A Bayesian approach
12.4
Comparison of approaches
13
Bayesian regression in practice
13.1
Simple linear regression with
brms
13.2
Extracting posterior samples
13.3
[Excursion:] Inspecting the underlying Stan code
13.4
Setting priors
13.5
Posterior predictions
13.6
Testing hypotheses
14
Categorical predictors
14.1
Single two-level predictor
14.2
Single multi-level predictor
14.3
Multiple predictors
14.3.1
Treatment coding
14.3.2
Sum coding
15
Generalized linear model
15.1
Generalizing the linear regression model
15.2
Logistic regression
V Frequentist statistics
16
Null Hypothesis Significance Testing
16.1
Frequentist statistics: why & how
16.2
Quantifying evidence against a null-model with
p
-values
16.2.1
Frequentist null-models
16.2.2
One- vs. two-sided
\(p\)
-values
16.2.3
Significance & categorical decisions
16.2.4
How (not) to interpret
p
-values
16.2.5
[Excursion] Distribution of
\(p\)
-values
16.3
[Excursion] Central Limit Theorem
16.4
[Excursion] The Neyman-Pearson approach
16.5
Confidence intervals
16.5.1
Relation of
p
-values to confidence intervals
16.6
Selected tests
16.6.1
Pearson’s
\(\chi^2\)
-tests
16.6.2
z
-test
16.6.3
t
-tests
16.6.4
ANOVA
16.6.5
Linear regression
16.6.6
Likelihood-Ratio Test
17
Comparing frequentist and Bayesian statistics
17.1
Frequentist and Bayesian statistical models
17.2
Approximation: in the model or through the computation
17.3
MC-simulated
\(p\)
-values
17.4
Bayesian
\(p\)
-values & model checking
17.5
Comparing Bayesian and frequentist estimates
17.6
Beliefs, decisions and long-term error
17.7
Evidence for the null
17.8
Three pillars of data analysis
17.9
Testing hypotheses by estimation, comparison & model checking
17.10
Jeffreys-Lindley paradox
17.11
Explicit beliefs vs. implicit intentions
Appendix
A
Further useful material
A.1
Material on
Introduction to Probability
:
A.2
Material on
Bayesian Data Analysis
:
A.3
Material on
frequentist statistics
:
A.4
Material on
R, tidyverse, etc.
:
A.5
Further information for RStudio
A.6
Further information on WebPPL
A.6.1
Primitives and sampling functions
A.6.2
Inference with
Infer()
A.6.3
Visualization
A.6.4
Installation
A.6.5
Usage
A.6.6
Keyboard shortcuts (for in-browser use)
A.6.7
Further resources
B
Common probability distributions
B.1
Selected continuous distributions of random variables
B.1.1
Normal distribution
B.1.2
Chi-squared distribution
B.1.3
F-distribution
B.1.4
Student’s
t
-distribution
B.1.5
Beta distribution
B.1.6
Uniform distribution
B.1.7
Dirichlet distribution
B.2
Selected discrete distributions of random variables
B.2.1
Binomial distribution
B.2.2
Multinomial distribution
B.2.3
Bernoulli distribution
B.2.4
Categorical distribution
B.2.5
Beta-Binomial distribution
B.2.6
Poisson distribution
C
Exponential Family and Maximum Entropy
C.1
An important family: The Exponential Family
C.2
The Maximum Entropy Principle
C.2.1
Information Entropy
C.2.2
Deriving Probability Distributions using the Maximum Entropy Principle
D
Data sets used in the book
D.1
Mental Chronometry
D.1.1
Nature, origin and rationale of the data
D.1.2
Loading and preprocessing the data
D.1.3
Cleaning the data
D.1.4
Exploration: summary stats & plots
D.2
Simon Task
D.2.1
Experiment
D.2.2
Hypotheses
D.2.3
Results
D.3
King of France
D.3.1
Nature, origin and rationale of the data
D.3.2
Loading and preprocessing the data
D.3.3
Cleaning the data
D.3.4
Exploration: summary stats & plots
D.4
Bio-Logic Jazz-Metal (and where to consume it)
D.4.1
Nature, origin and rationale of the data
D.4.2
Loading and preprocessing the data
D.4.3
Exploration: counts & plots
D.5
Avocado prices
D.5.1
Nature, origin and rationale of the data
D.5.2
Loading and preprocessing the data
D.5.3
Summary statistics
D.5.4
Plots
D.6
Annual average world surface temperature
D.6.1
Nature, origin and rationale of the data
D.6.2
Loading and preprocessing the data
D.6.3
Hypothesis & modeling approach
D.6.4
Plotting
D.7
Murder data
D.7.1
Nature, origin and rationale of the data
D.8
Politeness data
D.8.1
Nature, origin and rationale of the data
D.8.2
Hypotheses
D.8.3
Summary statistics
D.8.4
Visualization
E
Open science practices
E.1
Psychology’s replication crisis
E.1.1
Publication bias, QRP’s, and false-positives
E.1.2
Low statistical power
E.1.3
Lack of transparency
E.2
Possible remedies
E.2.1
Improve scientific rigor
E.2.2
Realigning incentive structures
E.2.3
Promote transparency
E.3
Chapter summary
E.4
Further resources
References
An Introduction to Data Analysis
A.5
Further information for RStudio
Keyboard shortcuts
for Windows and Mac in RStudio: “Tools -> Keyboard Shortcuts Help” or also on the
RStudio support site