Foundations Of Statistics With R
Preface
0.1
Further reading
0.2
Installing R and RStudio
1
Data in R
1.1
Arithmetic and Variable Assignment
1.2
Vectors
1.2.1
Creating vectors
1.3
Indexing Vectors
1.4
Data Types
1.4.1
Missing data
1.5
Data Frames
1.6
Reading data from files
1.7
Libraries
1.8
Useful Idioms
1.9
Exercises
2
Probability
2.1
Probability Basics
2.2
Conditional Probability and Independence
2.3
Counting Arguments
2.4
Simulations
2.4.1
Using replicate to simulate experiments
2.4.2
Simulating Conditional Probability
2.5
Exercises
3
Random Variables
3.1
Discrete random variables
3.2
Expected value
3.3
Binomial and geometric random variables
3.3.1
Binomial
3.3.2
Geometric
3.4
Continuous random variables
3.4.1
Expected value of a continuous random variable
3.5
Functions of a random variable
3.6
Variance and standard deviation
3.7
Normal random variables
3.7.1
Computations with normal random variables
3.7.2
Normal approximation to the binomial
3.8
Other special random variables
3.8.1
Poisson and exponential random variables
3.8.2
Uniform random variables
3.8.3
Negative binomial
3.8.4
Hypergeometric
3.9
Independent random variables
3.10
Summary
3.11
Exercises
4
Simulation of Random Variables
4.1
Estimating probabilities of rvs via simulation.
4.2
Estimating discrete distributions
4.3
Estimating continuous distributions
4.4
Theorems about transformations of random variables
4.5
The Central Limit Theorem
4.6
Sampling Distributions
4.6.1
Linear combination of normal rv’s
4.6.2
Chi-squared
4.6.3
The
\(t\)
distribution
4.6.4
The F distribution
4.6.5
Summary
4.7
Point Estimators
4.7.1
Properties of Point Estimators
4.7.2
Variance of Unbiased Estimators
4.8
Exercises
5
Data Manipulation
5.1
Data frames and tibbles
5.2
dplyr verbs
5.3
dplyr pipelines
5.3.1
Group by and summarize
5.4
The power of dplyr
5.5
Working with character strings
5.6
The structure of data
5.6.1
Tidy data: pivoting
5.6.2
Using join to merge data frames
5.7
The apply family
5.8
Data science communities
5.9
Exercises
6
Data Visualization with ggplot
6.1
Scatterplots
6.2
Boxplots
6.3
Histograms
6.4
Quantile-Quantile plots
6.4.1
qq plots by hand
6.5
Plotting pmfs
6.6
Plotting functions
6.7
Piping to
ggplot
6.8
Common ggplot issues
6.9
Example: Votes in Alabama
6.9.1
Some GIS
6.10
Exercises
7
Inference on the Mean
7.1
Confidence intervals for the mean
7.2
Hypothesis Tests of the Mean
7.3
One-sided Confidence Intervals and Hypothesis Tests
7.4
Simulations
7.4.1
Symmetric, light tailed
7.4.2
Skew
7.4.3
Heavy tails and outliers
7.4.4
Summary
7.5
Two sample hypothesis tests of
\(\mu_1 = \mu_2\)
7.6
Type II errors and power
7.6.1
Effect size
7.7
Exercises
8
Rank Based Tests
8.1
One sample Wilcoxon Ranked-Sum Test
8.2
Two Sample test
8.2.1
Example
8.2.2
Ordinal Data
8.2.3
Discussion
8.3
Simulations
8.4
Robustness, power, and sample size
8.5
Exercises
9
Tabular Data
9.1
Test of proportions
9.1.1
Hypothesis Testing
9.1.2
Confidence Intervals
9.2
Multinomial Experiments
9.3
\(\chi^2\)
-tests
9.3.1
Simulations
9.3.2
Two sample test for equality of proportions
9.4
Exercises
10
Simple Linear Regression
10.1
Finding the intercept and slope
10.2
Using R and Linear Models
10.3
Prediction and Confidence Intervals
10.3.1
Confidence Bands
10.3.2
Prediction Intervals
10.4
Inference on the slope
10.5
Residual Analysis
10.6
Simulations
10.6.1
simulating residuals
10.6.2
Simulating Prediction and Confidence Intervals
10.7
Exercises
11
Analysis of Variance
11.1
Setup
11.2
ANOVA
11.3
Examples
11.3.1
red.cell.folate
11.3.2
InsectSprays
11.4
Examining the hypotheses
11.5
Pairwise t-tests and FWER
11.6
Exercises
12
Multiple Regression
12.0.1
Example One:
cystifbr
12.0.2
Example Two: Secher data
12.1
Exercises
13
Joint Distributions of Random Variables
13.1
Joint probability mass functions
13.1.1
Sampling from a joint probability mass function
13.1.2
Expected Values
13.2
Joint probability density functions
13.2.1
Sampling from random variables given (joint) pdf
13.2.2
One-dimensional case
13.2.3
Two dimensional case
13.3
Computing Probabilities and Expectations
13.4
Marginal and Conditional Densities
13.5
Independence
13.6
Exercises
14
Transformations of Random Variables
14.1
Method of Distribution Functions
14.2
Moment Generating Functions
14.2.1
Method of Moment Generating Functions
14.3
Central Limit Theorem
14.4
Universality of the uniform
14.5
Order Statistics
14.6
Exercises
15
Point Estimators
15.1
Sampling distributions of point estimators
15.2
Bias
15.3
Consistency
15.4
Likelihood Functions and Sufficiency
15.5
MVUE
15.6
MSE
15.7
Method of Moments
15.8
Maximum Likelihood Estimators
15.9
Exercises
16
Intro to Bayesian Statistics
16.1
Bayes’ Theorem Revisited
16.2
Binomial Experiment
16.2.1
Conjugate Distributions for Binomial Experiment
16.2.2
Technical Discussions
16.2.3
A non-beta prior
16.3
Priors and Posteriors for Means
References
Appendix
A
An R Markdown Primer for Doing Homework
Published with bookdown
Foundations of Statistics with R
References