OpenIntro Statistics
📚 OpenIntro Statistics .pdf
Brief overview
This document provides a foundational understanding of statistical principles, covering data collection, probability, random variables, and statistical inference. Mastering these concepts is crucial for analyzing data, making informed decisions, and drawing valid conclusions in various fields.
Key points
- Overview of data types, observations, variables, and data collection principles including sampling and experimental design.
- Foundational concepts of probability, including distributions, random variables, and their properties.
- Principles of statistical inference, including confidence intervals and hypothesis testing for proportions and means.
- Application of statistical inference to categorical and numerical data using methods like chi-square and ANOVA.
- Introduction to regression techniques, including linear and logistic regression for modeling relationships.
1. Introduction to data and sampling principles (part 1)
1.1 Case study: using stents to prevent strokes
This case study highlights the role of statistics in evaluating medical treatments. Researchers investigated if stents reduce stroke risk in high-risk patients.
They randomly assigned 451 patients into two groups: treatment (stent + medical management) and control (medical management only).
- Treatment group: 224 patients received a stent and medical management.
- Control group: 227 patients received only medical management.
The study observed outcomes at 30 and 365 days. Data was summarized to show the proportion of patients experiencing a stroke.
Unexpected findings can occur; always be open to surprises in data. .
Stent study outcomes
| Timeframe | Group | Stroke | No Event | Total |
|---|---|---|---|---|
| 0-30 days | treatment | 33 | 191 | 224 |
| 0-365 days | treatment | 45 | 179 | 224 |
The analysis showed a higher stroke rate in the treatment group (20%) compared to the control group (12%) after one year. This unexpected result suggested potential harm from stents in this patient population.
🔑 Important: Generalizing results requires caution; study findings apply to specific populations and treatments studied. 10.
Exercise application
- Migraine and acupuncture: Researchers studied if acupuncture relieved migraine pain. 89 patients were assigned to treatment (acupuncture) or control (placebo acupuncture). After 24 hours, pain relief was assessed.
- Sinusitis and antibiotics: A study compared antibiotics to placebo for acute sinusitis. 166 adults received amoxicillin or a placebo. Symptom improvement was recorded after 10 days.
These exercises apply similar principles to analyze treatment effectiveness using contingency tables.
1.2 Data basics
Observations, variables, and data matrices
- Data: Observations collected from field notes, surveys, or experiments. .
- Statistics: The study of how to collect, analyze, and draw conclusions from data. 8.
Data is often organized in a data matrix.
A data matrix is a structured way to organize observations and their characteristics. 12.
Components of a data matrix
| Component | Description |
|---|---|
| Row (Case) | Represents a single observation or observational unit. |
| Column (Variable) | Represents a characteristic or attribute recorded for each case. |
Example: In a loan data set:
- Each row is a loan (a case).
- Columns like "loan amount" or "interest rate" are variables.
📝 Example: A gradebook is a data matrix where students are cases and assignments are variables. 13.
1.3 Sampling principles and strategies
This section introduces fundamental concepts for collecting data. Reliable conclusions require careful data collection, often using samples to represent a larger population.
The way data is collected significantly impacts the conclusions that can be drawn. .
Population vs. Sample
- Population: The entire group of individuals or items of interest.
- Sample: A subset of the population from which data is collected.
Collecting data from an entire population is often impractical or impossible. Therefore, statisticians use samples.
Random Sampling
Random sampling is crucial for ensuring a sample is representative of the population. It minimizes bias by giving every member of the population an equal chance of being selected.
Random selection helps avoid systematic errors and ensures results can be generalized. .
Common sampling methods
| Sampling Method | Description | When to Use |
|---|---|---|
| Simple Random Sampling (SRS) | Every possible sample of a given size has an equal chance of being selected. | When the population is homogeneous and a sampling frame is available. |
| Stratified Sampling | The population is divided into subgroups (strata), and SRS is performed within each stratum. | When subgroups within the population have distinct characteristics. |
| Cluster Sampling | The population is divided into clusters, and a random sample of clusters is selected for analysis. | When clusters are naturally occurring groups and SRS is difficult to implement. |
| Multistage Sampling | Involves multiple stages of sampling, combining different methods. | For large, geographically dispersed populations where other methods are complex. |
🔑 Important: Randomization is key to reducing bias and allowing generalizations from a sample to a population. .
📝 Example: To survey student opinions, stratify by year (freshman, sophomore, etc.) then take SRS from each year. .
🔑 Important: Aim for a sample that mirrors the population's diversity to ensure valid conclusions. .
🔑 Important: The core idea of sampling is to use a representative subset to understand a larger group efficiently. .
1.4 Data basics
-
Data: A collection of observations on one or more variables.
-
Data matrix: A rectangular arrangement where rows represent observations (cases) and columns represent variables.
Data matrix: observations = rows, variables = columns.
1.5 Variables
Variables describe characteristics of the observations. They can be classified into different types based on the values they can take.
| Variable Type | Description | Example from County Data |
|---|---|---|
| Numerical | Takes a wide range of numerical values; arithmetic operations are meaningful. | unemp rate, pop |
| Categorical | Takes values that are categories or labels. | state, metro |
1.6 Numerical variables
- Continuous numerical variable: Can take any numerical value within a range.
- Example:
unemp rate.
- Example:
- Discrete numerical variable: Can only take specific numerical values, often counts.
- Example:
pop(population count).
- Example:
Numerical variables are continuous or discrete.
1.7 Categorical variables
- Nominal variable: Categorical variable with no natural ordering of categories.
- Example:
state(AL, AK, WY).
- Example:
- Ordinal variable: Categorical variable with a natural ordering of categories.
- Example:
median edu(below hs, hs diploma, some college, bachelors). - Note: Ordinal variables are often treated as nominal for simplicity.
- Example:
Categorical variables are nominal or ordinal.
Example:
📝 Example: In a study of statistics students:
- Number of siblings: discrete numerical.
- Student height: continuous numerical.
- Previously taken statistics course (yes/no): categorical.
1.8 Relationships between variables
- Associated variables: Two variables show a connection or pattern when examined together.
- Visualized using scatterplots for numerical variables.
- Example:
homeownershipandmulti unitshow a downward trend (more multi-units mean less homeownership) 16.
- Independent variables: Two variables show no evident relationship.
Associated variables are related; independent variables are not.
- Positive association: As one variable increases, the other tends to increase.
- Example:
median hh incomeandpop change.
- Example:
- Negative association: As one variable increases, the other tends to decrease.
- Example:
multi unitandhomeownership17.
- Example:
🔑 Important: Association implies a relationship, but not necessarily causation.
1.9 Explanatory and response variables
- Explanatory variable: The variable hypothesized to cause or affect another variable.
- Response variable: The variable that is potentially affected by the explanatory variable.
Explanatory variable affects the response variable.
- Note: Labeling variables as explanatory or response assumes a potential causal link, which requires further investigation.
1.10 Observational studies and experiments
- Observational study: Researchers collect data without interfering with how the data arise.
- Can show associations but not causation.
- Examples: Surveys, reviewing records.
- Experiment: Researchers actively manipulate variables to investigate causal connections.
- Individuals are assigned to treatments.
- Randomized experiment: Individuals are randomly assigned to groups. This is key for inferring causation.
🔑 Important: Association does not imply causation. Causation can only be inferred from a randomized experiment 18.
Study: Does acupuncture affect migraines?
- Explanatory variable: Acupuncture treatment (received or placebo).
- Response variable: Pain relief (pain-free status) 20.
🔑 Important: Understanding variable types is crucial for choosing appropriate analytical methods and for correctly interpreting study findings 15.
2. Introduction to data and sampling principles (part 2)
2.1 Populations and samples
The core of research questions identifies a target population. This is the complete group you want to study.
Due to cost or feasibility, data is often collected from a sample, which is a subset of the population. This sample is used to estimate population characteristics.
A sample is a small fraction of the population used for estimation.
2.1.1 Anecdotal evidence
Anecdotal evidence is data collected haphazardly. It often relies on one or a few cases that are not representative of the population.
This type of evidence can be misleading because it may focus on unusual or striking examples.
Anecdotal evidence is based on a few, often extraordinary, cases.
2.1.2 Sampling from a population
Randomly selecting a sample helps reduce bias. A simple random sample (SRS) gives every individual in the population an equal chance of being selected.
This is like drawing names from a hat.
- Bias: If samples are not chosen randomly, they can be skewed by the collector's interests or by who is easily accessible.
Random sampling is key to creating representative samples.
- Convenience sample: This sample includes individuals who are easy to access. For example, surveying people in only one neighborhood might not represent an entire city.
- Non-response bias: This occurs when a significant portion of the sampled individuals do not participate. The results might then only reflect the opinions of those who did respond.
2.2 Observational studies
Observational studies collect data without applying any treatments. They are useful for showing associations or generating hypotheses.
However, they are generally not sufficient for making causal conclusions.
Observational studies can show relationships, not cause-and-effect.
2.2.1 Confounding variables
A confounding variable is related to both the variable being studied and the outcome. It can create a misleading association.
For example, sun exposure might link sunscreen use to skin cancer because more sun exposure leads to both increased sunscreen use and higher skin cancer risk.
Confounding variables offer alternative explanations for observed relationships.
2.2.2 Types of observational studies
- Prospective studies: Follow individuals forward in time, collecting data as events unfold. An example is tracking nurses' health behaviors over many years.
- Retrospective studies: Collect data after events have already occurred, often by reviewing past records.
2.3 Four sampling methods
Statistical methods rely on implied randomness for reliable results. Here are four common random sampling techniques:
2.3.1 Simple random sampling (SRS)
In a simple random sample, every case in the population has an equal chance of being selected. Knowing that one case is in the sample provides no useful information about other included cases.
SRS: Every individual has an equal chance of selection.
2.3.2 Stratified sampling
- Divide: The population is split into groups called strata.
- Sample within strata: A sampling method, usually SRS, is applied within each stratum.
- Benefit: Stratified sampling is useful when cases within strata are similar regarding the outcome of interest, leading to more precise estimates.
- Drawback: Analyzing stratified data is more complex.
Stratified sampling ensures representation from distinct subgroups.
| Stratum | Similarity within stratum | Sampling Method | Goal |
|---|---|---|---|
| Similar | High | SRS within | Precise population estimate |
| Diverse | Low | SRS within | Precise population estimate |
2.3.3 Cluster sampling
- Divide: The population is divided into groups called clusters.
- Sample clusters: A fixed number of clusters are randomly selected.
- Include all: All observations from the selected clusters are included in the sample.
- Benefit: Can be more economical than SRS or stratified sampling.
- Usefulness: Best when there is high variability within clusters, but clusters are similar to each other.
Cluster sampling selects entire groups to sample.
2.3.4 Multistage sampling
This method is similar to cluster sampling but involves an additional step.
- Divide: The population is divided into clusters.
- Sample clusters: A number of clusters are randomly selected.
- Sample within clusters: A random sample is taken within each selected cluster.
- Benefit: Can reduce data collection costs.
- Drawback: Data analysis may require more advanced methods.
Multistage sampling takes samples within sampled groups.
| Sampling Method | Steps | Best For | Complexity |
|---|---|---|---|
| Simple Random | 1. Equal chance for all individuals. | General use, unbiased selection. | Low |
| Stratified | 1. Divide into strata. 2. SRS within strata. | When subgroups are similar and need representation. | Medium |
| Cluster | 1. Divide into clusters. 2. Select whole clusters. | When clusters are similar but internally diverse. | Medium |
| Multistage | 1. Divide into clusters. 2. Sample clusters. 3. SRS within clusters. | Similar to cluster, but with further random sampling. | High |
🔑 Important: Random sampling is crucial for reliable statistical inferences. Non-random methods like convenience sampling or relying solely on anecdotal evidence introduce bias that undermines conclusions.
3. Experiments and data collection principles (part 1)
3.1 Principles of experimental design
Experiments are studies where researchers assign treatments to cases. When this assignment involves randomization, it's a randomized experiment.
These are crucial for showing cause-and-effect.
The core principles of experimental design are:
- Control: Researchers assign treatments and try to keep other differences between groups minimal. This involves standardizing conditions, like ensuring all patients drink the same amount of water with a pill.
- Randomization: Patients are randomly assigned to treatment groups. This balances out uncontrolled variables (like diet or genetics) and prevents bias.
- Replication: Observing more cases improves accuracy. This means collecting a large sample within one study or repeating the entire study.
- Blocking: If a variable is suspected to affect the outcome, researchers group cases by this variable (blocks) before randomizing. This ensures balanced representation of the blocking variable within treatment groups.
Blocking ensures equal representation of a variable across treatment groups.
3.2 Reducing bias in human experiments
While randomized experiments are powerful, bias can still occur, especially in human studies. Methods are used to ensure an unbiased perspective.
- Blinding: When patients don't know which group they are in, the study is blind. This prevents psychological effects from influencing results.
- Placebo: A fake treatment given to the control group. It looks identical to the real treatment, making the study blind. The placebo effect is a real improvement sometimes seen from fake treatments.
- Double-blinding: Both patients and researchers/doctors interacting with them are unaware of treatment assignments. This guards against subtle biases in care or observation.
Blinding prevents patient expectations and researcher attention from biasing results.
Here's a summary of how these principles are applied:
| Principle | Description | Goal |
|---|---|---|
| Control | Standardize conditions across groups. | Isolate treatment effect. |
| Randomization | Assign cases to groups by chance. | Balance unknown confounders and prevent bias. |
| Replication | Use a large sample size or repeat the study. | Increase precision of effect estimates. |
| Blocking | Group similar cases before randomizing. | Reduce variability due to a known factor. |
| Blinding | Keep participants unaware of their group assignment. | Minimize psychological bias (placebo effect). |
| Double-blinding | Keep participants and researchers unaware of group assignments. | Minimize bias from both participant and researcher actions. |
Key principles ensure valid causal conclusions.
🔑 Important: Randomized experiments with blinding and placebos are essential for strong causal claims in human studies. 32 34.
3.3 Understanding data distribution and shape
Histograms visualize data density, showing where values are more common. Higher bars indicate areas with more data.
This helps understand how data is spread.
- Shape of distribution: Describes how data trails off.
- Right skewed: Data trails off to the right, with a longer right tail.
- Left skewed: Data trails off to the left, with a longer left tail.
- Symmetric: Data trails off roughly equally in both directions.
A mode is a prominent peak in a distribution.
- Unimodal: One prominent peak.
- Bimodal: Two prominent peaks.
- Multimodal: More than two prominent peaks.
The shape description should include modality and skewness to fully characterize a distribution.
3.4 Variance and standard deviation
These measures describe the spread or variability of data around the mean.
- Deviation: The distance of an observation from its mean (x−xˉ).
- Sample variance (s2): The average of the squared deviations. Divided by n−1 for reliability. s2=n−1∑i=1n(xi−xˉ)2
- Standard deviation (s): The square root of the variance. It approximates the typical deviation of observations from the mean. s=s2
Standard deviation roughly describes how far the typical observation is from the mean. About 70% of data is usually within one standard deviation, and 95% within two.
For populations, variance is denoted σ2 and standard deviation by σ.
3.5 Summarizing data with quartiles and box plots
Box plots use five key statistics to summarize data and highlight unusual observations.
- Median: The middle value when data is ordered. It splits the data into two halves (50% below, 50% above).
- For an even number of observations, it's the average of the two middle values.
- For an odd number, it's the single middle value.
A box represents the middle 50% of the data, spanning from Q1 to Q3.
- Interquartile Range (IQR): The length of the box, measuring variability.
- IQR=Q3−Q1
- Q1 (First Quartile): The 25th percentile; 25% of data falls below this value.
- Q3 (Third Quartile): The 75th percentile; 75% of data falls below this value.
The median and IQR are considered robust statistics because extreme values have little impact on them.
3.6 Whiskers and outliers
Whiskers extend from the box to capture data within 1.5 times the IQR.
- Whisker reach: Limited to Q1−1.5×IQR and Q3+1.5×IQR.
- Outliers: Observations lying beyond the whiskers, identified by dots.
Identifying outliers helps detect strong skew, data errors, or interesting data properties.
| Statistic | Description |
|---|---|
| Median | The middle value of an ordered data set. |
| IQR | The range of the middle 50% of the data (Q3−Q1). |
| Mean (xˉ) | The average of all observations. |
| Standard Deviation (s) | The typical spread of data around the mean. |
3.7 Robust statistics
Robust statistics are less affected by extreme observations compared to non-robust ones.
| Statistic Type | Examples | Affected by Extreme Observations? |
|---|---|---|
| Robust | Median, IQR | Little |
| Not Robust | Mean (xˉ), s | Heavily |
The median and IQR are robust because they focus on the central tendency and middle spread, which are less influenced by single extreme values. The mean and standard deviation consider all values, making them sensitive to outliers.
Understanding robust statistics is crucial when dealing with skewed data, as outliers can distort non-robust measures.
4. Experiments and data collection principles (part 2)
4.1 Data transformations
Data transformations involve rescaling data using a function. This can help model data more easily, especially when it is strongly skewed.
-
Purpose of transformations:
- Show data structure differently.
- Reduce skew.
- Aid in modeling.
- Straighten nonlinear relationships in scatterplots.
-
Common transformations:
- Logarithm (e.g., base 10): Useful for right-skewed data clustered near zero.
- Square root (original observation).
- Inverse (original observation1).
Transformations aim to make data more symmetric and manageable for statistical analysis.
4.2 Mapping data
Geographic data benefit from intensity maps, which use color to represent value ranges. These maps are good for spotting geographic trends and forming hypotheses.
- Intensity maps:
- Use color to indicate high and low values of a variable.
- Help visualize geographic patterns.
- Are less precise for specific county values.
Intensity maps are excellent for exploring spatial trends in data.
4.3 Analyzing categorical data
Categorical data analysis involves summarizing relationships between two or more variables. Contingency tables and various plots are key tools.
4.4 Contingency tables
A contingency table displays counts for combinations of two categorical variables. Row and column totals are included for overall counts.
- Key elements:
- Counts: Number of observations for each combination.
- Row totals: Sum of counts across each row.
- Column totals: Sum of counts down each column.
4.5 Proportions in contingency tables
Proportions help understand the breakdown of one variable within another.
- Row proportions: Calculated by dividing each count by its row total.
- Example: Proportion of individual applicants who rent.
- Column proportions: Calculated by dividing each count by its column total.
- Example: Proportion of renters who applied as individuals.
Row and column proportions offer different perspectives on variable relationships.
| Variable Combination | Proportion Type | Interpretation |
|---|---|---|
| Individual & Rent | Row proportion | Proportion of individual applicants who rent |
| Individual & Rent | Column proportion | Proportion of renters who applied as individuals |
4.6 Visualizing categorical data
Several plots help visualize categorical data relationships.
- Bar plots: Display frequencies or proportions of a single categorical variable.
- Stacked bar plots: Show counts broken down by a second variable within bars.
- Side-by-side bar plots: Display bars for each category of one variable next to categories of another.
- Standardized stacked bar plots: Visualize proportions, useful when one variable is imbalanced.
- Mosaic plots: Resemble standardized stacked bar plots but also show relative group sizes through area.
- Pie charts: Show high-level breakdowns of a single categorical variable, but are less detailed than bar plots.
Choose the plot that best highlights the specific relationship or breakdown you want to show.
| Plot Type | Best Use Case | Strengths | Weaknesses |
|---|---|---|---|
| Stacked Bar Plot | Explanatory-response relationship | Shows breakdown within groups. | Can be hard to compare counts across groups if sizes differ greatly. |
| Side-by-Side Bar Plot | Comparing multiple categories neutrally | Easy to see counts in all combinations. | Can be cramped, difficult to compare proportions if group sizes vary widely. |
| Standardized Stacked Bar | Imbalanced primary variable | Clearly shows proportions, good for association checks. | Loses sense of raw case counts. |
| Mosaic Plot | Showing proportions and relative group sizes | Visualizes both proportions and group sizes effectively. | Can become complex with many variables. |
| Pie Chart | High-level overview of a single variable | Simple, shows part-to-whole. | Difficult to decipher details and compare slices accurately. |
4.7 Comparing numerical data across groups
Numerical data can be compared across different categories using specialized plots.
- Side-by-side box plots: Display multiple box plots on the same scale for easy comparison of center, spread, and shape.
- Hollow histograms: Show the outlines of histograms for each group on the same plot, useful for comparing distribution shapes.
These plots allow for direct visual comparison of numerical distributions between groups.
🔑 Important: Side-by-side box plots excel at comparing measures of center and spread, while hollow histograms are better for observing distribution shapes and potential anomalies across groups.
4.8 Variability within data
Randomly assigning participants to treatment groups helps ensure that any observed differences are due to the treatment itself, not pre-existing variations. Even with randomization, small differences can occur by chance.
This is expected due to inherent variability within data.
🔑 Important: In experiments, we assume variables are independent unless there's evidence to the contrary.
Malaria vaccine case study
A study on a new malaria vaccine, PfSPZ, involved randomizing patients into two groups. Fourteen patients received the experimental vaccine, and six received a placebo.
After 19 weeks, all 20 patients were exposed to a drug-sensitive malaria parasite strain. This strain was used for ethical reasons, allowing infections to be treated effectively.
Study Design and Outcome:
- Study Type: Experiment (patients were randomly assigned groups).
- Inference: Results can infer a causal relationship between the vaccine and infection signs.
- Results: 9 out of 14 treatment patients remained infection-free. All 6 placebo patients showed baseline infection signs.
- Proportion of Infection: 35.7% in the vaccine group vs. 100% in the placebo group.
- Limitation: The small sample size makes it unclear if the observed difference is convincing evidence of vaccine effectiveness.
Malaria Vaccine Experiment Results:
| Outcome | Vaccine Treatment | Placebo Treatment | Total |
|---|---|---|---|
| Infection | 5 | 6 | 11 |
| No Infection | 9 | 0 | 9 |
| Total | 14 | **6 | 20** |
🔑 Important: Even in experiments, chance variation can lead to differences between groups, especially with small sample sizes.
🔑 Important: The use of a drug-sensitive parasite strain in the malaria vaccine study was an ethical consideration to ensure prompt treatment of infections.
🔑 Important: When dealing with small sample sizes, observed differences might not be statistically significant and may be due to random chance.
5. Experiments and data collection principles (part 3)
5.1 Hypothesis testing through simulation
- Null hypothesis (H0): States that variables are independent. Any observed difference is due to random chance.
- Alternative hypothesis (HA): States that variables are not independent. The observed difference is not due to chance.
The goal is to see if the observed data conflict significantly with H0. If they do, H0 is rejected in favor of HA.
5.1.1 Simulating the independence model
- Simulation: A method to understand if an observed difference is common or rare under the assumption that H0 is true.
- This involves pretending the treatment (e.g., vaccine) has no effect. Then, randomly assigning subjects to groups many times.
- We record the outcome difference for each simulated trial. This builds a distribution of differences expected by chance alone.
The observed difference is deemed "rare" if it falls at the extreme edges of this simulated distribution.
5.1.2 Interpreting simulation results
The distribution of simulated differences, assuming H0 is true, is typically centered around 0.
- If the observed difference is common in simulations, it suggests the difference might be due to chance.
- If the observed difference is rare, it provides stronger evidence to reject H0 and support HA.
Table 1: Hypothesis testing steps
| Step | Action |
|---|---|
| Define claims | Formulate H0 (independence) and HA (association). |
| Simulate | Generate many datasets assuming H0 is true. |
| Compare | Calculate the observed statistic from real data and compare it to the simulated distribution. |
| Conclude | Determine if the observed statistic is rare under H0. Reject H0 if it is; otherwise, do not reject H0. |
Table 2: Malaria vaccine case study example
| Scenario | H0: Independence Model | HA: Alternative Model |
|---|---|---|
| Observed outcome | 35.7% infection (treatment), 100% (control) | Vaccine has an effect on infection rate. |
| Difference | 64.3% | Observed difference not due to chance alone. |
| Simulation | Observed difference is common by chance. | Observed difference is rare by chance. |
| Conclusion | Do not reject H0. | Reject H0; conclude vaccine is effective. |
5.2 Analyzing observed data in studies
Studies often compare outcomes between groups. It is crucial to determine if observed differences are statistically significant or due to random variation.
Table 3: Side effects of Avandia study analysis
| Statement | True/False | Explanation |
|---|---|---|
| i. More patients on pioglitazone had CV problems (5,386 vs. 2,593), so pioglitazone rate is higher. | False | This ignores the vastly different group sizes. Need to compare rates, not raw counts. |
| ii. Rosiglitazone rate (3.8%) is higher than pioglitazone rate (3.4%). | True | The calculation correctly compares rates per group. |
| iii. Higher incidence rate for rosiglitazone proves it causes CV problems. | False | Correlation does not equal causation. Observational studies cannot prove cause without controlling for confounding factors. |
| iv. Cannot tell if the difference is due to relationship or chance without further analysis. | True | This highlights the need for statistical inference to assess the role of chance. |
- Proportion of all patients with CV problems: 7,979 / 227,571 ≈ 0.035 or 3.5%.
- Expected CV problems in rosiglitazone group (if independent): Total CV events * (Rosiglitazone group size / Total patients) = 7,979 * (67,593 / 227,571) ≈ 2,368 75.
If H0 is true, we expect the observed number of CV problems in the rosiglitazone group to be close to this expected value.
- Claims being tested (Avandia study):
- H0: Rosiglitazone use and cardiovascular problems are independent.
- HA: Rosiglitazone use and cardiovascular problems are not independent.
- Support for HA: More patients with CV problems in the rosiglitazone group than expected under H0 provides stronger support for HA.
- Simulation results (Avandia study): If the simulation shows that observing a number of CV events as high or higher than calculated in (c) is rare, it suggests a relationship between rosiglitazone and CV problems.
Table 4: Heart transplants study data
| Group | Total Patients | Died | Alive |
|---|---|---|---|
| Control | 34 | 30 | 4 |
| Treatment | 69 | 45 | 24 |
- Survival independent of transplant?: Based on the mosaic plot, survival appears to be dependent on the transplant. The proportion of deaths is much lower in the treatment group.
- Efficacy of transplant: The box plots suggest the transplant program increases lifespan, as the survival times for the treatment group are generally longer.
- Proportion died (Treatment): 45 / 69 ≈ 0.652 or 65.2%.
- Proportion died (Control): 30 / 34 ≈ 0.882 or 88.2% 76.
5.2.1 Simulating the heart transplant study
- Claims being tested (Heart transplant study):
- H0: Survival is independent of receiving a heart transplant.
- HA: Survival is dependent on receiving a heart transplant; the transplant program is effective.
- Simulation setup:
- Create cards for "alive" and "dead" outcomes for all patients.
- Shuffle cards and deal into treatment (69 cards) and control (34 cards) groups.
- Calculate the difference in the proportion of "dead" cards between treatment and control.
- Repeat 100 times to build a distribution centered at 0.
- Determine the fraction of simulations with a difference as extreme or more extreme than observed.
- Simulation results: If the observed difference is rare in the simulations, it suggests the transplant program is effective.
Statistical inference provides tools to evaluate and control the rate of errors in model selection.
5.3 Data distribution characteristics
Understanding the shape of data distributions is key to interpreting summary statistics.
Table 5: Distribution shapes and statistics
| Distribution Shape | Mean vs. Median Relation | Histogram/Box Plot Features |
|---|---|---|
| Symmetric | Mean ≈ Median | Mirror image around the center. |
| Right-skewed | Mean > Median | Long tail to the right. Outliers are high. |
| Left-skewed | Mean < Median | Long tail to the left. Outliers are low. |
- Infant mortality: The histogram is right-skewed, with a long tail towards higher mortality rates. The mean would be larger than the median.
- TV watchers: The distribution is likely right-skewed, as there are likely many students watching a moderate amount of TV, but a few who watch a lot. The mean would be larger than the median.
- Exam scores (out of 100): If the average is 85 with a standard deviation of 15, the distribution might be left-skewed or symmetric. However, scores cannot exceed 100, potentially capping the right side and leading to a slight left skew if many high scores exist.
The median is a more robust measure of central tendency than the mean when data are skewed.
Table 6: Skewness statistic xˉ/median
| Condition | xˉ/median | Expected Distribution Shape | Reasoning |
|---|---|---|---|
| All observations > 0 | xˉ/median = 1 | Symmetric | Mean and median are equal. |
| All observations > 0 | xˉ/median < 1 | Left-skewed | Mean is smaller than the median. |
| All observations > 0 | xˉ/median > 1 | Right-skewed | Mean is larger than the median. |
- Oscar winners (Actor vs. Actress): Best actor ages show a higher mean (43.8) and lower SD (8.83) than best actress (Mean 36.2, SD 11.9). This suggests actors tend to be older and their ages are less variable than actresses. Histograms would reveal skewness for each.
The comparison of mean and median is a quick way to identify skewness in a distribution.
🔑 Important: Understanding whether data is skewed or symmetric is crucial because it dictates which summary statistics (mean vs. median) best represent the data and influences the interpretation of statistical tests.
6. Probability concepts and distributions (part 1)
6.1 Defining probability
- Probability: The likelihood of an outcome occurring, expressed as a proportion between 0 and 1. It represents the frequency of an outcome if a random process were repeated infinitely.
- Law of Large Numbers: As more observations are collected, the observed proportion of an outcome converges to its true probability.
- Notation: The probability of an event A occurring is written as P(A).
6.2 Random processes and outcomes
- A random process is an action with seemingly uncertain results.
- An outcome is a single result of a random process 82.
The probability of an outcome is its long-run proportion.
6.3 Disjoint or mutually exclusive outcomes
- Disjoint outcomes (or mutually exclusive outcomes) cannot occur at the same time.
- Example: Rolling a 1 and rolling a 2 on a single die roll are disjoint.
Addition Rule for Disjoint Outcomes: If A1 and A2 are disjoint outcomes, then P(A1 or A2)=P(A1)+P(A2).
6.4 Probabilities when events are not disjoint
- Events are sets of outcomes from a random process.
- Example: Event A = {1, 2} when rolling a die 84.
"Or" in statistics means "and/or" unless stated otherwise.
General Addition Rule: For any two events A and B, P(A or B)=P(A)+P(B)−P(A and B) 86. This accounts for outcomes that are in both events, preventing double-counting.
6.5 Probability distributions
- A probability distribution is a table listing all disjoint outcomes and their probabilities 87.
Rules for Probability Distributions:
- Outcomes must be disjoint.
- Probabilities must be between 0 and 1.
- Probabilities must sum to 1.
A probability distribution lists all possible outcomes and their likelihoods.
6.6 Complement of an event
- The sample space (S) is the set of all possible outcomes.
- The complement of an event A, denoted Ac, includes all outcomes not in A 88.
Complement Rule: P(A)+P(Ac)=1, or P(A)=1−P(Ac).
The complement rule is useful for simplifying calculations of "at least one" probabilities.
6.7 Independence
- Two processes are independent if the outcome of one provides no information about the outcome of the other.
- Example: Flipping a coin and rolling a die are independent.
Multiplication Rule for Independent Processes: If events A and B are from independent processes, then P(A and B)=P(A)×P(B) 90.
- Two events A and B are independent if P(A and B)=P(A)×P(B) 91.
Independence means outcomes don't influence each other.
🔑 Important: Understanding disjointness and independence is crucial for applying the correct probability rules (addition vs. multiplication). 83 89.
6.8 Introduction to probability
Probability quantifies the likelihood of an event occurring. It is a number between 0 and 1, inclusive.
A probability of 0 means an event is impossible, while a probability of 1 means it is certain.
Probability ranges from 0 (impossible) to 1 (certain).
6.9 Basic probability calculations
- Event: A specific outcome or a set of outcomes.
- Sample space: The set of all possible outcomes.
The probability of an event (A) is calculated as: P(A)=Total number of possible outcomesNumber of favorable outcomes for A
- Disjoint events: Events that cannot occur at the same time. Their intersection is empty.
- Non-disjoint events: Events that can occur simultaneously.
6.10 General addition rule
This rule applies to any two events, whether they are disjoint or not. It helps calculate the probability that at least one of the events occurs.
-
For any two events A and B: P(A∪B)=P(A)+P(B)−P(A∩B) Here, P(A∪B) is the probability of A or B occurring. P(A∩B) is the probability of both A and B occurring.
-
For disjoint events A and B: Since P(A∩B)=0, the formula simplifies to: P(A∪B)=P(A)+P(B)
6.11 Conditional probability
Conditional probability measures the likelihood of an event occurring given that another event has already occurred. It helps us understand how new information can change probability estimates.
Conditional probability updates likelihoods based on known information.
6.12 Calculating conditional probability
The conditional probability of event A given event B has occurred is denoted as P(A∣B).
-
Using counts: P(A∣B)=Number of outcomes where B occursNumber of outcomes where both A and B occur
-
Using probabilities: P(A∣B)=P(B)P(A∩B) This formula requires P(B)>0.
6.13 Marginal and joint probabilities
- Marginal probability: The probability of a single event occurring, irrespective of other events. It is calculated from the totals of a contingency table.
- Joint probability: The probability of two or more events occurring simultaneously. It is the probability of the intersection of events.
| Variable | Outcome | Probability |
|---|---|---|
| ML Prediction | pred fashion | 0.1202 |
| True Classification | truth fashion | 0.1696 |
| ML Prediction & True Class | pred fashion, truth fashion | 0.1081 |
- The probability of a photo being classified as "pred fashion" is P(mach learn is pred fashion)≈0.12.
- The probability of a photo being "truth fashion" is P(truth is fashion)≈0.17 97.
- The joint probability of a photo being predicted as "pred fashion" AND being "truth fashion" is P(mach learn is pred fashion and truth is fashion)≈0.11 96.
6.14 Applying conditional probability
We can use conditional probability to refine predictions. If we know the ML system predicted a photo was fashion, we can calculate the probability that it actually is fashion.
- Example: If the ML system predicts "pred fashion," the probability the photo is actually "truth fashion" is calculated as: P(truth is fashion∣mach learn is pred fashion)=P(mach learn is pred fashion)P(truth is fashion and mach learn is pred fashion) P(truth is fashion∣mach learn is pred fashion)=0.12020.1081≈0.90 This means that when the ML system predicts fashion, there is about a 90% chance it is correct. 97-98
6.15 Conditional probability notation
- P(A∣B) is read as "the probability of A given B."
- A is the outcome of interest, and B is the condition (known information).
📝 Example: The probability that the ML prediction was correct, if the photo was about fashion. This is written as P(mach learn is pred fashion∣truth is fashion). Using the probability table: P(mach learn is pred fashion∣truth is fashion)=P(truth is fashion)P(mach learn is pred fashion and truth is fashion)=0.16960.1081≈0.637 98.
🔑 Important: Conditional probability is essential for making informed decisions when some information is already known. It allows us to update our beliefs based on new evidence.
6.16 Probability distributions
A probability distribution describes the likelihood of each possible outcome for a random variable.
- Random variable: A variable whose value is a numerical outcome of a random phenomenon.
- Discrete random variable: Takes on a finite number of values or a countably infinite number of values.
- Continuous random variable: Can take on any value within a given range.
The pages reviewed focused on basic probability concepts and conditional probability, laying the groundwork for understanding discrete and continuous probability distributions in subsequent sections.
🔑 Important: Understanding conditional probability is crucial for interpreting data and making predictions in situations where information is incomplete or evolving.
7. Probability concepts and distributions (part 2)
7.1 Conditional probability
Conditional probability examines the likelihood of an event occurring given that another event has already occurred. It's denoted as P(A∣B), meaning the probability of event A happening given that event B has happened.
7.2 Calculating conditional probability
The probability of event A happening given event B is calculated by dividing the probability of both A and B occurring by the probability of B: P(A∣B)=P(B)P(A and B) This formula is crucial for understanding how new information affects probabilities.
7.3 The smallpox data example
Data from Boston in 1721 on smallpox inoculation shows how conditional probability applies to real-world scenarios.
- Contingency Table: Summarizes counts of outcomes, like inoculation status and survival.
- Proportion Table: Shows probabilities calculated by dividing counts by the total sample size.
| Inoculated | Result | Count | Proportion |
|---|---|---|---|
| Yes | Lived | 238 | 0.0382 |
| Yes | Died | 6 | 0.0010 |
| No | Lived | 5136 | 0.8252 |
| No | Died | 844 | 0.1356 |
The probability that a non-inoculated person died from smallpox is P(died∣not inoculated)=P(not inoculated)P(died and not inoculated)=0.96080.1356≈0.1411.
7.4 Observational studies and causation
Studies using existing data, like the smallpox example, are observational. They can show associations but not necessarily cause-and-effect.
🔑 Important: Observational studies may have confounding variables that affect both variables of interest.
7.5 General multiplication rule
This rule calculates the probability of two events occurring together, even if they are not independent. P(A and B)=P(A∣B)×P(B) This is a direct rearrangement of the conditional probability formula.
- Example: For the smallpox data, the probability of a resident being not inoculated and living is P(lived and not inoculated)=P(lived∣not inoculated)×P(not inoculated)=0.8588×0.9608≈0.8251.
7.6 Sum of conditional probabilities
If A1,…,Ak are disjoint outcomes that cover all possibilities for a variable, then for any event B: ∑i=1kP(Ai∣B)=1 Similarly, the complement rule applies: P(A∣B)=1−P(Ac∣B).
7.7 Independence and conditional probability
If events A and B are independent, then knowing B has occurred does not change the probability of A: P(A∣B)=P(A). The multiplication rule for independent events, P(A and B)=P(A)P(B), can be used to show this.
- Gambler's Fallacy: Believing past independent events influence future outcomes (e.g., roulette spins) is a common error.
7.8 Tree diagrams
Tree diagrams visually represent sequential events and their probabilities, especially when events are conditional.
- Structure: The diagram starts with primary branches for initial events (often marginal probabilities) and secondary branches for subsequent events (conditional probabilities).
- Joint Probabilities: Calculated by multiplying probabilities along each path from the root to a terminal node.
- Marginal Probabilities: Found by summing joint probabilities that share a common event.
📝 Example: For the smallpox data, a tree diagram shows the probability of being inoculated (0.0392) and then surviving (0.9754), leading to a joint probability of 0.0392×0.9754≈0.0382.
7.9 Applications of tree diagrams
Tree diagrams help calculate probabilities for complex scenarios, such as determining the probability of a student passing given they can construct tree diagrams. They are particularly useful for calculating conditional probabilities where the given information is the outcome and you want to infer the cause.
7.10 Bayes' Theorem
Bayes' Theorem provides a formal way to invert conditional probabilities, calculating P(cause∣effect) when P(effect∣cause) is known. It is especially useful when tree diagrams become too complex.
7.11 The formula
For a variable with outcomes A1,…,Ak and another variable with outcome B: P(A1∣B)=P(B∣A1)P(A1)+P(B∣A2)P(A2)+⋯+P(B∣Ak)P(Ak)P(B∣A1)P(A1) The denominator, P(B), is the total probability of outcome B, summing probabilities across all possible scenarios for the first variable.
7.12 Steps for application
- Identify marginal probabilities of the initial variable's outcomes: P(A1),P(A2),….
- Identify conditional probabilities of outcome B given each scenario of the first variable: P(B∣A1),P(B∣A2),….
- Substitute these values into Bayes' Theorem.
📝 Example: In a breast cancer screening scenario, Bayes' Theorem can calculate the probability of actually having cancer given a positive mammogram.
- Let "BC" be having breast cancer and "M+" be a positive mammogram.
- P(BC∣M+)=P(M+∣BC)P(BC)+P(M+∣no BC)P(no BC)P(M+∣BC)P(BC)
- Even with a positive test, if the disease is rare, the probability of actually having it can be surprisingly low.
7.13 Bayesian statistics
The strategy of updating beliefs with new evidence using Bayes' Theorem forms the basis of Bayesian statistics.
7.14 Sampling from a small population
When sampling from a small population, the method (with or without replacement) significantly impacts independence.
- Sampling without replacement: Observations are dependent. The probability of subsequent events changes based on prior selections.
- Example: A professor picking students for questions without picking the same student twice.
- Sampling with replacement: Observations are independent. The probability of each event remains constant.
- Example: A professor picking students for questions, allowing repeat selections.
🔑 Important: When the sample size is a small fraction (under 10%) of the population, observations are nearly independent even when sampling without replacement. The choice of sampling method has minimal impact in such cases.
- Comparison: Sampling without replacement typically offers a slightly better chance of winning if multiple prizes are awarded from a limited ticket pool, as it guarantees distinct winners.
7.15 Key takeaways for conditional probability and distributions
| Concept | Description | Relevance |
|---|---|---|
| Conditional Prob. | $P(A | B)$: Probability of A given B has occurred. |
| General Mult. Rule | $P(A \text{ and } B) = P(A | B)P(B)$ |
| Tree Diagrams | Visual tool for sequential, conditional events. | Organizing complex probability scenarios. |
| Bayes' Theorem | Inverting conditional probabilities ($P(B | A)fromP(A |
| Sampling Influence | Sampling without replacement from small populations introduces dependence. | Affects probability calculations for sequential events. |
🔑 Important: Conditional probability and Bayes' Theorem are fundamental for making informed decisions and updating beliefs when new data becomes available, especially in fields like medicine and statistics.
7.16 Random variables
A random variable is a process or variable with a numerical outcome. We use capital letters like X, Y, or Z to represent them.
The possible outcomes are denoted by lowercase letters with subscripts, such as x1,x2.
The concept of a random variable allows us to use mathematical tools to understand and predict real-world outcomes.
7.17 Expected value
The expected value of a random variable is the average outcome. It's calculated by summing each outcome multiplied by its probability.
This is often denoted by E(X) or the Greek letter μ.
For a discrete random variable X with outcomes x1,…,xk and probabilities P(X=x1),…,P(X=xk): E(X)=∑i=1kxiP(X=xi)
The expected value represents the balancing point, or center of gravity, of the probability distribution.
7.18 Variability in random variables
The variance and standard deviation describe how spread out the outcomes of a random variable are. Variance is the weighted sum of squared deviations from the mean.
The standard deviation is the square root of the variance.
The variance of a random variable X with expected value μ is: σ2=∑j=1k(xj−μ)2P(X=xj) The standard deviation is σ=σ2.
Variability measures the volatility or spread of potential outcomes around the average.
Example of calculating expected value and variance:
| Outcome (xi) | Probability (P(X=xi)) | xi×P(X=xi) | xi−μ | (xi−μ)2 | (xi−μ)2×P(X=xi) |
|---|---|---|---|---|---|
| \USD 0 | 0.20 | 0 | -117.85 | 13888.62 | 2777.7 |
| \USD 137 | 0.55 | 75.35 | 19.15 | 366.72 | 201.7 |
| \USD 170 | 0.25 | 42.50 | 52.15 | 2719.62 | 679.9 |
The expected value is $117.85, the variance is 3659.3, and the standard deviation is approximately $60.49.
Variance helps predict how much actual revenue might differ from expected revenue.
🔑 Important: Understanding both the expected value and variability is crucial for making informed decisions in situations with uncertain outcomes.
8. Probability concepts and distributions (part 3)
8.1 Linear combinations of random variables
A linear combination of random variables X and Y is an expression of the form aX+bY, where a and b are fixed numbers. This structure helps model situations where a total outcome is the sum or difference of individual components.
Examples include total travel time from daily commutes or net financial gain from investments.
The structure aX+bY describes a combination where coefficients are fixed numbers.
8.1.1 Expected value of linear combinations
The expected value of a linear combination is the sum of the expected values of the individual variables, each multiplied by its coefficient. This is a direct application of the linearity of expectation.
- Formula: E(aX+bY)=a×E(X)+b×E(Y)
- Intuition: The overall average outcome is the average of the individual average outcomes, weighted by their contributions.
Expected value calculation:
| Scenario | Description | Equation | Calculation |
|---|---|---|---|
| Travel time | Weekly commute | W=X1+...+X5 | E(W)=5×E(Xi) |
| Net cash flow | Auction profit/cost | X−Y | E(X−Y)=E(X)−E(Y) |
| Investment | Portfolio gain/loss | 6000X+2000Y | E(6000X+2000Y)=6000E(X)+2000E(Y) |
8.1.2 Variability of linear combinations
The variability of a linear combination is calculated using the variances of the individual random variables. This calculation depends on the assumption that the random variables are independent.
- Formula: Var(aX+bY)=a2×Var(X)+b2×Var(Y)
- Independence: This formula strictly holds when X and Y are independent.
- Standard deviation: The standard deviation is the square root of the variance.
Negatives in a linear combination do not affect variability calculations because coefficients are squared.
Variability calculation:
| Scenario | Description | Equation | Calculation |
|---|---|---|---|
| Travel time | Weekly commute | W=X1+...+X5 | Var(W)=5×Var(Xi) |
| Net cash flow | Auction profit/cost | X−Y | Var(X−Y)=Var(X)+Var(Y) |
| Investment | Portfolio gain/loss | 6000X+2000Y | Var(6000X+2000Y)=60002Var(X)+20002Var(Y) |
📝 Example: If John's daily commute has a standard deviation of 4 minutes, his weekly commute (5 days, X1 to X5) has a variance of 12×16+...+12×16=5×16=80. The standard deviation is 80≈8.94 minutes.
🔑 Important: The formula for the variance of a linear combination assumes independence between the random variables. If they are dependent, the formula needs modification 123.
8.2 Continuous distributions
Continuous probability distributions describe variables that can take any value within a given range, unlike discrete variables which have specific, separate outcomes. Examples include height, weight, or time.
8.2.1 From histograms to continuous distributions
Histograms visually represent the frequency or proportion of data within specific intervals (bins). As the number of bins increases and their width decreases, a histogram can approximate a smooth curve.
This curve represents the probability density function (PDF) of a continuous distribution.
- PDF property: The total area under the PDF curve is always equal to 1.
8.2.2 Probabilities from continuous distributions
For continuous distributions, probabilities are represented by the area under the PDF curve between two specific values. Probability is not assigned to a single point value.
- Area calculation: P(a≤X≤b) is the area under the PDF from a to b.
- Single point probability: The probability of a continuous random variable taking on any single exact value is zero. For example, P(X=180 cm)=0.
🔑 Important: Probabilities for continuous variables are represented by areas, not specific points. The probability of a single exact value is zero.
📝 Example: For US adults' heights, the probability of a person being between 180 cm and 185 cm is the area under the height PDF curve between those values, which is approximately 0.1157.
🔑 Important: If a person's height is measured to the nearest centimeter (e.g., 180 cm), this implies a range (179.5 cm to 180.5 cm) and has a non-zero probability 127.
🔑 Important: The topic covers linear combinations of random variables and the introduction to continuous probability distributions, focusing on how probabilities are represented as areas under a density curve 130.
9. Random variables and their distributions (part 1)
9.1 Normal distribution
The normal distribution is a symmetric, unimodal, bell-shaped curve ubiquitous in statistics. Many real-world variables, like SAT scores and adult heights, are approximately normally distributed.
9.2 Normal distribution model
The shape of a normal distribution is determined by two parameters:
- Mean (µ): Shifts the curve left or right.
- Standard deviation (σ): Stretches or constricts the curve.
A normal distribution with mean µ and standard deviation σ is denoted as N(µ, σ). The standard normal distribution has a mean of 0 and a standard deviation of 1, denoted N(0, 1).
| Distribution Type | Notation | Mean | Standard Deviation |
|---|---|---|---|
| Standard Normal | N(µ = 0, σ= 1) | 0 | 1 |
| Custom Normal Distribution | N(µ, σ) | µ | σ |
9.3 Standardizing with Z-scores
A Z-score measures how many standard deviations an observation is away from the mean. It standardizes observations for comparison.
-
The formula for a Z-score is: Z=σx−μ where x is the observation, µ is the mean, and σ is the standard deviation.
-
Positive Z-scores indicate values above the mean.
-
Negative Z-scores indicate values below the mean.
-
A Z-score of 0 means the observation is equal to the mean.
Observations are considered more unusual if their absolute Z-score is larger (∣Z1∣>∣Z2∣).
📝 Example: Ann scored 1300 on the SAT (N(1100, 200)). Her Z-score is Z=(1300−1100)/200=1. Tom scored 24 on the ACT (N(21, 6)). His Z-score is Z=(24−21)/6=0.5. Ann performed better relative to her group than Tom did in his.
9.4 Finding tail areas
Tail areas under the normal curve represent probabilities or percentiles.
-
Methods to find tail areas:
- Statistical software (e.g., R's
pnorm()function). - Graphing calculators.
- Probability tables (e.g., Appendix C.1).
- Statistical software (e.g., R's
-
Process:
- Draw and label a normal curve, shading the area of interest.
- Calculate the Z-score for the cutoff value(s).
- Use software, calculator, or table to find the corresponding tail area.
-
Finding areas to the right: If software provides the left tail area, subtract it from 1 to get the right tail area.
🔑 Important: Always draw a picture first and then find the Z-score. This helps estimate the probability and visualize the problem.
9.5 Normal probability examples
These examples illustrate using Z-scores to find probabilities for different scenarios.
-
Percentiles: The Z-score corresponding to a percentile can be found, then used to calculate the actual value.
- Example: The 40th percentile for height is found by first finding the Z-score for 0.40 (approx. -0.25) and then solving for height: x=μ+Zσ.
-
Probabilities between values: To find the probability between two values (x1 and x2), calculate their respective Z-scores (Z1 and Z2) and find the area between them. This can be done by subtracting the smaller tail area from the larger tail area.
📝 Example: For SAT scores (N(1100, 200)), the probability of scoring between 1100 and 1400 is calculated by finding the area below 1400 and subtracting the area below 1100. Area below 1100 (Z=0) is 0.5000. Area below 1400 (Z=1.5) is 0.9332. Probability between 1100 and 1400 is 0.9332−0.5000=0.4332.
9.6 68-95-99.7 rule
This rule of thumb estimates the percentage of observations falling within a certain number of standard deviations from the mean in a normal distribution:
| Range from Mean | Percentage of Data |
|---|---|
| µ ± 1σ | About 68% |
| µ ± 2σ | About 95% |
| µ ± 3σ | About 99.7% |
🔑 Important: This rule provides a quick estimate and is very useful for understanding the spread of data in normal distributions.
9.7 Geometric distribution
The geometric distribution models the number of independent Bernoulli trials needed to achieve the first success.
9.8 Bernoulli distribution
A Bernoulli random variable represents a single trial with two possible outcomes, typically labeled "success" and "failure."
- The probability of success is denoted by p.
- The probability of failure is denoted by 1−p.
- A Bernoulli random variable can be represented numerically as 1 for success and 0 for failure.
- The mean of a Bernoulli random variable is p.
- The standard deviation is p(1−p).
🔑 Important: The labeling of "success" and "failure" is arbitrary as long as it is consistent.
9.9 Geometric distribution
The geometric distribution describes the waiting time for the first success in a sequence of independent Bernoulli trials.
-
Probability Mass Function (PMF): The probability of observing the first success on the n-th trial is: P(X=n)=(1−p)n−1p where p is the probability of success on a single trial.
-
Mean (Expected Value): The average number of trials to get the first success is: μ=p1
-
Variance: The variability in the number of trials is: σ2=p21−p
-
Standard Deviation: σ=p21−p
🔑 Important: The independence of trials is crucial for the geometric distribution. It is always right-skewed and cannot be accurately approximated by the normal model.
🔑 Important: The geometric distribution is used for scenarios like "how many attempts until success?" and its mean intuitively shows that a higher success probability (p) leads to fewer expected trials.
9.10 Introduction to distributions
Random variables represent numerical outcomes of random phenomena. Their distributions describe the likelihood of each possible outcome.
Understanding these distributions is key to analyzing and predicting random events.
9.11 Bernoulli distribution
A Bernoulli trial is a random experiment with exactly two possible outcomes: success or failure. The probability of success is denoted by p, and the probability of failure is 1−p.
🔑 Important: For a trial to be Bernoulli, it must have only two outcomes, be independent, and have a constant probability of success.
9.12 Geometric distribution
The geometric distribution models the number of independent Bernoulli trials needed to achieve the first success. Each trial has a fixed probability of success p.
📝 Example: If a coin has a probability p=0.5 of landing heads, the geometric distribution can model how many flips it takes to get the first head.
9.13 Binomial distribution
The binomial distribution describes the number of successes in a fixed number (n) of independent Bernoulli trials. Each trial has the same probability of success (p).
This differs from the geometric distribution, which focuses on the number of trials until the first success.
🔑 Important: The four conditions for a binomial distribution are: independent trials, a fixed number of trials (n), each trial is a success or failure, and a constant probability of success (p) for each trial.
9.14 Calculating binomial probabilities
The probability of observing exactly k successes in n trials is calculated using a specific formula. This formula accounts for the number of ways these successes can occur and the probability of any single sequence of successes and failures.
The probability of any single sequence with k successes and n−k failures is: pk(1−p)n−k
The number of ways to choose k successes from n trials is given by the binomial coefficient, often read as "n choose k": (kn)=k!(n−k)!n! where n! (n factorial) is n×(n−1)×⋯×1, and 0!=1.
Combining these, the probability of exactly k successes in n trials is: P(X=k)=(kn)pk(1−p)n−k
9.15 Properties of the binomial distribution
The mean, variance, and standard deviation of a binomial distribution are standard calculations. These measures provide key insights into the expected outcome and variability.
| Measure | Formula |
|---|---|
| Mean (μ) | np |
| Variance (σ2) | np(1−p) |
| Standard Deviation (σ) | np(1−p) |
🔑 Important: Increasing the probability of success p for a fixed number of trials n decreases the standard deviation, making the outcomes more clustered around the mean.
9.16 Negative binomial distribution
The negative binomial distribution models the number of trials needed to achieve a specific number (r) of successes. This is a generalization of the geometric distribution, where we wait for r successes instead of just one.
9.17 Poisson distribution
The Poisson distribution describes the probability of a given number of events occurring in a fixed interval of time or space. These events must occur with a known average rate and independently of the time since the last event.
📝 Example: The number of customer calls arriving at a call center per hour follows a Poisson distribution if calls arrive randomly and at a constant average rate.
9.18 Properties of the Poisson distribution
The Poisson distribution is characterized by a single parameter, λ (lambda), which represents the average rate of events. This parameter is both the mean and the variance of the distribution.
| Measure | Formula |
|---|---|
| Mean (μ) | λ |
| Variance (σ2) | λ |
🔑 Important: A key characteristic of the Poisson distribution is that its mean and variance are equal.
9.19 Normal distribution
The normal distribution, often called the bell curve, is a continuous probability distribution. It is symmetric and is characterized by its mean (μ) and standard deviation (σ).
Many natural phenomena approximate a normal distribution.
🔑 Important: The normal distribution is fundamental in statistics and is often used to approximate other distributions, especially when sample sizes are large.
9.20 Properties of the normal distribution
The normal distribution is defined by its shape, which is determined by its mean and standard deviation. The area under the curve represents probabilities.
| Property | Description |
|---|---|
| Symmetry | The curve is symmetric around its mean. |
| Peak | The highest point of the curve is at the mean. |
| Tails | The curve approaches the horizontal axis but never touches it. |
| Total Area | The total area under the curve is 1 (representing 100% probability). |
| Mean = Median = Mode | In a perfect normal distribution, these three measures of central tendency are identical. |
9.21 Z-scores
A Z-score measures how many standard deviations a data point is from the mean. It standardizes values from different normal distributions, allowing for comparison.
The formula for a Z-score is: Z=σX−μ where X is the data point, μ is the mean, and σ is the standard deviation.
9.22 The 68-95-99.7 rule
Also known as the empirical rule, this guideline states approximate percentages of data falling within certain standard deviations of the mean for a normal distribution:
- Approximately 68% of data falls within 1 standard deviation of the mean (μ±σ).
- Approximately 95% of data falls within 2 standard deviations of the mean (μ±2σ).
- Approximately 99.7% of data falls within 3 standard deviations of the mean (μ±3σ).
🔑 Important: The 68-95-99.7 rule is a useful quick reference for estimating probabilities in normal distributions without complex calculations.
🔑 Important: Understanding the Bernoulli, binomial, geometric, Poisson, and normal distributions provides a foundational toolkit for analyzing various types of random events and data.
10. Random variables and their distributions (part 2)
10.1 Binomial distribution
-
Binomial distribution: Models the number of successes in a fixed number of independent trials.
-
Conditions for binomial model:
- Independent trials.
- Fixed number of trials (n).
- Each trial has only two outcomes (success/failure).
- The probability of success (p) is constant for each trial.
-
Formula: The probability of exactly k successes in n trials is: P(X=k)=(kn)pk(1−p)n−k where (kn)=k!(n−k)!n!.
-
Mean and Standard Deviation:
- Mean: μ=np
- Standard deviation: σ=np(1−p)
📝 Example: If 70% of individuals do not exceed an insurance deductible (p=0.7), the probability that exactly 5 out of 8 individuals (n=8,k=5) do not exceed it is (58)(0.7)5(0.3)3≈0.254.
10.2 Normal approximation to the binomial distribution
-
The normal distribution can approximate the binomial distribution when n is large.
-
Conditions for normal approximation:
- np≥10
- n(1−p)≥10
-
The approximating normal distribution has:
🔑 Important: The normal approximation is less accurate for small intervals. Use a continuity correction by adjusting interval endpoints by 0.5 (subtract 0.5 from the lower bound, add 0.5 to the upper bound).
- Continuity correction explained:
- For a range of values (e.g., 49 to 51), adjust the interval to 48.5 to 51.5.
- This correction improves the approximation by accounting for the discrete nature of the binomial distribution.
10.3 Negative binomial distribution
-
Negative binomial distribution: Models the number of trials needed to achieve a fixed number of successes.
-
Conditions for negative binomial model:
- Each trial has two outcomes (success/failure).
- The probability of success (p) is constant.
- The last trial must be a success.
-
Formula: The probability of achieving the kth success on the nth trial is: P(X=n)=(k−1n−1)pk(1−p)n−k where p is the probability of success on any given trial.
🔑 Important: The binomial distribution fixes the number of trials and counts successes. The negative binomial distribution fixes the number of successes and counts trials.
- Relation to geometric distribution: When k=1, the negative binomial distribution is equivalent to the geometric distribution (probability of first success on the nth trial).
📝 Example: If a kicker has a 0.8 probability of success (p=0.8), the probability of making the fourth successful field goal (k=4) on the sixth attempt (n=6) is (4−16−1)(0.8)4(0.2)6−4=(35)(0.8)4(0.2)2=10×0.4096×0.04=0.164.
10.4 Poisson distribution
-
Poisson distribution: Models the number of events occurring in a fixed interval of time or space.
-
Usefulness: It is useful for estimating the count of rare events in a large population over a unit of time or space.
-
Parameter: The distribution is characterized by a rate parameter, λ (or μ), which represents the average number of occurrences in that interval.
-
Formula: The probability of observing exactly k events in an interval is: P(X=k)=k!λke−λ where λ is the average rate of occurrence.
📝 Example: For New York City, with an average of 4.4 heart attack hospitalizations per day (λ=4.4), the probability of exactly 5 hospitalizations on a given day can be calculated using the Poisson formula.
🔑 Important: The Poisson distribution assumes that events occur independently and at a constant average rate within the specified interval.
10.5 Key distributions summary
| Distribution | Key Feature | Formula (Probability of X) | Parameters | Use Case |
|---|---|---|---|---|
| Binomial | Fixed number of trials, count successes | (kn)pk(1−p)n−k | n,p | Number of successes in a set number of trials |
| Negative Binomial | Fixed number of successes, count trials | (k−1n−1)pk(1−p)n−k | k,p | Trials to reach a fixed number of successes |
| Poisson | Count events in a fixed interval of time/space | k!λke−λ | λ | Number of occurrences in an interval |
| Normal (approximation) | Approximates binomial for large n | σ2π1e−21(σx−μ)2 | μ,σ | Large-sample binomial probabilities |
🔑 Important: Understanding the conditions and parameters for each distribution is crucial for selecting the correct model for a given problem.
10.6 Poisson distribution
The Poisson distribution models the number of events occurring in a fixed interval of time or space. It is suitable when events happen independently and the population is large.
-
Formula: P(observe k events)=k!λke−λ
- λ: The rate parameter (average number of events).
- k: The number of events observed (0, 1, 2, ...).
- e: Base of the natural logarithm (approx. 2.718).
- k!: k-factorial.
-
Mean: λ
-
Standard Deviation: λ
The Poisson distribution is for counting rare events in a large population.
10.7 Normal distribution
The normal distribution, also known as the Gaussian distribution or bell curve, is a continuous probability distribution. It is symmetric and characterized by its mean (μ) and standard deviation (σ).
- Key Properties:
- Symmetric around the mean.
- The mean, median, and mode are equal.
- The total area under the curve is 1.
10.8 Z-scores
A Z-score standardizes a value from a normal distribution. It represents the number of standard deviations a data point is away from the mean.
- Formula: Z=σx−μ
- x: The individual data point.
- μ: The population mean.
- σ: The population standard deviation.
Z-scores allow comparison across different normal distributions.
10.9 The 68-95-99.7 rule
The 68-95-99.7 rule (or empirical rule) describes the distribution of data in a normal distribution. It states that:
- Approximately 68% of the data falls within one standard deviation of the mean (μ±σ).
- Approximately 95% of the data falls within two standard deviations of the mean (μ±2σ).
- Approximately 99.7% of the data falls within three standard deviations of the mean (μ±3σ).
Use this rule to quickly estimate probabilities for normal distributions.
🔑 Important: Understanding these distributions (Poisson and Normal) and their properties, like Z-scores and the 68-95-99.7 rule, is crucial for solving probability problems involving counts and continuous measurements.
11. Foundations for statistical inference (part 1)
11.1 Point estimates and sampling variability
- Point estimate: A single value used to estimate a population parameter.
- Parameter: The true value for the entire population (e.g., population proportion p).
- Statistic: A value calculated from a sample, used to estimate a parameter (e.g., sample proportion p^).
- Error: The difference between an estimate and the true parameter. It includes sampling error and bias.
- Sampling error (uncertainty): Variability in estimates due to random chance across different samples.
- Bias: A systematic tendency to over- or under-estimate the true population value.
Larger sample sizes generally lead to smaller sampling error.
11.2 Sampling distribution
- The sampling distribution is the distribution of a statistic from many possible samples of the same size from the same population.
- It describes how a statistic (like p^) would vary if we repeatedly took samples.
- We can characterize a sampling distribution by its center, spread, and shape.
Example: If the true population proportion is p=0.88 and sample size is n=1000, simulations show the sampling distribution of p^ is centered at 0.88, with a standard deviation (standard error) of about 0.010, and is bell-shaped 171.
11.3 Central Limit Theorem (CLT)
The Central Limit Theorem provides conditions under which a sampling distribution will approximate a normal distribution.
CLT: For independent observations and a sufficiently large sample size, the sample proportion p^ follows a normal distribution.
The mean and standard error are: μp^=p SEp^=np(1−p)
Conditions for CLT:
- Independence: Observations must be independent. This is usually met with simple random samples or random assignment.
- Large Sample Size (Success-Failure Condition): The sample size must be large enough for the normal approximation to be valid.
- np≥10
- n(1−p)≥10
Example: For p=0.88 and n=1000:
- Independence: Assumed from simple random sample.
- Success-Failure:
- np=1000×0.88=880≥10
- n(1−p)=1000×(1−0.88)=120≥10 Both conditions met, so CLT applies 172.
11.4 Checking conditions for real-world data
- When the population proportion p is unknown, we use the sample proportion p^ to check the success-failure condition and estimate the standard error. This is called the "plug-in principle.".
Example: A poll of n=1000 found p^=0.887. * np^=1000×0.887=887≥10 * n(1−p^)=1000×(1−0.887)=113≥10 Conditions met.
- Estimated Standard Error: SEp^≈np^(1−p^)=10000.887(1−0.887)≈0.010 174.
11.5 Impact of small sample sizes
- If the success-failure condition (np≥10 and n(1−p)≥10) is not met, the sampling distribution may be discrete, skewed, or not closely resemble a normal distribution 175.
Summary of CLT implications:
- Center: The sampling distribution is centered at the population parameter p (unbiased).
- Spread: Variability (standard error) decreases as sample size n increases.
- Shape: Approximates a normal distribution when conditions are met.
- Variability: Standard error is largest when p=0.5.
The standard error formula SEp^=np(1−p) shows that increasing n (the sample size) decreases the standard error 179.
11.6 Applying CLT to other statistics
- The principles of point estimation and understanding sampling distributions apply to other statistics, such as sample means (xˉ) estimating population means (μ), and differences in means 178.
The core ideas of statistical inference are consistent across different types of parameters and statistics.
11.7 Confidence intervals for a proportion
A confidence interval provides a range of plausible values for a population parameter, offering more information than a single point estimate.
A confidence interval is like fishing with a net; it increases our chances of capturing the population parameter compared to using a spear (point estimate).
11.8 Constructing a 95% confidence interval
- A confidence interval is typically constructed around a point estimate (p^) by adding and subtracting a margin of error.
- The margin of error is based on the standard error and a critical value from the normal distribution.
Formula for a 95% confidence interval for a proportion: p^±1.96×SEp^
Where:
- p^ is the sample proportion.
- 1.96 is the critical value for 95% confidence (corresponding to approximately 95% of data within 1.96 standard deviations of the mean in a normal distribution).
- SEp^≈np^(1−p^) is the estimated standard error of the proportion.
11.9 Interpretation of confidence level
- A "95% confidence interval" means that if we were to construct many such intervals from numerous samples, approximately 95% of those intervals would contain the true population proportion (p).
To be more certain of capturing the population proportion, a wider interval is needed 181.
🔑 Important: Confidence intervals provide a plausible range for the population parameter, acknowledging the uncertainty inherent in using sample data.
11.10 Confidence intervals for a proportion
A confidence interval provides a plausible range of values for a population parameter. It's based on a sample statistic.
A point estimate is a single value that estimates a population parameter. For example, a sample proportion (p^) estimates a population proportion (p).
A confidence interval gives a range where the true population parameter likely lies.
11.11 Understanding sampling variability
- Sampling variability means that different random samples from the same population will produce different point estimates. This is natural.
- A single confidence interval gives a plausible range for the parameter. It doesn't guarantee the parameter is within that range.
- If an interval does not contain the population parameter, it doesn't mean the parameter is impossible; it just means that specific sample was unusual.
11.12 Constructing a 95% confidence interval
When a point estimate's sampling distribution is approximately normal, a 95% confidence interval is calculated as:
pointestimate±1.96×SE
- SE stands for standard error, which measures the variability of the point estimate.
- The value 1.96 is used because it captures 95% of the data in a standard normal distribution.
Example: A poll found 88.7% support for expanding solar power from 1000 adults. The standard error was 0.010.
The 95% confidence interval is: 0.887±1.96×0.010=(0.8674,0.9066) We are 95% confident that the true proportion of American adults supporting solar power is between 86.7% and 90.7% 182.
11.13 Adjusting the confidence level
To achieve a higher confidence level (e.g., 99%), the interval must be wider. A lower confidence level (e.g., 90%) allows for a narrower interval.
- The general formula for a confidence interval is: pointestimate±z⋆×SE
- z⋆ is a value from the standard normal distribution that corresponds to the chosen confidence level. It represents the number of standard errors from the point estimate needed to capture the desired percentage of the distribution.
| Confidence Level | z⋆ Value | Standard Deviations from Mean |
|---|---|---|
| 90% | 1.65 | Within ±1.65 |
| 95% | 1.96 | Within ±1.96 |
| 99% | 2.58 | Within ±2.58 |
- For a 90% confidence interval, we use z⋆ = 1.65. Using the solar power example: 0.887±1.65×0.010=(0.8705,0.9034) We are 90% confident that the true proportion is between 87.1% and 90.3% 184.
11.14 Steps for constructing a confidence interval for a proportion
- Prepare: Identify the sample proportion (p^), sample size (n), and desired confidence level.
- Check: Verify conditions for using a normal distribution model. This includes checking for independence and the success-failure condition (sample size ×p^≥10 and sample size ×(1−p^)≥10).
- Calculate: Compute the standard error (SE) using p^, find the appropriate z∗, and construct the interval: p^±z∗×SE.
- Conclude: Interpret the interval in the context of the problem.
Example: A poll of 1042 New Yorkers on Ebola quarantine found p^=0.82.
- Check: Independence is met (random sample). Success-failure condition: 1042×0.82≈854>10 and 1042×(1−0.82)≈188>10. Normal model is appropriate.
- Calculate SE: SE=np^(1−p^)≈10420.82(1−0.82)≈0.012
- Construct 95% CI: 0.82±1.96×0.012=(0.796,0.844) We are 95% confident that the true proportion of New Yorkers supporting a quarantine was between 79.6% and 84.4% 185.
11.15 Interpreting confidence intervals
- A confidence interval statement always refers to the population parameter, not the sample statistic or future samples.
- The confidence level (e.g., 95%) means that if we were to take many samples and construct intervals, about 95% of those intervals would capture the true population parameter.
- Confidence intervals do not account for bias in data collection.
Confidence intervals provide a plausible range for a population parameter, not a guarantee or a prediction for future samples.
📝 Example: A 95% confidence interval for the proportion of Americans supporting wind turbines is (81.9%, 87.7%). This means we are 95% confident that the true proportion of all US adults who support expanding wind turbines falls within this range.
🔑 Important: The confidence level quantifies the reliability of the method used to create the interval, not the probability that a specific, already-computed interval contains the true parameter 186.
12. Foundations for statistical inference (part 2)
12.1 Confidence intervals for proportions
A confidence interval provides a range of plausible values for a population proportion. It is constructed using a sample proportion and the margin of error.
- Point estimate: The sample proportion (p^) is the best single guess for the population proportion.
- Confidence level: This indicates the long-run success rate of the method used to construct the interval. A 95% confidence level means that if we were to take many samples and construct intervals, about 95% of them would contain the true population proportion.
- Interpretation: We are "X%" confident that the true population proportion lies within the calculated interval. This confidence applies to the interval creation process, not to a specific interval.
We are X% confident that the true proportion of [population characteristic is between [lower bound and [upper bound.
A confidence interval can also be used to perform hypothesis testing. If the null hypothesized value falls within the interval, we do not reject the null hypothesis.
If the null value is outside the interval, we reject the null hypothesis.
12.2 Hypothesis testing for a proportion
Hypothesis testing is a framework for rigorously evaluating competing claims about a population parameter.
- Null Hypothesis (H0): Often represents a skeptical view, a claim of "no difference," or a status quo. It usually states a specific value for the population parameter.
- Alternative Hypothesis (HA): Represents an alternative claim, often suggesting a difference or a new perspective. It can be directional (greater than, less than) or non-directional (not equal to).
The null hypothesis (H0) represents the status quo; the alternative hypothesis (HA) represents a new claim.
The goal is to find sufficient evidence to reject the null hypothesis in favor of the alternative. Failing to reject H0 does not mean H0 is true, only that there isn't enough evidence to reject it.
12.3 Framework and hypotheses
Hypotheses are set up to represent competing ideas about a population proportion (p).
- Example: Vaccination rates
- H0:p=0.333 (People guess randomly)
- HA:p=0.333 (People know more or less than random guessing)
- Null value (p0): The specific value of the proportion stated in the null hypothesis.
When setting hypotheses, always define the population parameter of interest.
12.4 Testing hypotheses using confidence intervals
A confidence interval can be used to test a hypothesis.
-
Conditions: For constructing a confidence interval for a proportion, we check:
- Independence: Data comes from a simple random sample.
- Success-failure condition: np^≥10 and n(1−p^)≥10.
-
Procedure:
- Construct a confidence interval for p.
- Check if the null hypothesized value (p0) falls within this interval.
- If p0 is within the interval, do not reject H0.
- If p0 is outside the interval, reject H0.
The confidence interval method is convenient but can only be used for non-directional hypotheses (p=p0).
12.5 Decision errors
Hypothesis tests can lead to incorrect conclusions.
| Test Conclusion | H0 True | HA True |
|---|---|---|
| Do not reject H0 | Okay (Correct) | Type 2 Error |
| Reject H0 in favor of HA | Type 1 Error | Okay (Correct) |
- Type 1 Error: Rejecting H0 when H0 is actually true.
- Type 2 Error: Failing to reject H0 when HA is actually true.
Reducing one type of error often increases the other type of error.
12.6 Formal testing using p-values
The p-value quantifies the strength of evidence against the null hypothesis.
- p-value: The probability of observing data at least as extreme as the current data, assuming the null hypothesis is true.
A small p-value indicates strong evidence against the null hypothesis.
1. <span style="color: #ff9f29; font-weight: 700;">Prepare:</span> Define parameter, state hypotheses ($H_0, H_A$), identify significance level ($\alpha$), and note sample statistic ($\hat{p}$) and sample size ($n$).
2. <span style="color: #ff9f29; font-weight: 700;">Check:</span> Verify conditions for the null distribution:
* Independence: Simple random sample.
* Success-failure condition (using null value): $np_0 \ge 10$ and $n(1-p_0) \ge 10$.
3. <span style="color: #ff9f29; font-weight: 700;">Calculate:</span> Compute the standard error using $p_0$, calculate the Z-score (test statistic), and determine the p-value from the null distribution.
4. <span style="color: #ff9f29; font-weight: 700;">Conclude:</span> Compare the p-value to $\alpha$.
* If $p$-value $< \alpha$, reject $H_0$.
* If $p$-value $\ge \alpha$, do not reject $H_0$.
Conclude in the context of the problem.
When performing hypothesis tests for a proportion, always use the null value (p0) to check conditions and calculate the standard error.
12.7 Choosing a significance level
The significance level (α) is the threshold for rejecting the null hypothesis.
- Traditional level: α=0.05.
- Adjusting α:
- Smaller α (e.g., 0.01): Used when Type 1 errors are very costly or dangerous. Requires stronger evidence to reject H0.
- Higher α (e.g., 0.10): Used when Type 2 errors are more costly. Easier to reject H0.
- More data: Collecting more data can reduce the Type 2 error rate without affecting the Type 1 error rate.
The choice of significance level depends on the consequences of Type 1 and Type 2 errors.
🔑 Important: Statistical inference involves quantifying uncertainty. Confidence intervals provide a range of plausible values for a parameter, while hypothesis tests rigorously evaluate claims about that parameter using evidence from data. Both methods require careful checking of conditions and clear interpretation in context.
12.8 Statistical significance versus practical significance
- Statistical significance means a result is unlikely due to random chance.
- Practical significance means a result has real-world value or importance.
- Large sample sizes can make tiny, unimportant differences statistically significant.
- A data scientist helps plan study sizes to detect meaningful differences.
With large sample sizes, even small differences can be statistically significant but not practically significant.
12.9 Choosing a significance level (α)
- The significance level, α, is the probability of a Type 1 error (rejecting a true null hypothesis).
- The default α = 0.05 is common but can be adjusted.
- Use a larger α (e.g., 0.10) when the cost of a Type 1 error is low, and switching is desired even with moderate evidence.
- Use a smaller α (e.g., 0.01) when the cost of a Type 1 error is high, and strong evidence is required before rejecting the null.
The choice of significance level depends on the consequences of making a Type 1 error.
Appropriate significance levels:
| Situation | Suggested α | Reason |
|---|---|---|
| Safety improvement desired | Larger (e.g., 0.10) | Eager to switch if there's moderate evidence of improvement. |
| Expensive part replacement | Smaller (e.g., 0.01) | Require very strong evidence before replacing a costly, non-critical part. |
| Critical safety violation risk | Smaller (e.g., 0.01) | High cost of Type 1 error (revoking license incorrectly). |
12.10 One-sided versus two-sided hypothesis tests
- A two-sided hypothesis test considers differences in either direction (p ≠ p₀).
- A one-sided hypothesis test is used when only one direction of difference is of interest (p < p₀ or p > p₀).
- One-sided tests can yield smaller p-values, making it easier to reject H₀.
- However, one-sided tests risk overlooking findings in the opposite direction.
Two-sided tests are generally preferred because they avoid missing unexpected results.
One-sided test considerations:
- Form: H<0xE2><0x82><0x90>: p < p₀ (parameter is less than null value)
- Form: H<0xE2><0x82><0x90>: p > p₀ (parameter is greater than null value)
- Null hypothesis: Always written with an equals sign (H₀: p = p₀).
- P-value calculation: Uses only the tail area in the direction of the alternative hypothesis.
Avoid one-sided tests if you would want to conclude something in the opposite direction of your alternative hypothesis 200.
Consequences of improper one-sided test use:
- If you choose a one-sided test after seeing the data, you can inflate your Type 1 error rate.
- Example: If H<0xE2><0x82><0x90>: p < 0.05 and H₀: p = 0.05, seeing p̂ > 0.05 would be disregarded.
- If H₀ is true, you have a 10% chance of rejecting it with a combined 5% tail in each direction, not the intended 5%.
Choosing a one-sided test after seeing the data inflates the Type 1 error rate to 0.10 201.
12.11 Common errors in hypothesis setup
- Hypotheses must be about population parameters (e.g., p), not sample statistics (e.g., p̂).
- The null hypothesis (H₀) must always contain an equals sign (=).
- The alternative hypothesis (H<0xE2><0x82><0x90>) must be mutually exclusive with H₀.
Incorrect hypothesis examples:
| Error Type | Incorrect Hypothesis | Correct Hypothesis (Example) | Reason |
|---|---|---|---|
| Sample statistic used | H₀ : p̂ < 0.6 | H₀ : p = 0.6 | Hypotheses are about population parameters. |
| Equals sign missing | H₀ : p = 0.24 | H₀ : p = 0.24 | Null must always contain equality. |
Always use population parameters (p) in hypotheses, not sample statistics (p̂).
🔑 Important: The null hypothesis (H₀) must always contain an equals sign. The sample proportion (p̂) is an estimate, not the parameter itself.
12.12 Confidence intervals and hypothesis testing
- Confidence intervals and hypothesis tests are related methods of inference.
- A confidence interval can often be used to perform a two-sided hypothesis test.
Relationship between confidence intervals and hypothesis tests:
| Scenario | Interpretation |
|---|---|
| Null hypothesized value (p₀) is outside the confidence interval. | Reject H₀ at the corresponding significance level. |
| Null hypothesized value (p₀) is inside the confidence interval. | Fail to reject H₀ at the corresponding significance level. |
- For a 95% confidence interval, you can test H₀: p = p₀ at α = 0.05.
- If a value is within a 95% CI, it may or may not be within a 99% CI (a wider interval).
- A wider confidence interval (higher confidence level) will contain more possible null values.
A confidence interval can perform a two-sided hypothesis test: if p₀ is outside the interval, reject H₀.
📝 Example: A 95% CI for p is (0.55, 0.65). If H₀: p = 0.50, we reject H₀ because 0.50 is outside the interval. If H₀: p = 0.60, we fail to reject H₀ because 0.60 is inside the interval 202.
🔑 Important: Decreasing the significance level (α) decreases the probability of a Type 1 error.
🔑 Important: Failing to reject H₀ does not prove that H₀ is true; it simply means there isn't enough evidence to reject it.
12.13 Factors affecting p-values and error rates
- Sample size (n): Larger sample sizes lead to smaller standard errors and generally smaller p-values for the same effect size.
- Effect size: The difference between the sample statistic and the null hypothesized value. A larger effect size usually leads to a smaller p-value.
- Significance level (α): This is the threshold for rejecting H₀. It does not change with the data.
Impact of sample size and observation:
- Same observation, different sample size: If a p-value is 0.08 with n=50, increasing n to 500 will generally decrease the p-value, making it more likely to be statistically significant.
- This is because the standard error decreases with a larger n, making the observed difference more extreme relative to the standard error.
Larger sample sizes generally result in smaller p-values for the same observed difference 205.
Type 2 Error Rate (β):
- β is the probability of failing to reject a false null hypothesis.
- A higher significance level (α, e.g., 0.10) typically leads to a lower Type 2 error rate (β) for a true alternative.
Comparison of factors:
| Factor | Effect on p-value (holding others constant) | Effect on Type 1 Error Rate | Effect on Type 2 Error Rate |
|---|---|---|---|
| Sample size (n) increases | Decreases | No change | Decreases |
| Effect size increases | Decreases | No change | Decreases |
| α increases | No change | Increases | Decreases |
🔑 Important: With large sample sizes, even small differences (effect sizes) can become statistically significant.
📝 Example: For a Z-statistic of 2.5, the p-value will be smaller with n=1000 than with n=500.
🔑 Important: Increasing the significance level (α) increases the chance of a Type 1 error but decreases the chance of a Type 2 error 203.
🔑 Important: The most exam-relevant insight is that statistical significance should be considered alongside practical significance, as large sample sizes can make trivial differences seem important 199.
13. Inference for categorical data (part 1)
13.1 Inference for a single proportion
Inference for a single proportion involves estimating or testing a population proportion (p). This relies on the sample proportion (p^) being approximately normally distributed.
13.2 Conditions for normality of sample proportion
The sampling distribution of p^ is approximately normal if:
- Independence: Sample observations are independent. This is usually met with a simple random sample.
- Success-failure condition: We expect at least 10 successes and 10 failures. This means np≥10 and n(1−p)≥10.
When these conditions are met, the sampling distribution of p^ has a mean of p and a standard error (SE) of p(1−p)/n. When p is unknown, we use p^ to check conditions and estimate SE for confidence intervals, and the null value (p0) for hypothesis tests.
Independence+Success-Failure⟹Normal distribution for $\hat{p}$
13.3 Confidence intervals for a proportion
A confidence interval provides a range of plausible values for the true population proportion (p).
Steps for constructing a confidence interval:
- Prepare: Identify p^, n, and the desired confidence level.
- Check: Verify independence and success-failure conditions. Use p^ to check success-failure for confidence intervals.
- Calculate: Compute SE using p^, find z⋆ for the confidence level, and calculate the interval: p^±z⋆×SE.
- Conclude: Interpret the interval in context.
For a 95% confidence interval, z⋆≈1.96.
📝 Example: A survey of 826 payday loan borrowers found 70% supported new regulations.
- Independence holds (random sample).
- Success-failure: np^≈826×0.70=578≥10 and n(1−p^)≈826×0.30=248≥10. Conditions met.
- SE≈0.70(1−0.70)/826≈0.016.
- 95% CI: 0.70±1.96×0.016≈(0.669,0.731).
- We are 95% confident the true proportion of borrowers supporting regulation is between 66.9% and 73.1%.
13.4 Hypothesis testing for a proportion
Hypothesis tests for a single proportion evaluate a claim about the population proportion (p).
Steps for hypothesis testing:
- Prepare: Define parameter, state hypotheses (H0,HA), identify significance level (α), and identify p^ and n.
- Check: Verify independence and success-failure conditions. Use the null value (p0) to check success-failure for hypothesis tests.
- Calculate: Compute SE using p0. Calculate the Z-score (test statistic): Z=(p^−p0)/SE. Find the p-value.
- Conclude: Compare the p-value to α to reject or fail to reject H0 and conclude in context.
The SE for a hypothesis test is SE=p0(1−p0)/n.
📝 Example: Test if more than 50% of borrowers support a regulation (H0:p=0.50,HA:p>0.50).
- Sample: n=826,p^=0.51.
- Independence holds.
- Success-failure (using p0=0.50): np0=826×0.5=413≥10 and n(1−p0)=826×0.5=413≥10. Conditions met.
- SE=0.5(1−0.5)/826≈0.017.
- Z=(0.51−0.50)/0.017≈0.59.
- P-value ≈0.2776 (one-tail). If α=0.05, we fail to reject H0. No convincing evidence of majority support.
13.5 When conditions aren’t met
If the success-failure condition fails, simulation methods or the Clopper-Pearson interval can be used. For independence issues, especially with non-random samples, advanced methods or acknowledging bias is necessary.
13.6 Choosing a sample size
To ensure a desired margin of error (ME) for a confidence interval, we can calculate the required sample size (n).
The margin of error is ME=z⋆×SE=z⋆p(1−p)/n.
To solve for n: n≥ME2(z⋆)2×p(1−p)
If the population proportion (p) is unknown, use p=0.5 for the worst-case scenario, which maximizes the required sample size. Always round up to the next whole number.
📝 Example: Need ME < 0.04 at 95% confidence.
- z⋆=1.96. Use p=0.5.
- n≥(0.04)2(1.96)2×0.5(1−0.5)≈600.25.
- We need at least 601 participants.
If an estimate of p is available, use that value instead of 0.5 for a potentially smaller sample size.
🔑 Important: Always round up the calculated sample size to ensure the margin of error is met.
13.7 Difference of two proportions
This section extends inference to the difference between two population proportions (p1−p2). The point estimate is the difference between sample proportions, p^1−p^2.
13.8 Sampling distribution of the difference of two proportions
The difference p^1−p^2 can be modeled using a normal distribution if:
- Independence: Data are independent within and between the two groups (e.g., independent random samples or randomized experiment).
- Success-failure condition: Holds for both groups separately (n1p1≥10,n1(1−p1)≥10 and n2p2≥10,n2(1−p2)≥10).
When conditions are met, the SE is: SE=n1p1(1−p1)+n2p2(1−p2)
13.9 Confidence intervals for p1−p2
Confidence intervals for the difference of two proportions follow the general formula: Point estimate ±z⋆×SE p^1−p^2±z⋆×n1p^1(1−p^1)+n2p^2(1−p^2)
We use sample proportions (p^1,p^2) to estimate SE for confidence intervals.
📝 Example: CPR study: 11/50 control survived, 14/40 treatment survived.
- Independence: Randomized experiment (met).
- Success-failure: Control (11,39), Treatment (14,26). All counts ≥10 (met).
- p^c=11/50=0.22, p^t=14/40=0.35.
- Point estimate: p^t−p^c=0.35−0.22=0.13.
- SE≈400.35(0.65)+500.22(0.78)≈0.095.
- 90% CI: 0.13±1.6449×0.095≈(−0.026,0.286).
- We are 90% confident that blood thinners increase survival rate by -2.6 to +28.6 percentage points. Since 0 is in the interval, no significant effect can be concluded.
13.10 Hypothesis tests for the difference of two proportions
Hypothesis tests for p1−p2 often test if the proportions are equal (H0:p1−p2=0, or p1=p2).
When testing H0:p1=p2, we use a pooled proportion to calculate the SE, as we are assuming the proportions are equal under the null hypothesis. p^pooled=n1+n2n1p^1+n2p^2 SEpooled=p^pooled(1−p^pooled)(n11+n21)
The test statistic is: Z=SEpooledp^1−p^2
🔑 Important: For hypothesis tests on the difference of two proportions, use the pooled proportion to calculate SE if H0:p1=p2. Use individual sample proportions for confidence intervals.
🔑 Important: Inference for categorical data (part 1) covers foundational methods for single proportions and differences between two proportions, relying heavily on the normal approximation. Understanding the conditions for normality is critical for applying these techniques correctly.
13.11 Hypothesis testing for two proportions
When testing hypotheses about two proportions, we often assume the null hypothesis is that the proportions are equal (p1−p2=0). In this specific case, we use a special value called the <span style="color: #ff9f29; font-weight: 700;">pooled proportion</span> (p^pooled) to check conditions and calculate the standard error.
-
Pooled proportion: An estimate of the true proportion across both samples combined. It's calculated as the total number of successes divided by the total number of cases in both samples. \hat{p}_{pooled} = \frac{\text{# successes in sample 1} + \text{# successes in sample 2}}{n_1 + n_2} This is used when H0:p1−p2=0.
-
Success-failure condition: To use the normal distribution for inference, we need at least 10 successes and 10 failures in each group. When H0:p1−p2=0, we check this condition using the pooled proportion.
- p^pooled×n1≥10
- (1−p^pooled)×n1≥10
- p^pooled×n2≥10
- (1−p^pooled)×n2≥10
🔑 Important: The pooled proportion is only used when the null hypothesis states that the two proportions are equal.
13.12 Calculating the point estimate and standard error
The point estimate for the difference in proportions is simply the difference between the sample proportions: p^1−p^2.
The standard error (SE) when H0:p1−p2=0 is calculated using the pooled proportion: SE=p^pooled(1−p^pooled)(n11+n21)
This formula can be broken down from the standard errors of individual proportions: SEp^1−p^2=SEp^12+SEp^22=n1p1(1−p1)+n2p2(1−p2)
🔑 Important: When H0 is not p1−p2=0 (i.e., a difference other than zero is hypothesized), we use the individual sample proportions (p^1,p^2) to calculate the standard error, not the pooled proportion.
13.13 Performing the hypothesis test
Once the point estimate and standard error are calculated, a Z-test statistic is computed: Z=SEpoint estimate−null value
The p-value is then determined from the Z-statistic using the standard normal distribution. A conclusion is drawn based on comparing the p-value to the significance level.
📝 Example: In a mammogram study, the null hypothesis was that the breast cancer death rate was the same for mammogram and control groups (pmgm−pctrl=0). The pooled proportion was calculated to be 0.0112. After checking the success-failure condition, the point estimate was −0.00012 and the standard error was 0.00070. The Z-statistic was 0.00070−0.00012−0=−0.17. This resulted in a p-value of 0.8650, leading to the conclusion that there is not enough evidence to reject the null hypothesis.
🔑 Important: When interpreting the results of a hypothesis test, remember that failing to reject the null hypothesis does not prove it is true. It simply means there isn't enough evidence to conclude it's false. Consider practical significance, costs, and other factors beyond the statistical test.
Hypothesis testing summary for two proportions:
| Scenario | Null Hypothesis | Pooled Proportion (p^pooled) | Standard Error (SE) |
|---|---|---|---|
| Proportions are equal (p1=p2) | p1−p2=0 | Yes (for conditions and SE) | p^pooled(1−p^pooled)(n11+n21) |
| Proportions have a specific difference | p1−p2=d | No (use p^1,p^2 for SE) | n1p^1(1−p^1)+n2p^2(1−p^2) |
🔑 Important: Always check the conditions for inference, especially the success-failure condition, before proceeding with the hypothesis test. If conditions are not met, the results may not be reliable.
14. Inference for categorical data (part 2)
14.1 Difference of two proportions
This section covers inference for the difference between two proportions. This is used when comparing proportions from two independent groups.
14.2 Confidence intervals for the difference
- A confidence interval for the difference between two proportions (p^1−p^2) provides a range of plausible values for the true difference.
- The formula for a confidence interval is: (p^1−p^2)±z∗n1p^1(1−p^1)+n2p^2(1−p^2).
- Conditions to check:
- Independence: Samples must be independent, and observations within each sample must be independent.
- Sample size: At least 10 expected successes and 10 expected failures in each group (np^≥10 and n(1−p^)≥10).
Confidence interval widens with higher confidence levels.
14.3 Hypothesis tests for the difference
-
Hypothesis tests are used to determine if there is convincing evidence of a difference between two proportions.
-
The null hypothesis is typically H0:p1=p2 or H0:p1−p2=0.
-
The alternative hypothesis can be HA:p1=p2, HA:p1>p2, or HA:p1<p2.
-
When H0 is true, we pool the proportions to estimate the standard error: p^pool=n1+n2X1+X2.
-
The test statistic is z=p^pool(1−p^pool)(n11+n21)(p^1−p^2)−0.
-
Conditions for hypothesis testing are the same as for confidence intervals.
-
Type I Error: Rejecting H0 when it is true.
-
Type II Error: Failing to reject H0 when it is false.
14.4 Chi-square tests
Chi-square tests are used to analyze categorical data, particularly for comparing observed counts to expected counts.
14.5 Chi-square test for goodness of fit
- This test assesses if a sample's distribution across multiple categories matches a hypothesized distribution.
- It's used when you have one categorical variable with more than two categories.
Hypotheses:
- H0: The observed counts follow the specified distribution.
- HA: The observed counts do not follow the specified distribution.
Test Statistic:
- The chi-square (χ2) statistic measures the discrepancy between observed (Oi) and expected (Ei) counts: χ2=∑i=1kEi(Oi−Ei)2 where k is the number of categories.
Distribution:
- If H0 is true and expected counts are ≥5, the test statistic follows a chi-square distribution with df=k−1.
Conditions:
- Independence: Individual observations are independent.
- Expected Counts: Each expected count must be at least 5.
Higher χ2 values indicate a greater difference between observed and expected counts.
| Category | Observed Count (Oi) | Expected Count (Ei) | Ei(Oi−Ei)2 |
|---|---|---|---|
| White | 205 | 198 | 198(205−198)2≈0.25 |
| Black | 26 | 19.25 | 19.25(26−19.25)2≈2.38 |
| Hispanic | 25 | 33 | 33(25−33)2≈1.94 |
| Other | 19 | 24.75 | 24.75(19−24.75)2≈1.35 |
| Total | 275 | 275 | χ2≈5.92 |
- The degrees of freedom are k−1=4−1=3.
- A p-value is found using the chi-square distribution with df=3.
14.6 Chi-square test for independence
-
This test examines whether there is an association between two categorical variables presented in a two-way table.
-
It tests if the variables are independent or dependent.
-
H0: The two categorical variables are independent.
-
HA: The two categorical variables are dependent (associated).
-
The same χ2 test statistic formula is used: χ2=∑Ei(Oi−Ei)2.
-
Expected counts (Eij) are calculated as: Eij=grand total(row total)×(column total).
-
The test statistic follows a chi-square distribution with df=(number of rows−1)×(number of columns−1).
-
Independence: Observations are independent, and the two variables are from the same sample or independent samples.
If variables are independent, observed counts should be close to expected counts.
| Example: Support for Scanning by Party Affiliation | Support: Republican | Support: Democrat | Support: Independent | Row Total |
|---|---|---|---|---|
| Should | 264 | 299 | 351 | 914 |
| Should not | 38 | 55 | 77 | 170 |
| Don't know | 16 | 15 | 22 | 53 |
| Column Total | 318 | 369 | 450 | 1137 |
- For the "Should" row, the expected counts would be:
- Republican: 1137914×318≈255.7
- Democrat: 1137914×369≈296.2
- Independent: 1137914×450≈362.1
- The degrees of freedom are (3−1)×(3−1)=4.
📝 Example: If a χ2 test for independence yields a small p-value, we reject the null hypothesis of independence. This suggests the two variables are associated.
14.7 Finding p-values with the chi-square distribution
- The chi-square (χ2) distribution is a right-skewed distribution used for χ2 test statistics.
- Its shape is determined by the degrees of freedom (df). As df increases, the distribution becomes more symmetric and shifts to the right.
- P-values for χ2 tests are always the area in the upper tail of the distribution, as larger χ2 values provide stronger evidence against the null hypothesis.
| Degrees of Freedom (df) | Cutoff Value | Upper Tail Area (p-value) |
|---|---|---|
| 3 | 6.25 | 0.1001 |
| 2 | 4.3 | 0.1165 |
| 5 | 5.1 | 0.4038 |
| 7 | 11.7 | 0.1109 |
| 4 | 10 | 0.0404 |
| 3 | 9.21 | 0.0266 |
🔑 Important: P-values for chi-square tests are always calculated as the area to the right of the test statistic.
🔑 Important: When performing a chi-square test, ensure all expected counts are at least 5 to use the chi-square distribution reliably.
🔑 Important: The degrees of freedom for a chi-square goodness-of-fit test are k−1 (number of categories minus one), and for a chi-square test of independence, they are (number of rows - 1) * (number of columns - 1).
14.8 Testing for goodness-of-fit using chi-square
This test checks if observed counts for a single categorical variable match expected counts based on a theory or hypothesis.
-
Hypotheses:
- H0: The observed counts fit the expected distribution.
- Ha: The observed counts do not fit the expected distribution.
-
Chi-square statistic: This measures the discrepancy between observed (Oi) and expected (Ei) counts for each category i. X2=∑Ei(Oi−Ei)2
-
Degrees of freedom: For a goodness-of-fit test, df=k−1, where k is the number of categories.
-
Conditions:
- Data are counts for categorical variables.
- Observations are independent.
- Expected counts for each category are at least 5.
The chi-square distribution is always right-skewed 239.
14.9 Testing for independence in two-way tables
This test determines if there is an association between two categorical variables presented in a two-way table.
* $H_0$: The two variables are independent.
* $H_a$: The two variables are dependent.
- Expected counts: For a cell in row i and column j, the expected count is calculated as: Eij=table total(row i total)×(column j total)
- Chi-square statistic: Calculated similarly to the goodness-of-fit test, using observed and expected counts for each cell. X2=∑Eij(Oij−Eij)2
- Degrees of freedom: For a two-way table, df=(R−1)×(C−1), where R is the number of rows and C is the number of columns.
- Data are counts for two categorical variables.
- Expected counts for each cell are at least 5.
This test is used when you want to know if two categorical variables are related 240.
Calculating expected values for a two-way table
Chi-square test components
| Component | Formula | Example (iPod study) |
|---|---|---|
| Chi-square statistic (X2) | ∑Exp(Obs−Exp)2 | 40.13 |
| Degrees of freedom (df) | (R−1)×(C−1) | 2 |
📝 Example: In a study testing if buyer questions influence seller disclosure about an iPod's freezing issue, the observed count of "Disclose Problem" for the "General" question was 2. The expected count was 20.33. The contribution to the chi-square statistic from this cell is 20.33(2−20.33)2≈16.53.
🔑 Important: The degrees of freedom calculation for a two-way table is crucial and differs from a one-way table. It depends on the dimensions of the table.
📝 Example: For a Type 2 Diabetes study with 3 treatments (rows) and 2 outcomes (columns), the df=(3−1)×(2−1)=2. A calculated X2 of 8.16 with df=2 yields a p-value of 0.017, leading to rejection of the null hypothesis 244.
🔑 Important: When conducting a chi-square test for independence, always ensure the expected counts for all cells are at least 5. If not, consider combining categories if theoretically justifiable 242.
🔑 Important: The chi-square test for independence assesses whether two categorical variables are associated. If the p-value is less than the significance level (α), we reject H0 and conclude the variables are dependent 243.
15. Inference for categorical data (part 3)
15.1 Testing for independence in two-way tables
This section covers testing for association between two categorical variables presented in a two-way table.
- Purpose: To determine if there is a statistically significant relationship between two categorical variables.
- Method: Uses a chi-square (χ2) test.
15.1.1 Hypotheses for testing independence
- Null Hypothesis (H0): The two categorical variables are independent. There is no association between them.
- Alternative Hypothesis (HA): The two categorical variables are dependent. There is an association between them.
15.1.2 Conditions for chi-square test
- Randomness: Data should come from a random sample or randomized experiment.
- Independence: Individual observations should be independent. For two-way tables, this means the sample size should be less than 10% of the population size for each group.
- Sample Size: Expected counts for each cell in the two-way table must be at least 5.
15.1.3 Calculating expected counts
Expected counts are crucial for the chi-square test. They represent the counts we would expect if the null hypothesis of independence were true.
- Formula: Expected Count=Grand Total(Row Total)×(Column Total)
15.1.4 The chi-square statistic
The chi-square statistic measures the discrepancy between observed and expected counts.
- Formula: χ2=∑Expected(Observed−Expected)2 where the sum is over all cells in the table.
15.1.5 Degrees of freedom
The degrees of freedom determine the shape of the chi-square distribution.
- Formula: df=(Number of Rows−1)×(Number of Columns−1)
15.1.6 Interpreting the results
A small p-value (typically < 0.05) suggests strong evidence against the null hypothesis, indicating an association between the variables.
🔑 Important: A statistically significant association means a relationship exists, but it doesn't imply causation.
15.2 Sample size considerations
Calculating the required sample size is important for surveys and experiments.
15.2.1 Sample size for a proportion
When planning a study, we often need to determine the sample size required to achieve a specific margin of error.
- Formula:
n=p∗(1−p∗)(MEz∗)2 where:
- n is the sample size.
- p∗ is a prior estimate of the sample proportion (use 0.5 if no estimate is available).
- z∗ is the critical value for the desired confidence level.
- ME is the desired margin of error.
🔑 Important: Using p∗=0.5 provides the most conservative (largest) sample size estimate.
15.2.2 Impact of sample size on confidence intervals
- Larger sample size: Leads to a smaller margin of error and a narrower confidence interval.
- Smaller sample size: Leads to a larger margin of error and a wider confidence interval.
15.2.3 Sample size and statistical significance
- A larger sample size can detect smaller differences as statistically significant.
- However, a statistically significant difference might not be practically significant if the sample size is very large.
🔑 Important: Understanding inference for categorical data allows us to draw conclusions about populations based on sample data, especially when dealing with counts and proportions.
16. Inference for numerical data (part 1)
16.1 One-sample means with the t-distribution
This section covers inference for a single population mean using the t-distribution.
16.2 Sampling distribution of the sample mean
- The sample mean (xˉ) tends to follow a normal distribution centered at the population mean (μ).
- The standard error (SE) of the sample mean is calculated as σ/n, where σ is the population standard deviation and n is the sample size.
Central Limit Theorem for Sample Mean When n is sufficiently large and observations are independent:
- Mean of xˉ = μ
- Standard Error (SE) = σ/n
16.3 Conditions for inference for a sample mean
Two main conditions must be met for valid inference:
- Independence: Sample observations must be independent. This is often satisfied by using a simple random sample.
- Normality:
- If n<30: The population should be approximately normal, with no clear outliers in the sample.
- If n≥30: The sampling distribution of xˉ is approximately normal, even if the population is not, as long as there are no particularly extreme outliers.
🔑 Important: For n<30, no outliers means we assume approximate normality. For n≥30, we worry about extreme outliers, not mild skew.
16.4 The t-distribution
- When the population standard deviation (σ) is unknown, we use the sample standard deviation (s) to estimate the standard error: SE≈s/n.
- This estimation introduces uncertainty, which is accounted for by the t-distribution.
- The t-distribution is bell-shaped but has thicker tails than the normal distribution, indicating a higher probability of observing extreme values.
Degrees of freedom (df)
- The shape of the t-distribution is determined by its degrees of freedom.
- For inference about a single mean, df=n−1.
- As df increases, the t-distribution approaches the normal distribution.
| df Value | Shape Relative to Normal |
|---|---|
| Low | Thicker tails |
| High | Closer to normal |
📝 Example: A t-distribution with 2 degrees of freedom has significantly thicker tails than a normal distribution, leading to a larger area beyond 3 units from the mean (0.0955 vs. ~0.003).
16.5 One-sample t-confidence intervals
A confidence interval for the population mean (μ) using the t-distribution is:
point estimate±margin of error xˉ±tdf∗×SE
where:
- xˉ is the sample mean.
- tdf∗ is the critical t-value for the given confidence level and degrees of freedom.
- SE=s/n is the estimated standard error.
Steps for constructing a confidence interval:
- Prepare: Identify xˉ, s, n, and the confidence level.
- Check: Verify independence and normality conditions.
- Calculate: Compute SE, find tdf∗, and construct the interval: xˉ±tdf∗×(s/n).
- Conclude: Interpret the interval in the context of the problem.
🔑 Important: A confidence interval provides a range of plausible values for the population mean, not for individual observations.
16.6 One-sample t-tests
Hypothesis testing for a single population mean (μ) using the t-distribution follows a similar process to one-sample proportion tests.
Hypotheses:
- H0:μ=μ0 (Null hypothesis: the population mean is equal to a specific value).
- HA:μ=μ0 or μ<μ0 or μ>μ0 (Alternative hypothesis: the population mean is different from, less than, or greater than the specific value).
Test statistic (T-score): T=SExˉ−μ0 where SE=s/n.
p-value: The probability of observing a test statistic as extreme as, or more extreme than, the one calculated, assuming the null hypothesis is true. This is found using the t-distribution with df=n−1.
Steps for conducting a hypothesis test:
- Prepare: Identify the parameter of interest, hypotheses, significance level (α), xˉ, s, and n.
- Check: Verify conditions for inference (independence and normality).
- Calculate: Compute SE, the T-score, and the p-value.
- Conclude: Compare the p-value to α to make a decision about rejecting H0 and interpret the conclusion in context.
🔑 Important: If p<α, reject H0. If p≥α, fail to reject H0.
16.7 Paired data
Paired data arises when two sets of observations have a special correspondence, such as before-and-after measurements on the same subject.
16.8 Paired observations
- Two sets of observations are paired if each observation in one set has a direct link to an observation in the other set.
- Analyzing paired data often involves calculating the difference for each pair. The order of subtraction must be consistent.
16.9 Inference for paired data
Inference for paired data is performed by analyzing the differences between the paired observations. This is essentially a one-sample inference problem on the differences.
- Calculate the sample mean of the differences (xˉdiff).
- Calculate the sample standard deviation of the differences (sdiff).
- Use the t-distribution techniques from Section 7.1 with ndiff (the number of pairs) and df=ndiff−1.
Hypothesis test for paired data:
- H0:μdiff=0 (There is no difference on average).
- HA:μdiff=0 (There is a difference on average).
Test statistic: T=sdiff/ndiffxˉdiff−0
🔑 Important: Treat the differences as a single sample to perform inference.
🔑 Important: This entire topic, covering one-sample means with the t-distribution and paired data analysis, is crucial for understanding how to make inferences about population means when the population standard deviation is unknown. Mastering the conditions and application of the t-distribution is key for exam success.
16.10 Paired data
Paired data involves observations that are collected in pairs. This often happens when measuring the same subject twice (e.g., before and after a treatment) or when matching subjects based on certain characteristics.
Inference for paired data focuses on the differences between these paired observations.
16.11 Identifying paired data
- Paired data: Occurs when each observation in one dataset has a natural correspondence with exactly one observation in another dataset.
- Independent data: Observations in the two groups do not have a natural correspondence.
| Scenario | Paired? | Reasoning |
|---|---|---|
| Comparing pre- and post-test scores for the same students. | Yes | Same students are measured twice. |
| Assessing gender salary gap by comparing randomly sampled men and women. | No | Men and women are sampled independently; no direct pairing. |
| Comparing artery thickness before and after Vitamin E for the same patients. | Yes | Same patients are measured twice. |
| Assessing diet effectiveness by comparing before and after weights of subjects. | Yes | Same subjects are measured twice. |
| Comparing Intel and Southwest stock returns on 50 randomly sampled days. | Yes | Each day's returns are paired for both stocks. |
| Comparing prices of 50 items at Target and Walmart, collecting prices for each item. | Yes | Each item's price is directly compared between the two stores. |
| Comparing SAT scores of students from two different high schools via random samples. | No | Students are sampled independently from each school; no direct pairing. |
[ ] 265.
16.12 Inference for paired data
To perform inference on paired data, we first calculate the difference for each pair. Then, we treat these differences as a single sample and proceed with one-sample inference methods.
-
Procedure:
- Calculate the difference for each pair: di=xi1−xi2.
- Perform one-sample inference (e.g., t-test, t-interval) on these differences.
-
Conditions for paired t-tests/intervals:
- Independence: The paired differences must be independent of each other.
- Normality: The distribution of the paired differences should be approximately normal, or the sample size of differences should be large enough (n≥30).
Paired data analysis focuses on the differences between matched pairs.
16.13 Difference of two means (independent samples)
This section covers inference for the difference between two population means, μ1−μ2, when the data comes from two independent samples. The core ideas are similar to one-sample mean procedures, but adapted for two separate groups.
16.14 When to use independent samples inference
This method is used when comparing the means of two distinct groups where the observations in one group do not influence the observations in the other.
- Motivating question: Is there convincing evidence that one group's average is different from another's?
- Example: Do mothers who smoke have newborns with different average birth weights than those who don't?
16.15 Confidence interval for a difference of means
We aim to construct a confidence interval for the true difference between two population means, μ1−μ2.
-
Point estimate: The difference between the sample means, xˉ1−xˉ2.
-
Conditions for using the t-distribution:
- Independence: Data are independent within and between the two groups. This usually means random sampling or randomization in an experiment.
- Normality: The data in each group should be approximately normally distributed, or the sample sizes should be large (n1≥30 and n2≥30). Outliers should not be present in either group.
-
Standard error calculation: SE=n1s12+n2s22 where s1 and s2 are the sample standard deviations, and n1 and n2 are the sample sizes for the two groups.
-
Degrees of freedom (df):
- A conservative approach for calculation is to use the smaller of (n1−1) and (n2−1).
- Statistical software often computes a more precise, complex df.
For independent samples, use the t-distribution if groups are independent and roughly normal.
📝 Example: In a study on embryonic stem cells (ESCs) and heart function, the mean change in pumping capacity was 3.50 for the ESC group (n=9,s=5.17) and -4.33 for the control group (n=9,s=2.76). The point estimate for the difference is 3.50−(−4.33)=7.83. Using df=min(9−1,9−1)=8, the standard error is 95.172+92.762≈1.95. [ 268 267.
🔑 Important: The standard error for the difference between two means combines the variability from both samples, accounting for their respective sizes.
🔑 Important: When using t-tables without software, use the minimum of (n1−1) and (n2−1) for degrees of freedom to be conservative.
📝 Example: For the ESC study with n1=9 and n2=9, the degrees of freedom would be df=min(9−1,9−1)=8. [ ] 268.
🔑 Important: If a confidence interval for μ1−μ2 includes 0, it suggests there is no statistically significant difference between the population means at that confidence level.
🔑 Important: The conclusion from a hypothesis test about the difference of means should align with the findings of a confidence interval for the same difference. If the hypothesis test rejects the null hypothesis (of no difference), the confidence interval should not contain 0.
🔑 Important: For inference on numerical data, paired data analysis looks at the differences within pairs, while independent samples analysis looks at the difference between the means of two separate groups.
🔑 Important: The use of the t-distribution for inference on numerical data (both one-sample and two-sample) relies on assumptions of independence and approximate normality.
17. Inference for numerical data (part 2)
17.1 Difference of two means
This section covers hypothesis testing and confidence intervals for the difference between two population means, assuming independent samples. The process involves preparing hypotheses, checking conditions, calculating statistics, and concluding with an interpretation.
- Preparation: Identify critical information and set up hypotheses.
- Check: Verify necessary conditions are met.
- Calculate: Compute standard error, confidence interval, test statistic, or p-value.
- Conclude: Interpret results in the context of the problem.
17.2 Hypothesis tests for difference of two means
Hypothesis tests are used to determine if there is convincing evidence of a difference between two population means.
- Null Hypothesis (H0): States there is no difference between the population means (μ1−μ2=0).
- Alternative Hypothesis (HA): States there is a difference (e.g., μ1−μ2=0, μ1−μ2>0, or μ1−μ2<0).
Conditions for using the t-distribution:
- Independence: Observations must be independent within and between samples.
- Sample Size: Both sample sizes should be sufficiently large (often n>30) or the data should be approximately normally distributed, with no extreme outliers.
Point Estimate: The difference between sample means (xˉ1−xˉ2).
Standard Error (SE): Calculated as SE=n1s12+n2s22.
Test Statistic (T): T=SE(xˉ1−xˉ2)−(null value).
Degrees of Freedom (df): Typically, the smaller of n1−1 and n2−1, though more complex formulas exist.
The t-distribution is used when the population standard deviation is unknown.
17.3 Confidence intervals for difference of two means
Confidence intervals provide a range of plausible values for the true difference between two population means.
- Formula: Point estimate ±t∗×SE.
- t∗ is the critical value from the t-distribution for the desired confidence level and degrees of freedom.
A 95% confidence interval means we are 95% confident that the true difference between population means falls within the calculated range.
17.4 Pooled standard deviation estimate
This method is used when there is strong evidence that the population standard deviations of the two groups are equal.
- Pooled Variance (spooled2): spooled2=n1+n2−2s12(n1−1)+s22(n2−1).
- Pooled Standard Error: Use spooled in the standard error formula.
- Degrees of Freedom (df): df=n1+n2−2.
Pool standard deviations only after careful consideration, as it assumes equal population variances.
| Condition for Pooling | Requirement |
|---|---|
| Population Variances | Strong evidence that σ12=σ22. |
| Sample Size | Large sample sizes may reduce benefits of pooling. |
17.5 Power calculations for a difference of means
Power calculations are crucial for experiment planning. They help determine the sample size needed to detect important effects with a certain probability.
17.6 Hypothesis testing setup for power analysis
This involves setting up a hypothesis test framework to frame sample size calculations.
- Hypotheses: Typically two-sided for clinical trials.
- H0:μtreatment−μcontrol=0
- HA:μtreatment−μcontrol=0
Assumptions:
- An estimate of the standard deviation (σ) is available from prior studies.
- The distribution of the difference in means is approximately normal for large sample sizes.
17.7 Calculating power
Power is the probability of detecting a practically important effect if it truly exists.
- Minimum Effect Size of Interest: The smallest difference that has practical value (e.g., 3 mmHg).
- Null Distribution: Centered at 0, with standard error calculated from assumed σ and sample size (n).
- Alternative Distribution: Centered at the minimum effect size of interest, with the same standard error.
- Power: The proportion of the alternative distribution that falls into the rejection region of the null hypothesis.
Power is the probability of correctly rejecting a false null hypothesis.
| Calculation Step | Description |
|---|---|
| 1. Standard Error | SE=n1σ2+n2σ2 |
| 2. Null Distribution | Mean = 0, SD = SE. Defines rejection regions based on α. |
| 3. Alt. Distribution | Mean = minimum effect size, SD = SE. |
| 4. Calculate Power | Probability of observing a test statistic in the rejection region under the alternative distribution. |
Approximation: For large sample sizes (n≥30), the normal distribution can approximate the t-distribution.
17.8 Determining a proper sample size
This involves solving backward to find the sample size (n) that yields a desired power (commonly 80% or 90%) at a given significance level (α).
- The calculation sets the distance between the centers of the null and alternative distributions equal to the minimum effect size of interest. This distance is expressed in terms of the standard error and Z-scores corresponding to the desired power and α.
A sample size of approximately 251 per group might be needed for 80% power to detect a 3 mmHg difference with α=0.05.
🔑 Important: The power of a test increases with larger sample sizes, larger effect sizes, and a larger significance level (α).
17.9 Power calculations for a difference of means
- Power calculations are essential for expensive or risky experiments.
- They help determine the necessary sample size to detect a specific effect size.
- The required sample size depends on:
- Significance level (α).
- Desired power level.
- Minimum effect size of interest.
- Population standard deviation.
The difference between the centers of the null and alternative distributions, measured in standard errors (SE), influences the required sample size. For a power of 90% and α=0.01, this difference needs to be about 3.86 SE.
- For inexpensive experiments or when a more precise estimate is valuable, larger sample sizes might be justified.
17.10 Comparing many means with ANOVA
- Analysis of Variance (ANOVA) is a statistical method used to compare means across three or more groups.
- It avoids the problem of inflated Type 1 error rates associated with conducting multiple pairwise comparisons.
- ANOVA tests the following hypotheses:
- Null Hypothesis (H0): All group means are equal (μ1=μ2=⋯=μk).
- Alternative Hypothesis (HA): At least one group mean is different.
ANOVA asks: Are the differences between group means larger than what we expect from random chance?
- Three conditions must be met before performing ANOVA:
- Observations are independent within and across groups.
- Data within each group are nearly normal.
- Variability across groups is approximately equal.
17.11 Core ideas of ANOVA
- ANOVA assesses the variability of group means relative to the variability within individual observations in each group.
- Visually, large differences in group centers are noticeable when they are large relative to the variability within each group.
📝 Example: If groups I, II, and III have similar means but high within-group variation, differences might be due to chance. If groups IV, V, and VI have clearly different means with low within-group variation, the differences are likely real.
- Hypotheses for comparing means across groups are stated as:
- H0: μ1=μ2=⋯=μk (average outcome is the same across all groups).
- HA: At least one mean is different.
17.12 Application: Batting performance and player position in MLB
- This example uses on-base percentage (OBP) to compare batting performance across three player positions: outfielder (OF), infielder (IF), and catcher (C).
- The dataset includes 429 MLB players.
| Variable | Description |
|---|---|
| name | Player name |
| team | Abbreviated team name |
| position | Player's primary field position (OF, IF, C) |
| AB | Number of opportunities at bat |
| H | Number of hits |
| HR | Number of home runs |
| RBI | Number of runs batted in |
| AVG | Batting average (H/AB) |
| OBP | On-base percentage (fraction of times a player gets on base or hits a home run) |
- H0: The average on-base percentage is equal across the three positions (OF, IF, C).
- HA: The average on-base percentage varies across some (or all) groups.
| Position | Sample size (ni) | Sample mean (xˉi) | Sample SD (si) |
|---|---|---|---|
| OF | 160 | 0.320 | 0.043 |
| IF | 205 | 0.318 | 0.038 |
| C | 64 | 0.302 | 0.038 |
- A point estimate for the mean OBP for outfielders (μOF) is the sample average xˉOF=0.320.
- Visual inspection of box plots shows that variability appears approximately constant across groups, an important ANOVA assumption.
🔑 Important: Inspecting data to choose which groups to formally test can inflate the Type 1 error rate. This practice is called "data snooping" or "data fishing."
🔑 Important: ANOVA provides a single test to determine if any group means differ, avoiding issues with multiple comparisons.
🔑 Important: For inferring differences in numerical data, understanding power calculations for differences of means and using ANOVA for comparing multiple means are key exam topics.
18. Inference for numerical data (part 3)
18.1 Analysis of variance (ANOVA)
Analysis of variance (ANOVA) is a statistical method used to test if the means of two or more groups differ significantly. It assesses whether the variability observed among sample means is larger than what would be expected due to random chance alone.
-
Core question: Is the variability in sample means large enough to suggest real differences between groups, not just random variation?
-
When to use: To compare means across multiple groups simultaneously.
Key Concepts:
- Mean Square Between Groups (MSG): Measures the variability of the sample means across the different groups. It is a scaled variance for group means.
- Mean Square Error (MSE): Also known as pooled variance, it estimates the variability within each group. It represents the typical variation expected if the null hypothesis were true.
ANOVA asks if between-group differences are much larger than within-group differences.
18.2 The F-test statistic
The F-test statistic is the ratio of the between-group variability to the within-group variability.
F=MSEMSG
-
MSG: Variability between group means.
-
MSE: Variability within groups.
-
If the null hypothesis (H0) is true (all group means are equal), MSG and MSE should be roughly equal.
-
A larger F-value indicates stronger evidence against H0.
ANOVA Calculations Summary:
| Component | Formula/Description | Degrees of Freedom (df) |
|---|---|---|
| Mean Square Between | MSG=k−1SSG | dfG=k−1 |
| Mean Square Error | MSE=n−kSSE | dfE=n−k |
| F-statistic | F=MSEMSG | df1=dfG, df2=dfE |
Where:
- k is the number of groups.
- n is the total sample size.
- SSG is the sum of squares between groups.
- SSE is the sum of squares error (within groups).
The F-statistic follows an F-distribution with df1=k−1 and df2=n−k. The p-value is found using the upper tail of this distribution.
📝 Example: For baseball data, MSG = 0.00803 and MSE = 0.00158. With k=3 groups and n=429 total observations, dfG=2 and dfE=426. The F-statistic is F=0.001580.00803≈5.08 289.
18.3 ANOVA table and interpretation
Statistical software typically summarizes ANOVA results in a table, providing the F-statistic and p-value.
ANOVA Summary Table Structure:
- The p-value from the ANOVA table indicates the strength of evidence against the null hypothesis.
- A small p-value (typically < 0.05) suggests that there are significant differences in means among the groups.
📝 Example: An ANOVA table shows an F-value of 5.0766 and a p-value of 0.0066. Since 0.0066 < 0.05, we reject the null hypothesis, concluding that the average on-base percentage varies by player position 290.
18.4 Conditions for ANOVA
For ANOVA to be valid, three conditions must be met:
- Independence: Observations within and between groups must be independent. This is usually satisfied with random sampling.
- Approximately Normal: The data within each group should be approximately normally distributed. Histograms and Q-Q plots can assess this. For larger sample sizes, ANOVA is robust to moderate deviations from normality.
- Constant Variance: The variability (variance) within each group should be roughly equal across all groups. This can be checked using side-by-side box plots or by comparing standard deviations.
🔑 Important: Independence is crucial. Normality and constant variance are more forgiving, especially with larger sample sizes 291.
18.5 Multiple comparisons
When an ANOVA test rejects the null hypothesis, it indicates that at least one group mean is different. However, it doesn't specify which groups differ.
Multiple comparisons are performed to identify specific pairs of group means that are significantly different.
18.6 Controlling Type 1 Error
Performing many pairwise tests increases the chance of a Type 1 error (falsely rejecting a true null hypothesis).
- The Bonferroni correction is a common method to adjust the significance level for multiple comparisons.
- It divides the original significance level (α) by the number of comparisons (K).
α∗=Kα
- If there are k groups, the number of pairwise comparisons is K=2k(k−1).
🔑 Important: With multiple tests, use a stricter significance level to avoid inflating the Type 1 error rate.
Multiple Comparisons Scenario:
| Comparison | Test Type | Modified α∗ | Example Conclusion |
|---|---|---|---|
| Group A vs. B | t-test | α/3 | Not significant |
| Group A vs. C | t-test | α/3 | Not significant |
| Group B vs. C | t-test | α/3 | Significant |
📝 Example: For three lectures (A, B, C), we have K=23(3−1)=3 comparisons. With α=0.05, the Bonferroni-corrected significance level is α∗=0.05/3=0.0167. Pairwise t-tests are conducted using this stricter alpha 293.
- When a pairwise test's p-value is less than α∗, we conclude there is a statistically significant difference between that pair of group means.
- Failing to find a significant difference in a pairwise test does not prove the means are equal, only that there isn't enough evidence to claim they are different at the adjusted α∗.
🔑 Important: Rejecting H0 in ANOVA means some difference exists, but pairwise tests pinpoint which specific means differ.
🔑 Important: ANOVA is like a detective looking at all suspects at once to find evidence of a crime; pairwise comparisons then try to pinpoint the exact culprit 294.
🔑 Important: The most exam-relevant insight from ANOVA is its ability to compare multiple group means simultaneously, using the F-test to gauge overall differences and Bonferroni correction to manage errors in follow-up pairwise comparisons 299.
18.7 One-sample mean inference: t-distribution
When analyzing numerical data, we often want to estimate the population mean (μ). If the population standard deviation (σ) is unknown, we use the sample standard deviation (s) and the t-distribution.
This approach is suitable when the data are approximately normally distributed or the sample size is large (n > 30).
- t-distribution: This distribution is similar to the normal distribution but has heavier tails. It accounts for the extra uncertainty introduced by estimating σ with s.
- Degrees of freedom (df): The shape of the t-distribution depends on the degrees of freedom, which for a one-sample mean is typically n−1.
The t-distribution becomes more like the normal distribution as degrees of freedom increase.
18.8 Confidence interval for a population mean
A confidence interval provides a range of plausible values for the population mean. For a one-sample mean, the formula is:
Sample Mean ± Critical t-value × Standard Error
The standard error of the mean is calculated as s/n. The critical t-value is determined by the confidence level and the degrees of freedom.
- Confidence interval: A range of values, calculated from sample data, that is likely to contain the true population parameter.
- Interpretation: A 95% confidence interval means that if we were to take many samples and construct a confidence interval for each, about 95% of those intervals would contain the true population mean.
95% confidence interval for μ: xˉ±t∗ns
18.9 Hypothesis testing for a population mean
We use hypothesis tests to determine if sample data provide enough evidence to reject a claim about a population mean.
- Null hypothesis (H0): A statement of no effect or no difference, often involving a specific value for the population mean (e.g., H0:μ=μ0).
- Alternative hypothesis (HA): A statement that contradicts the null hypothesis, suggesting a difference or effect (e.g., HA:μ=μ0, HA:μ>μ0, or HA:μ<μ0).
Errors in hypothesis setup can lead to incorrect conclusions. For example, hypotheses should refer to population parameters (μ), not sample statistics (xˉ).
Also, the null hypothesis should typically state equality, not inequality.
Incorrect hypotheses: H0:xˉ<10 hours or HA:xˉ=23.44 years. Correct hypotheses use population parameters: H0:μ=10 hours and HA:μ>10 hours.
18.10 Assumptions for one-sample mean inference
For valid inference about a population mean using the t-distribution, certain assumptions should be met:
- Independence: Observations within the sample should be independent of each other. For samples, this often means random sampling.
- Normality: The population from which the sample is drawn should be approximately normally distributed. For large sample sizes (typically n>30), the Central Limit Theorem helps relax this assumption.
📝 Example: For the age at first marriage data, we assume the 5,534 sampled women are representative of the population of interest and that their ages at first marriage are approximately normally distributed or the sample size is large enough for the Central Limit Theorem to apply.
18.11 Comparing means of two groups
When comparing means between two independent groups or within paired samples, we use similar inferential techniques but adapt them to the specific scenario.
18.12 Paired data analysis
Paired data occurs when observations are collected in pairs, such as before-and-after measurements on the same subject or matched pairs from different groups. We analyze the differences between the paired observations as a single sample.
- Difference variable: Create a new variable representing the difference for each pair (d=x1−x2).
- Inference: Perform a one-sample t-test or construct a t-confidence interval on these differences to make inferences about the mean difference in the population.
Paired data analysis reduces variability by focusing on the differences within pairs.
18.13 Difference between two independent means
When comparing the means of two independent groups (e.g., comparing the average test scores of students who used study aid A versus study aid B), we use a two-sample t-test or confidence interval.
- Pooled vs. unpooled variance: Depending on whether the population variances are assumed to be equal, we use either a pooled or unpooled (Welch's) t-test. The Welch's t-test is more robust as it does not assume equal variances.
- Standard error: The calculation of the standard error for the difference between two means differs based on whether variances are pooled.
The goal is to determine if the observed difference in sample means is large enough to conclude a true difference exists in population means.
🔑 Important: When comparing two independent means, use a two-sample t-test. If data are paired, analyze the differences using a one-sample t-test.
18.14 Power and sample size for difference of means
Before conducting a study, it's crucial to determine the required sample size to achieve a desired level of power. Power is the probability of correctly rejecting a false null hypothesis.
- Power calculation: This involves specifying the effect size (the minimum difference in means we want to detect), the significance level (α), and the desired power.
- Sample size determination: Based on these factors, we can calculate the necessary sample size per group for a two-sample t-test.
Larger effect sizes or higher desired power require larger sample sizes.
18.15 Analysis of Variance (ANOVA)
Analysis of Variance (ANOVA) is a statistical method used to compare the means of three or more groups. Instead of performing multiple pairwise t-tests, ANOVA provides a single framework to test if at least one group mean differs significantly from the others.
- Core idea: ANOVA partitions the total variation in the data into variation between groups and variation within groups.
- F-statistic: A ratio of the variance between groups to the variance within groups. A large F-statistic suggests that group means are different.
ANOVA is the go-to method for comparing means across multiple independent groups simultaneously.
🔑 Important: ANOVA is used when comparing the means of three or more groups, whereas t-tests are for comparing two groups 302.
19. Introduction to linear regression
19.1 Fitting a line, residuals, and correlation
Linear regression models relationships between numerical variables using a straight line. This line helps predict one variable (response) using another (explanatory).
- Linear model form:
y = β0 + β1x + εy: response variablex: explanatory variableβ0: intercept parameter (estimated byb0)β1: slope parameter (estimated byb1)ε: error term (accounts for variability not explained byx)
The goal is to find the line that best fits the data, even when points don't fall perfectly on the line.
- Residuals: The difference between the observed response (
y) and the predicted response (ŷ).ei = yi - ŷi- Positive residual: observation is above the line.
- Negative residual: observation is below the line.
- Small residuals indicate a good fit.
🔑 Important: Residuals measure how far individual data points fall from the regression line.
A residual plot shows residuals against the explanatory variable. It helps assess if a linear model is appropriate.
-
Ideal residual plot: Points are randomly scattered around zero, with no discernible pattern.
-
Problematic residual plot: Patterns (like curves or funnels) suggest a linear model is not suitable.
-
Correlation (R):
- Measures the strength and direction of a linear relationship.
- Ranges from -1 to 1.
- Near +1: strong positive linear relationship.
- Near -1: strong negative linear relationship.
- Near 0: weak or no linear relationship.
🔑 Important: Correlation quantifies the strength of linear relationships only. Strong nonlinear relationships may have low correlation.
| Relationship Type | Correlation (R) Value Range | Visual Trend |
|---|---|---|
| Strong Positive Linear | 0.8 to 1.0 | Upward, points close |
| Moderate Positive Linear | 0.4 to 0.7 | Upward, some scatter |
| Weak Positive Linear | 0.1 to 0.3 | Slightly upward, noisy |
| No Linear Trend | -0.1 to 0.1 | Scattered, no direction |
| Weak Negative Linear | -0.3 to -0.1 | Slightly downward, noisy |
| Moderate Negative Linear | -0.7 to -0.4 | Downward, some scatter |
| Strong Negative Linear | -1.0 to -0.8 | Downward, points close |
🔑 Important: Changing units of measurement does not alter the correlation coefficient. Correlation is unitless.
🔑 Important: Linear regression helps us understand and predict relationships between variables, with residuals guiding model fit and correlation quantifying relationship strength.
20. Least squares regression and model interpretation
20.1 Least squares regression method
- Least squares regression is a statistical method for finding the best-fitting line through data.
- It aims to minimize the sum of the squared residuals, which are the differences between observed and predicted values.
- This method is preferred over minimizing the sum of absolute residuals because larger errors are penalized more heavily.
🔑 Important: Minimizing squared residuals is standard practice due to its mathematical properties and wider software support.
20.2 Conditions for least squares regression
For the least squares line to be reliable, four conditions should generally be met:
- Linearity: The relationship between the variables should appear linear on a scatterplot.
- Nearly normal residuals: The distribution of residuals should be approximately normal. Outliers can violate this.
- Constant variability: The spread of residuals should be consistent across all values of the explanatory variable.
- Independent observations: Data points should be independent of each other, especially important for time series data.
🔑 Important: Violations of these conditions suggest that a simple linear model may not be appropriate.
20.3 Finding the least squares line
The equation for a least squares regression line is y^=b0+b1x.
- Estimating the slope (b1): b1=Rsxsy where R is the correlation, sy is the standard deviation of the response variable, and sx is the standard deviation of the explanatory variable.
- Identifying a point on the line: The mean of the explanatory variable (xˉ) and the mean of the response variable (yˉ) always lie on the least squares line.
- Estimating the intercept (b0): b0=yˉ−b1xˉ
🔑 Important: Computers are typically used to calculate these estimates, but understanding the formulas is key.
20.3.1 Example: Gift aid and family income
| Statistic | Family Income (x) | Gift Aid (y) |
|---|---|---|
| Mean (xˉ) | $101,780 | $19,940 |
| Std. Dev. (sx) | $63,200 | $5,460 |
Using these statistics, the slope is b1=(−0.499)×(5,460/63,200)≈−0.0431. The intercept is b0=19,940−(−0.0431)×101,780≈24,327.
The regression equation is Gift Aid=24,327−0.0431×Family Income 320.
20.4 Interpreting regression model parameters
- The slope (b1) represents the estimated average change in the response variable (y) for a one-unit increase in the explanatory variable (x).
- For example, if b1=−0.0431 for family income and gift aid, each additional dollar of family income is associated with an average decrease of \USD 0.0431 in gift aid.
- The intercept (b0) is the estimated average value of the response variable when the explanatory variable is zero.
- This interpretation is only meaningful if x=0 is a plausible value within the data range.
🔑 Important: Correlation does not imply causation. Observational data cannot definitively prove that changes in x cause changes in y.
20.5 Extrapolation
- Extrapolation occurs when a linear model is used to predict values outside the range of the observed explanatory variable data.
- This is unreliable because the linear trend may not continue beyond the observed data.
📝 Example: Predicting gift aid for a family income of \USD 1 million using the Elmhurst model results in a negative aid amount, which is unrealistic.
20.6 R-squared (R2)
- R2 (R-squared) quantifies the proportion of the variation in the response variable that is explained by the linear relationship with the explanatory variable.
- It is calculated as the square of the correlation coefficient (R2=R2).
- R2 ranges from 0 to 1 (or 0% to 100%).
🔑 Important: A higher R2 indicates that the linear model explains a larger portion of the variability in the response. For the Elmhurst data, R=−0.499, so R2=(−0.499)2≈0.25, meaning about 25% of the variation in gift aid is explained by family income 323.
20.7 Categorical predictors with two levels
- Categorical predictors can be included in regression models using indicator variables.
- An indicator variable takes a value of 1 for one category and 0 for another.
- For a categorical variable with two levels, the regression model becomes y^=b0+b1×indicator.
20.7.1 Interpreting parameters for categorical predictors
- The intercept (b0) represents the estimated average value of the response for the category coded as 0.
- The slope (b1) represents the estimated average difference in the response between the category coded as 1 and the category coded as 0.
📝 Example: For eBay auction prices of Mario Kart, if 'used' is coded as 0 and 'new' as 1:
- Intercept (\USD 42.87) is the average price for used games.
- Slope (\USD 10.90) is the average additional price for new games compared to used ones 324.
🔑 Important: When using categorical predictors, check for normality and equal variance of residuals within each category.
🔑 Important: Least squares regression provides a powerful framework for understanding relationships, but always check model conditions and avoid extrapolation for reliable interpretations.
21. Outliers and model diagnostics in linear regression
21.1 Identifying outliers and influential points
Outliers are observations that deviate significantly from the general pattern of the data. In linear regression, these points can disproportionately affect the fitted line.
- High leverage points: These are observations that lie horizontally far from the center of the data cloud. They have the potential to influence the slope of the regression line.
- Influential points: A high leverage point is considered influential if it pulls the regression line towards itself. If removing an influential point causes a substantial change in the fitted line, it is influential.
Don't remove outliers without strong justification; they can hold important insights.
21.2 Diagnostic plots and their use
Diagnostic plots help visualize the fit of a linear regression model and identify potential issues like outliers. Examining scatterplots and residual plots is crucial for understanding how points affect the model.
- Scatterplots: Show the raw data points and the fitted regression line. Outliers appear as points far from the main cluster.
- Residual plots: Plot the residuals (the differences between observed and predicted values) against the fitted values or predictor variables. Trends in residual plots, especially with high leverage points, indicate potential influence on the model.
| Plot Characteristic | Impact on Line | Classification |
|---|---|---|
| Far from cloud, near line | Minimal | Outlier |
| Far from cloud, pulls line | Significant | Influential point |
| Horizontally far from center | High potential | High leverage point |
21.3 Inference for linear regression coefficients
Inference allows us to generalize from sample estimates to the population. This involves quantifying the uncertainty in the estimated slope (b1) and intercept (b0).
21.3.1 Standard errors and hypothesis testing
- Standard error (SE): Measures the variability of the estimated coefficient. Statistical software calculates this value.
- Hypothesis test for slope:
- Null hypothesis (H0): β1=0 (The true slope is zero; no linear relationship).
- Alternative hypothesis (HA): β1=0 (The true slope is different from zero; a linear relationship exists).
To test these hypotheses, a t-test statistic is computed:
T=SEEstimate−Null Value
The p-value from this test indicates the probability of observing the data if the null hypothesis were true. A small p-value (typically < 0.05) leads to rejecting H0.
| Output Component | Meaning |
|---|---|
| Estimate | Point estimate of the coefficient (b0 or b1). |
| Std. Error | Standard error of the estimate. |
| t value | The calculated t-test statistic. |
| Pr(>|t|) | The p-value for the two-sided test. |
| df | Degrees of freedom for the t-distribution. |
Software provides estimates, standard errors, t-values, and p-values for hypothesis tests. Always verify model conditions.
21.3.2 Confidence intervals for coefficients
A confidence interval provides a range of plausible values for the true population coefficient.
- Formula: bi±tdf⋆×SEbi
- bi: The estimated coefficient.
- tdf⋆: The critical t-value for the desired confidence level and degrees of freedom.
- SEbi: The standard error of the coefficient.
For example, a 95% confidence interval for the slope means we are 95% confident that the true slope lies within that range.
Confidence intervals quantify the uncertainty around our coefficient estimates.
🔑 Important: Outliers can significantly distort regression results; always investigate them. Inference methods rely on model assumptions being met.
22. Multiple regression
22.1 Introduction to multiple regression
-
Multiple regression: Extends simple linear regression to models with one response and multiple predictor variables. It helps understand how several factors simultaneously influence an outcome.
-
Model equation: For k predictors, the model is y^=β0+β1x1+β2x2+⋯+βkxk.
-
Parameter estimation: Coefficients (βi) are estimated to minimize the sum of squared residuals (SSE). Statistical software is typically used for this.
📝 Example: Predicting loan interest rates using borrower income, credit utilization, and loan term.
22.2 Handling categorical predictors
-
Indicator variables: Used for binary categorical predictors (e.g., bankruptcy: 1 for yes, 0 for no).
-
Interpretation: The coefficient represents the change in the response for a unit increase in the predictor, holding others constant. For a binary variable, it's the difference between the two levels.
-
Categorical variables with k>2 levels:
- Software creates k−1 indicator variables.
- One level is designated the reference level.
- Coefficients for other levels are interpreted relative to this reference level.
📝 Example: If
income verhas levels 'not', 'source only', 'verified', and 'not' is the reference, coefficients for 'source only' and 'verified' show the rate difference compared to 'not'.
| Variable Level | Indicator Variable Value | Effect on Interest Rate (vs. 'not') |
|---|---|---|
| not | 0 (for both indicators) | Base rate (Intercept) |
| source only | 1 (source only), 0 (verified) | Intercept + βsource only |
| verified | 0 (source only), 1 (verified) | Intercept + βverified |
- Counter-intuitive results: Coefficients might seem surprising (e.g., higher interest for verified income). This can happen due to confounding variables that are not included in the model.
22.3 Interpreting multiple regression coefficients
- Coefficient interpretation: Each βi represents the expected change in the response variable for a one-unit increase in predictor xi, assuming all other predictors are held constant.
- Collinearity: When predictor variables are correlated, it complicates model estimation. This correlation is known as collinearity.
🔑 Important: Simple regression coefficients can change in multiple regression because other predictors account for variation previously attributed to the single predictor.
22.4 Assessing model fit with adjusted R-squared
- R-squared (R2): Measures the proportion of variability in the response explained by the model. R2=1−Var(outcome)Var(residuals).
- Adjusted R-squared (Radj2): A modified version of R2 that accounts for the number of predictors (k) and sample size (n). It penalizes models with too many predictors. Radj2=1−soutcome2sresiduals2×n−k−1n−1
- Purpose: Adjusted R2 provides a less biased estimate of model fit for new data, especially when comparing models with different numbers of predictors. It tends to be lower than R2.
🔑 Important: Adding a predictor always increases R2. Adjusted R2 may decrease if the added predictor does not improve the model enough to justify its inclusion.
22.5 Model selection strategies
- Goal: To find a parsimonious model – one that is simpler but still explains the data well.
- Full model: Includes all potential predictor variables.
🔑 Important: The best model is not always the most complex; sometimes fewer predictors lead to more accurate predictions.
22.6 Backward elimination
- Process:
- Start with the full model.
- Sequentially remove the variable that results in the largest improvement in adjusted R2.
- Stop when removing any further variable does not improve adjusted R2.
📝 Example: If removing the
issuedvariable increases adjusted R2, it is dropped. Then, check if removing other variables further improves adjusted R2.
22.7 Forward selection
1. Start with a model containing only the intercept.
2. Sequentially add the variable that provides the greatest improvement in adjusted $R^2$.
3. Stop when adding any remaining variable does not improve adjusted $R^2$.
🔑 Important: Both backward elimination and forward selection are stepwise model selection strategies, meaning they add or remove one variable at a time.
🔑 Important: Multiple regression is a powerful tool for understanding relationships between multiple variables, but careful model selection using adjusted R-squared is crucial for building accurate and interpretable models.
22.8 Model selection strategies
Model selection helps choose the best subset of predictor variables for a regression model. Two common strategies are backward elimination and forward selection.
22.9 Backward elimination
Backward elimination starts with a model containing all possible predictor variables. It then removes variables one by one.
The variable removed at each step is the one with the least importance.
- Process:
- Begin with the full model (all predictors).
- Identify the least important predictor.
- If this predictor is not significant, remove it.
- Refit the model and repeat.
- Stop when all remaining predictors are important.
22.10 Forward selection
Forward selection starts with a model containing no predictor variables. It then adds variables one by one.
The variable added at each step is the one that most improves the model.
* Begin with a model with no predictors.
* Consider adding each predictor individually.
* Add the predictor that most improves the model.
* Stop when no further additions improve the model.
22.11 Comparing selection strategies
Both backward elimination and forward selection can result in different final models. When this happens, the model with the higher adjusted R-squared is often preferred.
Backward elimination starts with everything, forward selection starts with nothing.
22.12 Evaluating model fit
We use metrics like adjusted R-squared or p-values to assess how well a model fits the data and to guide variable selection.
22.13 Adjusted R-squared
Adjusted R² is a modified version of R-squared. It accounts for the number of predictors in the model.
This metric helps avoid overfitting by penalizing models with too many variables.
- A higher adjusted R² generally indicates a better model fit.
- When comparing models with different numbers of predictors, adjusted R² is more informative than R-squared.
22.14 p-value approach
The p-value approach uses statistical significance to select variables. It's useful when understanding the impact of individual predictors is important.
-
Backward elimination with p-values:
- Identify the predictor with the largest p-value.
- If this p-value exceeds a significance level (α, often 0.05), remove the predictor.
-
Forward selection with p-values:
- Start with a null model.
- Identify the predictor with the smallest p-value among those not yet in the model.
- If this p-value is less than α, add the predictor to the model.
The p-value approach focuses on statistical significance of predictors.
22.15 Adjusted R² vs. p-value approach
The choice between adjusted R² and p-values depends on the goal.
| Goal | Preferred Approach | Notes |
|---|---|---|
| Improve prediction accuracy | Adjusted R² | Common in machine learning; may include more predictors. |
| Understand significant predictors | p-value approach | Results in a simpler model, possibly with slight prediction cost. |
After selecting variables, it's crucial to verify that the model conditions are met.
The adjusted R² approach tends to select more variables than the p-value approach.
🔑 Important: Model selection techniques like backward elimination and forward selection, using either adjusted R² or p-values, are essential for building robust multiple regression models.
23. Checking model conditions using graphs
Understanding and checking model conditions is crucial for multiple regression. These conditions ensure that the model's results are reliable.
Key conditions include:
- Residuals are nearly normal.
- Residual variance is constant.
- Residuals are independent.
- Predictor variables have a linear relationship with the outcome.
Diagnostic plots help identify violations of these conditions.
23.1 Diagnostic plots overview
Diagnostic plots visually assess if a regression model meets its underlying assumptions. These plots help identify issues like outliers, non-constant variance, and nonlinearity.
- Histogram of residuals: Checks for normality and identifies extreme outliers. For large datasets, only severe outliers are a concern.
- Absolute residuals vs. fitted values: Assesses if the variance of residuals is constant. A smoothed line can reveal trends.
- Residuals in order of collection: Detects patterns if data was collected sequentially, indicating potential autocorrelation. Time series methods may be needed if patterns emerge.
- Residuals vs. predictor variables: Checks for relationships between residuals and each predictor. This can reveal nonlinearity or unequal variance across groups.
Visualizing residuals helps diagnose model health.
23.2 Common issues and interpretation
When examining diagnostic plots, look for specific patterns that suggest problems with the model assumptions.
23.2.1 Identifying outliers and non-constant variance
- Outliers: While normality of residuals is ideal, large datasets tolerate some deviation. Extreme outliers are the primary concern.
- Non-constant variance: A plot of absolute residuals versus fitted values can show increasing or decreasing variance. This is also known as heteroscedasticity.
- Patterns in residuals vs. predictors: A "fan" shape or noticeable curvature in these plots suggests issues. For categorical predictors, compare variability across groups.
📝 Example: A fan shape in the residuals vs. fitted values plot indicates increasing variance as fitted values grow.
23.2.2 Nonlinearity and independence
- Nonlinearity: A curved pattern when plotting residuals against a predictor variable suggests the linear assumption is violated for that variable.
- Independence: If residuals show a pattern when plotted against their order of collection, it suggests observations are not independent.
🔑 Important: Curvature in residual plots signals a need to transform a predictor or use a nonlinear model.
| Plot Type | Condition Checked | Potential Issue |
|---|---|---|
| Histogram of residuals | Normality, Outliers | Extreme values, skewed distribution |
| Absolute residuals vs. fitted | Constant variance | Funnel shape, increasing/decreasing spread |
| Residuals vs. predictor | Linearity, Constant Var. | Curved pattern, unequal spread |
| Residuals vs. order of collection | Independence | Cyclical patterns, trends |
23.3 Improving model fit
When diagnostic plots reveal problems, several strategies can improve the model.
23.3.1 Transformation and truncation
- Transforming variables: Applying functions like log, square root, or inverse to predictor variables can linearize relationships and stabilize variance.
- Log transformations are useful for right-skewed data.
- Square root transformations can reduce skewness.
- Inverse transformations can help with certain patterns.
- Truncation: Capping extreme values of a predictor variable can reduce their undue influence.
🔑 Important: Transformations can make interpretation harder but improve model validity.
| Transformation Type | Use Case | Consideration if x = 0 |
|---|---|---|
| Log transformation | Highly right-skewed variables | Undefined |
| Square root | Moderately right-skewed, stabilizes variance | Valid for x ≥ 0 |
| Inverse (1/x) | Specific patterns, stabilizing variance | Undefined for x = 0 |
| Truncation | Extreme outliers, high leverage points | Caps maximum value |
23.3.2 Advanced techniques
- Additional variables: Including relevant predictors can capture variation missed by the current model.
- Advanced methods: Techniques like generalized additive models (GAMs) can handle nonlinear relationships and varying variance more flexibly.
🔑 Important: Model improvements should balance diagnostic improvements with interpretability.
23.4 Case Study: Mario Kart Auctions
In the Mario Kart auction case study, diagnostic plots were used to check the final model.
- Residuals Histogram: Showed no major outliers in the large dataset.
- Absolute Residuals vs. Fitted Values: Displayed no obvious patterns, suggesting reasonably constant variance.
- Residuals vs. Predictors:
cond new: Variability was similar across groups.stock photo: Showed some difference in residual variability between unique and stock photos.wheels: Indicated potential curvature, suggesting a nonlinear relationship.
The analysis noted potential non-constant variance for stock photo and nonlinearity for wheels. While these issues were noted, the model was considered reasonable for its purpose.
🔑 Important: Reporting model limitations is crucial for transparency, even with a useful model.
24. Introduction to logistic regression (part 1)
24.1 Logistic regression basics
Logistic regression models categorical outcomes with two levels. It's a type of generalized linear model (GLM).
GLMs use a probability distribution for the response variable. Then, they model the distribution's parameter with predictors.
The process feels similar to multiple regression.
- Response variable: Yi, takes value 1 (event occurs) with probability pi, or 0 (event does not occur) with probability 1 - pi.
- Model goal: Relate pi to predictor variables (x1,x2,...,xk).
24.2 Modeling the probability of an event
The core idea is to model the probability (pi) of an event occurring for each observation. Regular multiple regression doesn't work well here because the response is not continuous and normally distributed.
- Logit transformation: A common transformation for pi to make it suitable for linear modeling. logit(pi)=loge(1−pipi)
- The logistic regression model is: loge(1−pipi)=β0+β1x1,i+β2x2,i+⋯+βkxk,i This equation links the log-odds of an event to a linear combination of predictors.
The logit transformation maps probabilities (0 to 1) to all real numbers (-∞ to +∞).
To convert a predicted log-odds back to a probability: pi=1+eβ0+β1x1,i+⋯+βkxk,ieβ0+β1x1,i+⋯+βkxk,i
24.3 Example: Resume callbacks
A study investigated factors influencing callback rates for job applications.
📝 Example: A model with "honors" as a predictor: loge(1−pipi)=−2.4998+0.8668×honors
- If no honors (honors = 0), predicted callback probability p^i=0.076.
- If honors listed (honors = 1), predicted callback probability p^i=0.163.
24.4 Building logistic models with multiple variables
Similar to multiple regression, logistic regression can include many predictors. The output from statistical software typically includes estimates, standard errors, z-values, and p-values for each predictor.
- P-values: Calculated using the normal distribution (z-distribution) for logistic regression, unlike the t-distribution in linear regression.
24.5 Model selection
- Variable selection methods, like using Akaike Information Criterion (AIC), can be used to find a smaller, more parsimonious model. AIC is analogous to adjusted R-squared in multiple regression.
- Models with lower AIC values are preferred.
📝 Example: A model was reduced by eliminating "college degree." The remaining coefficients could slightly change, reflecting interactions or multicollinearity.
| Predictor | Full Model Estimate | Reduced Model Estimate |
|---|---|---|
| (Intercept) | -2.6632 | -2.7162 |
| job city: Chicago | -0.4403 | -0.4364 |
| honors | 0.7694 | 0.7634 |
| race: white | 0.4424 | 0.4429 |
📝 Example: In the resume study, "race: white" had a positive coefficient, indicating that resumes implying a White applicant had a higher callback rate, suggesting racial bias.
-
For a job in Chicago with 14 years experience, an email, White race, and male sex:
- Log-odds of callback ≈−2.3955
- Predicted probability ≈8.35%
-
If the same individual was perceived as Black (racewhite = 0):
- Predicted probability ≈5.53%
- This implies Black-perceived applicants need to apply to ≈50% more jobs for a callback.
24.6 Conditions for logistic regression
Two key conditions must be met for a logistic regression model:
- Independence: Each outcome (Yi) must be independent of other outcomes. This is often met when observations are randomly sampled or assigned.
- Linearity: Each predictor (xi) must be linearly related to the logit of the probability (pi), holding other predictors constant.
24.7 Model assessment
Visualizations help assess the model's fit.
- Plotting predicted probabilities against the actual outcomes can reveal patterns.
- A plot of observed vs. predicted probabilities with confidence intervals helps check if predicted probabilities align with observed rates. If points fall within the confidence bounds and near the y=x line, the fit is reasonable.
🔑 Important: With a large dataset (4870 observations), we can reliably check the linearity assumption and assess model fit.
24.8 Discrimination and group sizes
Logistic regression can reveal discriminatory patterns in data.
📝 Example: In a company with 80% men and 20% women, if 10% of each sex are prejudiced, women (the smaller group) experience discrimination from a larger proportion of their colleagues.
- Men face bias from ≈ 2% of reviewers.
- Women face bias from ≈ 8% of reviewers.
🔑 Important: Even with equal prejudice rates, the smaller demographic group experiences disproportionately more discrimination due to population imbalance.
🔑 Important: Logistic regression provides powerful tools to model dichotomous outcomes and identify significant predictors. Understanding the logit transformation and interpreting coefficients are key to applying this model effectively.
24.9 Modeling binary outcomes
Logistic regression is used to model outcomes that have two categories. It predicts the probability of an event occurring.
- Outcome variable: This variable can only take one of two values, like yes/no or damaged/not damaged.
- Model goal: To estimate the probability of the outcome being in one specific category.
Logistic regression models the probability of a binary outcome.
24.10 The logit transformation
To model probabilities, logistic regression uses a transformation called the logit. This transformation converts probabilities into a linear function of the predictors.
- Probability of damage: Let p^ be the estimated probability of an O-ring being damaged.
- Logit transformation: The model uses the log of the odds: log(1−p^p^). This is often called the logit.
- Linear model: The logit is modeled as a linear combination of predictor variables. For temperature (T), the model is: log(1−p^p^)=β0+β1×T
24.11 Building and interpreting logistic models
A logistic regression model relates predictor variables to the log-odds of the outcome. The coefficients in the model have a specific interpretation.
-
Challenger disaster example: In the Challenger disaster case, temperature (T) was a predictor. The model was: log(1−p^p^)=11.6630−0.2162×T Here, p^ is the estimated probability of an O-ring being damaged.
-
Coefficient interpretation: The coefficient β1=−0.2162 for Temperature means that for every one-degree Fahrenheit increase in temperature, the log-odds of O-ring damage decrease by 0.2162.
A one-unit increase in a predictor changes the log-odds by its coefficient.
24.12 Calculating predicted probabilities
To find the predicted probability (p^) for a given predictor value, you first calculate the log-odds using the model. Then, you transform this back to a probability.
- Log-odds calculation: For T=51 degrees Fahrenheit: log(1−p^p^)=11.6630−0.2162×51=11.6630−11.0262=0.6368
- Transforming back: The odds are e0.6368≈1.89. The probability p^ is calculated as: p^=1+oddsodds=1+1.891.89≈0.65
The odds ratio for a predictor is eβ1.
24.13 Assumptions and concerns in logistic regression
Applying logistic regression requires certain assumptions about the data. Violating these assumptions can affect the model's validity.
- Independence: Observations must be independent. This means one observation's outcome should not influence another's.
- No perfect separation: It should not be possible to perfectly predict the outcome using the predictors.
- Linearity in the log-odds: The relationship between the predictors and the log-odds of the outcome should be linear.
Independence of observations is a key assumption.
🔑 Important: Logistic regression predicts probabilities between 0 and 1, avoiding impossible negative or greater than 1 predictions.
📝 Example: In the Challenger disaster, concerns might include whether the limited data points truly represent the underlying relationship or if temperature is the only crucial factor. Assumptions about O-ring behavior and the physics of the launch also play a role.
25. Introduction to logistic regression (part 2)
25.1 Modeling with multiple predictors
- Logistic regression can handle multiple predictor variables. These predictors can be continuous or categorical.
- The model estimates the relationship between each predictor and the log-odds of the outcome.
- The form of the logistic regression model with multiple predictors is:
logit(p)=β0+β1x1+β2x2+⋯+βkxk where:
- p is the probability of the outcome.
- logit(p)=log(1−pp) is the log-odds.
- β0 is the intercept.
- βi are the coefficients for each predictor xi.
25.2 Interpreting coefficients
- The coefficients (βi) represent the change in the log-odds of the outcome for a one-unit increase in the corresponding predictor, holding other predictors constant.
- Interpreting coefficients directly in terms of log-odds can be difficult. Exponentiating the coefficients provides odds ratios.
- The odds ratio for predictor xi is eβi.
Odds ratio > 1: increases the odds of the outcome. Odds ratio < 1: decreases the odds of the outcome. Odds ratio = 1: no effect on the odds.
- For categorical predictors with more than two levels, one level is chosen as the reference category. The coefficients represent the change in log-odds compared to this reference category.
| Predictor | Coefficient (βi) | Interpretation of βi | Odds Ratio (eβi) | Interpretation of Odds Ratio |
|---|---|---|---|---|
| Continuous | βi | Change in log-odds per unit increase in xi | eβi | Multiplicative change in odds for a one-unit increase in xi |
| Categorical | βi | Change in log-odds compared to reference category | eβi | Multiplicative change in odds compared to the reference category |
25.3 Model building and diagnostics
- When building a logistic regression model with multiple predictors, variable selection methods can be used to identify important predictors.
- Common methods include forward selection, backward elimination, and stepwise regression.
- Model diagnostics are crucial to assess the fit of the model and identify potential issues.
Key diagnostics: residual analysis, goodness-of-fit tests, and assessment of influential points.
25.4 Discrimination
- Discrimination refers to the model's ability to distinguish between the two outcome categories.
- A well-discriminating model will assign higher predicted probabilities to individuals in one category than to individuals in the other.
- Metrics like the Area Under the Receiver Operating Characteristic (ROC) Curve (AUC) are used to quantify discrimination.
Higher AUC values indicate better discrimination. An AUC of 0.5 suggests no better performance than random guessing.
- The ROC curve plots the true positive rate against the false positive rate at various threshold settings.
📝 Example: A model that can accurately predict whether a patient will develop a certain disease (yes/no) has good discrimination.
🔑 Important: Even a statistically significant model may not be clinically useful if its discrimination is poor.
25.5 Building logistic models with multiple predictors
-
Multiple logistic regression extends simple logistic regression to include several predictor variables. These predictors can be continuous or categorical. The model estimates the relationship between each predictor and the log-odds of the outcome, holding other predictors constant.
-
The model equation for multiple logistic regression is: log(1−p^ip^i)=β0+β1x1i+β2x2i+⋯+βkxki Here, p^i is the predicted probability of the outcome for the i-th observation. β0 is the intercept, and β1,…,βk are the coefficients for the k predictor variables x1i,…,xki.
-
The coefficients (β values) represent the change in the log-odds of the outcome for a one-unit increase in the corresponding predictor, assuming all other predictors remain constant.
-
When fitting these models, a common challenge is collinearity. This occurs when predictor variables are highly correlated with each other. Collinearity can inflate standard errors and make coefficient estimates unstable.
25.6 Interpreting model coefficients
-
Coefficients in a logistic regression model (βj) directly relate to the log-odds. Specifically, βj is the estimated change in the log-odds for a one-unit increase in predictor xj, holding other predictors constant.
-
To interpret coefficients in terms of odds, we exponentiate them: eβj. This value represents the odds ratio.
- An odds ratio greater than 1 means that for a one-unit increase in the predictor, the odds of the outcome occurring increase.
- An odds ratio less than 1 means that for a one-unit increase in the predictor, the odds of the outcome occurring decrease.
- An odds ratio equal to 1 means the predictor has no association with the odds of the outcome.
-
The odds ratio (eβj) shows how much the odds of the outcome change for each unit increase in the predictor, holding other variables constant.
-
For categorical predictors with more than two levels, dummy variables are used. Each dummy variable represents one level compared to a baseline reference level. The interpretation of their coefficients is similar, focusing on the odds ratio relative to the reference category.
Predictor Coefficient (β) Odds Ratio (eβ) Interpretation (for 1-unit increase) x1(continuous)0.50 1.65 Odds of outcome increase by 65% x2(categorical, Level A vs. B)-0.75 0.47 Odds of outcome decrease by 53% (1 - 0.47) if Level A vs. B
25.7 Model diagnostics and evaluation
-
Assessing model fit is crucial. Diagnostics help identify potential problems with the model or data.
-
Common diagnostic plots include:
- Residuals vs. Fitted Values: Helps check for non-constant variance (heteroscedasticity) and non-linear relationships. Ideally, residuals should be randomly scattered around zero.
- Residuals vs. Predictors: Similar to the above, this helps spot issues with individual predictors.
- Influence Plots (e.g., Cook's Distance): Identifies observations that have a large impact on the model's coefficients.
-
Random scatter around zero in residual plots suggests a well-fitting model.
-
Key metrics for evaluating logistic regression models include:
- R-squared (or pseudo R-squared): Measures the proportion of variance in the outcome explained by the predictors. Common pseudo R-squared measures include McFadden's R-squared and Nagelkerke's R-squared.
- AIC (Akaike Information Criterion): Used for model comparison; lower AIC values generally indicate a better model.
- Likelihood Ratio Test: Compares the fit of a full model to a reduced model (e.g., one with fewer predictors).
-
Lower AIC values indicate a better balance between model fit and complexity.
-
Specific diagnostics for logistic regression also include checking for outliers and high-leverage points, which can disproportionately influence the model's results.
-
🔑 Important: Collinearity, outliers, and poor residual patterns can all degrade model performance and lead to unreliable predictions or interpretations.
🔑 Important: Model diagnostics are essential for ensuring the reliability and validity of logistic regression results, especially when interpreting coefficients or making predictions.
25.8 Using logistic regression with multiple predictors
When you have several variables that might predict an outcome, logistic regression can handle them. This is called building a "multiple logistic regression model."
-
Model Form: The model uses a linear combination of predictor variables. This is then transformed to predict the log-odds of the outcome. ln(1−pp)=β0+β1X1+β2X2+⋯+βkXk
- p is the probability of the outcome.
- Xi are the predictor variables.
- βi are the coefficients for each predictor.
- β0 is the intercept.
-
Interpretation of Coefficients: Each βi represents the change in the log-odds of the outcome for a one-unit increase in Xi, assuming all other predictors stay the same.
The odds ratio for a predictor is eβi.
-
Odds Ratio: An odds ratio (eβi) tells you how much the odds of the outcome change for a one-unit increase in a predictor.
- An odds ratio > 1 means the odds increase.
- An odds ratio < 1 means the odds decrease.
- An odds ratio = 1 means no change in odds.
-
Example: If a model predicts loan default, and the coefficient for 'credit score' is -0.02, the odds ratio is e−0.02≈0.98. For every one-point increase in credit score, the odds of defaulting decrease by about 2%.
25.9 Interpreting model coefficients
Interpreting the coefficients in a multiple logistic regression requires careful consideration of the other variables in the model.
- Log-odds: The coefficients (βi) directly relate to the log-odds of the event occurring.
- Odds Ratios: Exponentiating the coefficients (eβi) yields odds ratios, which are often easier to interpret. They quantify the multiplicative change in the odds of the outcome.
🔑 Important: When interpreting coefficients, always state that the effect is "holding other variables constant."
25.10 Using probability tables
Probability tables, specifically the normal probability table, help find percentiles and probabilities for normally distributed data.
- Normal Probability Table: This table lists Z-scores and their corresponding percentiles (the area to the left of the Z-score).
- A Z-score measures how many standard deviations a data point is from the mean.
Key Relationship: Z-score = (Value - Mean) / Standard Deviation.
25.11 Using the normal probability table
The table allows you to find the percentile for a given Z-score or the Z-score for a given percentile.
-
Finding Percentile from Z-score:
- Locate the Z-score's first decimal in the row.
- Locate the Z-score's second decimal in the column.
- The intersection gives the percentile (area to the left).
- Example: For Z=0.45, look at row 0.4 and column 0.05. The percentile is 0.6736 (67.36th percentile) 408.
-
Finding Z-score from Percentile:
- Find the value in the table closest to the desired percentile.
- Combine the row and column values to get the Z-score.
- Example: For the 80th percentile (0.8000), the closest value is 0.7995, corresponding to Z=0.84.
-
Upper Tail Areas: To find the area to the right of a Z-score, calculate the left-tail area and subtract it from 1.
- Area to the right = 1−(Area to the left)
🔑 Important: The normal probability table always provides the area to the left of a Z-score.
25.12 Calculating values from percentiles
You can find a specific data value corresponding to a percentile using the Z-score.
- Steps:
- Find the Z-score for the desired percentile using the table.
- Use the Z-score formula, rearranged to solve for the unknown value (x). Z=σx−μ⟹x=μ+Zσ
- μ is the mean.
- σ is the standard deviation.
📝 Example: SAT scores follow N(1100,200). For the 80th percentile, Z=0.84. The score is x=1100+(0.84×200)=1100+168=1268 409.
🔑 Important: The normal probability table is essential for understanding the distribution of many natural phenomena and for hypothesis testing in statistics.
25.13 Normal distribution table (full)
This table provides a comprehensive list of Z-scores and their corresponding cumulative probabilities (percentiles).
| Negative Z | ... | Second decimal place of Z | ... | Positive Z |
|---|---|---|---|---|
| 0.0002 | ... | 0.00 | ... | 0.5000 |
| 0.0003 | ... | 0.01 | ... | 0.5040 |
| ... | ... | ... | ... | ... |
| 0.1587 | ... | 0.00 | ... | 0.8413 |
🔑 Important: This full table allows for precise calculations of probabilities and percentiles for any Z-score rounded to two decimal places.
🔑 Important: Understanding how to interpret logistic regression coefficients and use probability tables are key skills for analyzing categorical data and understanding statistical distributions.
26. Introduction to logistic regression (part 3)
26.1 Interpreting logistic regression models
- Logistic regression coefficients represent the change in the log-odds of the outcome for a one-unit increase in the predictor.
- The logit transformation, logit(p)=ln(1−pp), converts probabilities into a linear scale.
- The log-odds are then modeled as a linear combination of predictors, similar to linear regression.
The logit transformation is key to modeling probabilities linearly.
26.1.1 Understanding log-odds and odds ratios
- A coefficient (β) in a logistic model indicates how much the log-odds of the outcome change for a one-unit increase in the predictor, assuming other predictors are constant.
- Exponentiating a coefficient, eβ, gives the odds ratio (OR).
- The odds ratio represents the multiplicative change in the odds of the outcome for a one-unit increase in the predictor.
Exponentiate coefficients to get odds ratios.
26.1.2 Interpreting odds ratios
- An odds ratio greater than 1 means the odds of the outcome increase with the predictor.
- An odds ratio less than 1 means the odds of the outcome decrease with the predictor.
- An odds ratio equal to 1 means the predictor has no effect on the odds of the outcome.
| Odds Ratio (OR) | Interpretation |
|---|---|
| OR > 1 | Odds of outcome increase with predictor |
| OR < 1 | Odds of outcome decrease with predictor |
| OR = 1 | Predictor has no effect on odds of outcome |
26.1.3 Models with multiple predictors
- In multiple logistic regression, each coefficient represents the change in log-odds associated with its predictor, holding all other predictors constant.
- The interpretation of odds ratios remains the same for each predictor, assuming independence.
- This allows us to assess the effect of each variable while accounting for the influence of others.
Coefficients in multiple logistic regression are interpreted holding other variables constant.
26.2 Using distribution tables
- Distribution tables, like the normal, t, and chi-square tables, help find probabilities or scores based on degrees of freedom and tail areas.
- The normal probability table is used for Z-scores, showing the cumulative probability up to a given score.
- The t-probability table relates T-scores to tail probabilities for different degrees of freedom.
- The chi-square probability table provides upper tail areas for chi-square statistics based on degrees of freedom.
26.2.1 Finding tail areas with t-tables
- To find the proportion of a t-distribution below a T-score, locate the degrees of freedom (df) row and the column corresponding to the tail area.
- For cutoffs, find the intersection of the df row and the column representing the desired tail probability.
- When an exact T-score is not listed, interpolate between the closest values in the table to estimate the tail area.
T-tables use degrees of freedom and tail areas to find T-scores or probabilities.
26.2.2 Using chi-square tables
- Chi-square tables typically provide upper tail areas, meaning the probability of observing a value greater than the given statistic.
- Locate the row for the specific degrees of freedom.
- Find the column that matches or bounds the chi-square statistic to determine the corresponding tail area.
Chi-square tables show upper tail areas for a given statistic and degrees of freedom.
26.3 Model diagnostics and discrimination
- Model diagnostics help assess how well the logistic regression model fits the data and identify potential issues.
- Discrimination refers to the model's ability to distinguish between cases that have the outcome and those that do not.
- Metrics like ROC curves and AUC are used to evaluate discrimination.
Diagnostics ensure the model fits well and can distinguish between outcomes.
🔑 Important: Understanding coefficients, odds ratios, and distribution tables is crucial for interpreting logistic regression models and related statistical tests.
© 2026 Maeve. All rights reserved. This content is protected by copyright.