MSU Intro Stat with R
Welcome
Authors
Preface
Textbook overview
Examples and exercises
Data sets and their sources
STAT 216 Coursepack
Acknowledgements
Preliminaries: Getting started in RStudio
Accessing RStudio
Alternative options for accessing RStudio
Packages
Using packages
The
catstats
package
Projects
R script files
Try it!
Loading data
Try it!
Exporting files
Exporting R script files
Try it!
Exporting plots
Try it!
Home
Troubleshooting
Extra references
I Introduction to data
1
Hello data
1.1
Case study: using stents to prevent strokes
1.2
Data basics
1.2.1
Observations, variables, and data frames
1.2.2
Types of variables
1.2.3
Relationships between variables
1.2.4
Explanatory and response variables
1.2.5
Introducing observational studies and experiments
1.3
Chapter review
Summary
Terms
Key ideas
2
Study design
2.1
Sampling principles and strategies
2.1.1
Populations and samples
2.1.2
Parameters and statistics
2.1.3
Anecdotal evidence
2.1.4
Sampling from a population
2.1.5
Four sampling methods (special topic)
2.2
Observational studies
2.3
Experiments
2.3.1
Principles of experimental design
2.3.2
Reducing bias in human experiments
2.4
Scope of inference
2.5
Chapter review
Summary
Terms
Key ideas
3
Applications: Data
3.1
Dataframes in R
3.2
Tidy structure of data
3.3
Using the pipe to chain
3.4
A data wrangling example
Filtering
Mutating
Terms
R functions
II Exploratory data analysis
4
Exploring categorical data
4.1
Contingency tables and conditional proportions
4.1.1
Row and column proportions
4.1.2
Sample proportions and population proportions
4.2
Bar plots and mosaic plots
4.2.1
Mosaic plots
4.3
Why not pie charts?
4.4
Simpson’s paradox
4.5
Chapter review
Summary
Terms
Key ideas
5
Exploring quantitative data
5.1
Scatterplots for paired data
5.2
Dot plots and the mean
5.3
Histograms and shape
5.4
Variance and standard deviation
5.5
Box plots, quartiles, and the median
5.6
Describing and comparing quantitative distributions
5.7
Robust statistics
5.8
Transforming data (special topic)
5.9
Mapping data (special topic)
5.10
Chapter review
Summary
Terms
Key ideas
6
Correlation and regression
6.1
Fitting a line, residuals, and correlation
6.1.1
Fitting a line to data
6.1.2
Using linear regression to predict possum head lengths
6.1.3
Residuals
6.1.4
Describing linear relationships with correlation
6.2
Least squares regression
6.2.1
Gift aid for freshman at Elmhurst College
6.2.2
An objective measure for finding the best line
6.2.3
Finding and interpreting the least squares line
6.2.4
Calculating the least squares regression line using summary statistics (special topic)
6.2.5
Extrapolation is treacherous
6.2.6
Describing the strength of a fit
6.2.7
Categorical predictors with two levels (special topic)
6.3
Outliers in linear regression
6.3.1
Types of outliers
6.4
Chapter review
Summary
Data visualization summary
Summary measures
Notation summary
Terms
Key ideas
7
Multivariable models
7.1
Gapminder world
7.2
Simpson’s paradox revisited
7.3
Multiple regression (special topic)
7.3.1
Indicator and categorical predictors
7.3.2
Many predictors in a model
7.4
Chapter review
Summary
Terms
Key ideas
8
Applications: Explore
III Foundations of inference
9
Hypothesis testing with randomization
9.1
Motivating example: Martian alphabet
9.1.1
Observed data
9.1.2
Variability in a statistic
9.1.3
Observed statistic vs. null statistics
9.2
Case study: Sex discrimination
9.2.1
Observed data
9.2.2
Variability of the statistic
9.2.3
Observed statistic vs. null statistics
9.3
Hypothesis testing
9.3.1
The US court system
9.3.2
p-value and statistical significance
9.4
Chapter review
Summary
Terms
Key ideas
10
Confidence intervals with bootstrapping
10.1
Case study: Medical consultant
10.1.1
Observed data
10.1.2
Variability of the statistic
10.2
Confidence intervals
10.2.1
Plausible range of values for the population parameter
10.2.2
Bootstrap confidence interval
10.3
Chapter review
Terms
11
Inference with mathematical models
11.1
Central Limit Theorem
11.2
Normal distributions
11.2.1
Normal distribution model
11.2.2
Standardizing with Z-scores
11.2.3
Normal probability calculations in R
11.2.4
Normal probability examples
11.2.5
68-95-99.7 rule
11.3
Quantifying the variability of a statistic
11.3.1
Standard error
11.3.2
Margin of error
11.4
Chapter review
Terms
12
Errors, power, and practical importance
12.1
Decision errors
12.2
Significance level
12.3
Two-sided hypotheses
12.4
Controlling the Type 1 error rate
12.5
Power
12.6
Statistical significance vs. practical importance
12.7
Chapter review
Terms
13
Applications: Foundations
IV Inference for categorical data
14
Inference for a single proportion
14.1
Simulation-based test for
\(H_0: \pi = \pi_0\)
Steps 1 and 2: Hypotheses and test statistic
Steps 3 and 4: Null distribution and p-value
Step 5: Conclusion and scope of inference
14.2
Bootstrap confidence interval for
\(\pi\)
14.3
Theory-based inferential methods for
\(\pi\)
14.3.1
Evaluating the two conditions required for modeling
\(\hat{p}\)
using theory-based methods
14.3.2
Theory-based test for
\(H_0: \pi = \pi_0\)
14.3.3
Theory-based confidence interval for
\(\pi\)
14.3.4
Violating conditions
14.4
Chapter review
Terms
15
Inference for comparing two proportions
15.1
Randomization test for
\(H_0: \pi_1 - \pi_2 = 0\)
15.1.1
Case study: CPR and blood thinner
15.1.2
Case study: Opportunity cost
15.1.3
Case study: Malaria vaccine
15.2
Bootstrap confidence interval for
\(\pi_1 - \pi_2\)
15.2.1
Observed data
15.2.2
Variability of the statistic
15.2.3
What does 95% mean?
15.3
Theory-based inferential methods for
\(\pi_1 - \pi_2\)
15.3.1
Evaluating the two conditions required for modeling
\(\pi_1 - \pi_2\)
using theory-based methods
15.3.2
Confidence interval for
\(\pi_1 - \pi_2\)
15.3.3
Hypothesis test for
\(H_0: \pi_1 - \pi_2 = 0\)
15.4
Chapter review
15.4.1
Summary of Z-procedures
Terms
16
Applications: Infer categorical
Making tables from raw data
Simulation-based inference for one proportion
Simulation-based inference for difference in two proportions
Simulation-based inference for relative risk
Theory-based inference for one proportion
Theory-based inference for a difference in two proportions
16.1
catstats
function summary
V Inference for quantitative data
17
Inference for a single mean
17.1
Bootstrap confidence interval for
\(\mu\)
17.1.1
Observed data
17.1.2
Variability of the statistic
17.1.3
Bootstrap percentile confidence interval for
\(\sigma\)
(special topic)
17.1.4
Bootstrapping is not a solution to small sample sizes!
17.2
Shifted bootstrap test for
\(H_0: \mu = \mu_0\)
17.2.1
Observed data
17.2.2
Shifted bootstrapped null distribution
17.3
Theory-based inferential methods for
\(\mu\)
17.3.1
Evaluating the two conditions required for modeling
\(\bar{y}\)
using theory-based methods
17.3.2
Introducing the
\(t\)
-distribution
17.3.3
One sample
\(t\)
-confidence intervals
17.3.4
One sample
\(t\)
-tests
17.4
Chapter review
Terms
18
Inference for comparing paired means
18.1
Shifted bootstrap test for
\(H_0: \mu_d = 0\)
18.1.1
Observed data
18.1.2
Variability of the statistic
18.1.3
Observed statistic vs. null value
18.2
Bootstrap confidence interval for
\(\mu_d\)
18.2.1
Observed data
18.2.2
Variability of the statistic
18.3
Theory-based inferential methods for
\(\mu_d\)
18.3.1
Observed data
18.3.2
Variability of the statistic
18.3.3
Observed statistic vs. null statistics
18.4
Chapter review
Terms
19
Inference for comparing two independent means
19.1
Randomization test for
\(H_0: \mu_1 - \mu_2 = 0\)
19.1.1
Observed data
19.1.2
Variability of the statistic
19.1.3
Observed statistic vs. null value
19.2
Bootstrap confidence interval for
\(\mu_1 - \mu_2\)
19.2.1
Observed data
19.2.2
Variability of the statistic
19.3
Theory-based inferential methods for
\(\mu_1 - \mu_2\)
19.3.1
\(t\)
-test for
\(\mu_1 - \mu_2\)
19.3.2
\(t\)
confidence interval for
\(\mu_1 - \mu_2\)
19.4
Chapter review
Summary of t-procedures
Terms
20
Applications: Infer quantitative
20.1
Inference for quantitative data using R and
catstats
Using the
\(t\)
-distribution
Simulation-based inference for paired mean difference
Theory-based inference for paired mean difference
Simulation-based inference for the difference of two means
Theory-based inference for the difference of two means
20.2
catstats
function summary
VI Inference for regression
21
Inference for correlation and slope
21.1
Case study: Sandwich store
21.1.1
Observed data
21.1.2
Variability of the statistic
21.2
Randomization test for
\(H_0: \beta_1= 0\)
21.2.1
Observed data
21.2.2
Variability of the statistic
21.2.3
Observed statistic vs. null value
21.3
Bootstrap confidence interval for
\(\beta_1\)
21.3.1
Observed data
21.3.2
Variability of the statistic
21.4
Inference on the correlation coefficient
\(\rho\)
21.5
Theory-based inferential methods for
\(\beta_1\)
21.5.1
Case study: Midterm elections and unemployment
21.5.2
Understanding regression output from software
21.5.3
Intuition vs. formal inference
21.5.4
Theory-based confidence interval for a regression coefficient
21.6
Checking model conditions
21.6.1
L
inearity
21.6.2
I
ndependence
21.6.3
N
ormality
21.6.4
E
qual variability
21.6.5
Scope of Inference for Regression
21.7
Chapter review
Terms
22
Applications: Infer regression
22.1
Inference for regression using R and
catstats
Simulation-based inference for the regression slope
Theory-based inference for the regression slope
22.2
catstats
function summary
VII Probability
23
Probability with tables
23.1
Defining probability
23.2
Finding probabilities with tables
23.3
Probability notation
23.4
Diagnostic testing
23.4.1
The case of Baby Jeff
23.5
Chapter review
Terms
Key ideas
References
Published with bookdown
Montana State Introductory Statistics with R
Chapter 13
Applications: Foundations
Future chapter addition