stat110 practice 2026S1

📚 stat110_practice_2026S1 (1).pdf

Brief overview

This document provides a foundational overview of key statistical concepts essential for data analysis. It covers descriptive statistics, probability, inferential statistics, and modeling techniques, preparing you for rigorous statistical application.

Key points

  • Overview of descriptive statistics and fundamental probability concepts.
  • Understanding confidence intervals and hypothesis testing for means and proportions.
  • Exploration of linear regression and correlation for variable relationships.
  • Application of ANOVA and chi-squared tests for group comparisons and categorical associations.
  • Principles of research design, sampling methods, and ethical data handling.

1. Descriptive statistics and probability basics

1.1 Types of variables

  • Categorical variables represent categories or groups.
    • Nominal categorical variables have no natural order (e.g., colors).
    • Ordinal categorical variables have a natural order but the distance between categories is not meaningful (e.g., satisfaction levels: "Agree", "Neutral", "Disagree").
    • Binary categorical variables have only two possible outcomes (e.g., Yes/No).
  • Numeric variables represent quantities.
    • Continuous numeric variables can take any value within a range (e.g., height, temperature).
    • Discrete numeric variables can only take specific, separate values, often integers (e.g., number of cars, number of goals).

📝 Example: Student agreement with "I like statistics" on a scale from "Strongly Agree" to "Strongly Disagree" is an ordinal categorical variable.

1.2 Sample statistics

  • Sample mean (yˉ\bar{y}): The average of a sample of data points.
    • Calculated by summing all data points and dividing by the number of data points.
    • Formula: yˉ=1n∑i=1nyi\bar{y} = \frac{1}{n} \sum_{i=1}^{n} y_i
  • Sample standard deviation (ss): A measure of the spread or dispersion of data points around the sample mean.
    • It is the square root of the sample variance.
    • Formula: s=1n−1∑i=1n(yi−yˉ)2s = \sqrt{\frac{1}{n-1} \sum_{i=1}^{n} (y_i - \bar{y})^2}

📝 Example: For data y=(39.7,41.3,44.4,39.0,45.5)y = (39.7, 41.3, 44.4, 39.0, 45.5), the sample mean is approximately 41.341.3 and the sample standard deviation is approximately 2.92.9 2.

1.3 Probability distributions

  • A probability distribution describes the likelihood of each possible outcome for a random variable.
  • The sum of probabilities for all possible outcomes must equal 1.
  • Expected value (E[Y]E[Y]): The average value of a random variable, weighted by its probabilities.
    • Formula: E[Y=∑yiP(Y=yi)E[Y = \sum y_i P(Y=y_i)
  • Variance (Var(Y)Var(Y)): A measure of the spread of the probability distribution.
    • Formula: Var(Y)=E[(Y−E[Y])2=∑(yi−E[Y])2P(Y=yi)Var(Y) = E[(Y - E[Y])^2 = \sum (y_i - E[Y])^2 P(Y=y_i)

📝 Example: For a gene study, the probability distribution of the number of copies YY is given. The probability of observing 3 or 4 copies is P(Y=3)+P(Y=4)=0.50+?P(Y=3) + P(Y=4) = 0.50 +?. If P(Y=3)=0.50P(Y=3)=0.50 and P(Y=1)=0.15P(Y=1)=0.15, P(Y=0)=0.05P(Y=0)=0.05, then P(Y=4)=1−(0.05+0.15+0.50)=0.30P(Y=4) = 1 - (0.05 + 0.15 + 0.50) = 0.30. So, P(Y=3 or 4)=0.50+0.30=0.80P(Y=3 \text{ or } 4) = 0.50 + 0.30 = 0.80.

Variable (Y)(Y)Probability P(Y=yi)P(Y=y_i)
00.05
10.15
30.50
40.30
  • Expected value E[Y=(0×0.05)+(1×0.15)+(3×0.50)+(4×0.30)=0+0.15+1.50+1.20=2.85E[Y = (0 \times 0.05) + (1 \times 0.15) + (3 \times 0.50) + (4 \times 0.30) = 0 + 0.15 + 1.50 + 1.20 = 2.85.
  • Variance Var(Y)=(0−2.85)2×0.05+(1−2.85)2×0.15+(3−2.85)2×0.50+(4−2.85)2×0.30=0.408+0.517+0.011+0.401=1.337Var(Y) = (0-2.85)^2 \times 0.05 + (1-2.85)^2 \times 0.15 + (3-2.85)^2 \times 0.50 + (4-2.85)^2 \times 0.30 = 0.408 + 0.517 + 0.011 + 0.401 = 1.337. (Approximation, actual value may differ slightly based on precise rounding in the source).

🔑 Important: The expected value E[Y]E[Y] is the average number of copies of the gene for a randomly selected person 3.

1.4 Conditional probability and Bayes' Theorem

  • Conditional probability (P(A∣B)P(A|B)): The probability of event A occurring given that event B has already occurred.
    • Formula: P(A∣B)=P(A∩B)P(B)P(A|B) = \frac{P(A \cap B)}{P(B)}
  • Bayes' Theorem: Relates conditional probabilities of events. It's used to update beliefs based on new evidence.
    • Formula: P(V∣B)=P(B∣V)P(V)P(B)P(V|B) = \frac{P(B|V)P(V)}{P(B)}
    • To use this, we first need P(B)P(B), the overall probability of event B. This can be found using the law of total probability: P(B)=P(B∣V)P(V)+P(B∣Vc)P(Vc)P(B) = P(B|V)P(V) + P(B|V^c)P(V^c).

📝 Example: Let VV be the event a customer is vegetarian and BB be the event they choose a plant-based burger. We are given P(V)=0.30P(V)=0.30, P(B∣V)=0.60P(B|V)=0.60, and P(B∣Vc)=0.15P(B|V^c)=0.15.

  • P(Vc)=1−P(V)=1−0.30=0.70P(V^c) = 1 - P(V) = 1 - 0.30 = 0.70.
  • P(B)=P(B∣V)P(V)+P(B∣Vc)P(Vc)=(0.60×0.30)+(0.15×0.70)=0.18+0.105=0.285P(B) = P(B|V)P(V) + P(B|V^c)P(V^c) = (0.60 \times 0.30) + (0.15 \times 0.70) = 0.18 + 0.105 = 0.285.
  • P(V∣B)=P(B∣V)P(V)P(B)=0.60×0.300.285=0.180.285≈0.632P(V|B) = \frac{P(B|V)P(V)}{P(B)} = \frac{0.60 \times 0.30}{0.285} = \frac{0.18}{0.285} \approx 0.632.
EventProbability
VV (Vegetarian)P(V)=0.30P(V) = 0.30
VcV^c (Not Veg.)P(Vc)=0.70P(V^c) = 0.70
BB (Plant-based)P(B)=0.285P(B) = 0.285
$BV$
$BV^c$
$VB$
  • The interpretation of P(B∣Vc)P(B|V^c) is the probability a customer chooses a plant-based burger given they are not vegetarian.
  • The probability that a customer is vegetarian OR chooses a plant-based burger is P(V∪B)=P(V)+P(B)−P(V∩B)P(V \cup B) = P(V) + P(B) - P(V \cap B).
    • P(V∩B)=P(B∣V)P(V)=0.60×0.30=0.18P(V \cap B) = P(B|V)P(V) = 0.60 \times 0.30 = 0.18.
    • P(V∪B)=0.30+0.285−0.18=0.405P(V \cup B) = 0.30 + 0.285 - 0.18 = 0.405.

1.5 Random variables and their properties

  • A random variable is a variable whose value is a numerical outcome of a random phenomenon.
  • Continuous random variables can take any value within a range, often used for measurements 4.
  • Discrete random variables take on a finite or countably infinite number of values, often used for counts.

📝 Example: The pH value of seawater is best modeled using a continuous random variable.

  • For linear combinations of random variables XX and YY:
    • E[aX+bY=aE[X+bE[Y]E[aX + bY = aE[X + bE[Y]
    • Var(aX+bY)=a2Var(X)+b2Var(Y)+2abCov(X,Y)Var(aX + bY) = a^2 Var(X) + b^2 Var(Y) + 2ab Cov(X,Y)
    • If XX and YY are independent, Cov(X,Y)=0Cov(X,Y) = 0, so Var(aX+bY)=a2Var(X)+b2Var(Y)Var(aX + bY) = a^2 Var(X) + b^2 Var(Y).
  • The standard deviation of aX+bYaX + bY is Var(aX+bY)\sqrt{Var(aX + bY)}.

📝 Example: Given E[X]=10,Var(X)=1.5E[X]=10, Var(X)=1.5 and E[Y]=4,Var(Y)=0.5E[Y]=4, Var(Y)=0.5, for a nutrient score 2X−3Y2X-3Y:

  • E[2X−3Y=2E[X−3E[Y=2−3=20−12=8E[2X-3Y = 2E[X - 3E[Y = 2 - 3 = 20 - 12 = 8.
  • Assuming XX and YY are independent: Var(2X−3Y)=22Var(X)+(−3)2Var(Y)=4(1.5)+9(0.5)=6+4.5=10.5Var(2X-3Y) = 2^2 Var(X) + (-3)^2 Var(Y) = 4(1.5) + 9(0.5) = 6 + 4.5 = 10.5.
  • The standard deviation is 10.5≈3.24\sqrt{10.5} \approx 3.24.

1.6 Normal distribution and its properties

  • The normal distribution is a symmetric, bell-shaped curve defined by its mean (μ\mu) and standard deviation (σ\sigma).
  • It is commonly used to model continuous data.
  • Individual observations vary randomly around the population mean (μ\mu) with a typical spread measured by σ\sigma 5.
  • The z-score measures how many standard deviations an observation is from the mean: z=y−μσz = \frac{y - \mu}{\sigma}.

📝 Example: A working memory score is normally distributed with μ=40\mu=40 and σ=8\sigma=8. A score that is 1.5 standard deviations below the mean (z=−1.5z=-1.5) is 40+(−1.5×8)=40−12=2840 + (-1.5 \times 8) = 40 - 12 = 28.

  • To find the probability of a score above a certain value (e.g., >48> 48), we convert it to a z-score and use the cumulative distribution function (CDF), often denoted as pnorm() in software.
    • z=48−408=88=1.0z = \frac{48 - 40}{8} = \frac{8}{8} = 1.0.
    • P(Y>48)=P(Z>1.0)=1−P(Z≤1.0)=1−pnorm(1.0)P(Y > 48) = P(Z > 1.0) = 1 - P(Z \le 1.0) = 1 - \text{pnorm}(1.0).

1.7 Sampling distributions

  • The sampling distribution of the sample mean (yˉ\bar{y}) describes the distribution of sample means if we were to take many samples of the same size from the population.
  • According to the Central Limit Theorem (CLT), if the sample size (nn) is sufficiently large (often n≥30n \ge 30), the sampling distribution of yˉ\bar{y} will be approximately normal, regardless of the population distribution's shape.
  • The mean of the sampling distribution is equal to the population mean (μ\mu).
  • The standard deviation of the sampling distribution (called the standard error) is σn\frac{\sigma}{\sqrt{n}}.

📝 Example: For a population with μ=40\mu=40 and σ=8\sigma=8, a sample of n=64n=64 will have a sampling distribution of yˉ\bar{y} that is approximately normal with:

  • Mean: 4040
  • Standard Error: 864=88=1\frac{8}{\sqrt{64}} = \frac{8}{8} = 1 6.

1.8 Confidence intervals

  • A confidence interval (CI) provides a range of plausible values for an unknown population parameter (e.g., population mean μ\mu).
  • Formula: Estimate±Multiplier×Standard Error\text{Estimate} \pm \text{Multiplier} \times \text{Standard Error}
  • For a 95% CI for the population mean μ\mu when σ\sigma is unknown: yˉ±tn−1,0.975×sn\bar{y} \pm t_{n-1, 0.975} \times \frac{s}{\sqrt{n}}.
    • yˉ\bar{y} is the sample mean.
    • ss is the sample standard deviation.
    • nn is the sample size.
    • tn−1,0.975t_{n-1, 0.975} is the t-multiplier for a 95% confidence level with n−1n-1 degrees of freedom.
  • Increasing the confidence level (e.g., from 95% to 99%) increases the multiplier, leading to a wider interval.

🔑 Important: A 99% confidence interval means we are 99% confident that the true population mean lies within that interval. It does not mean there is a 99% probability that the true mean is in the interval 7.

1.9 Hypothesis testing

  • A hypothesis test is a formal procedure to decide between two competing statements about a population parameter.
  • Null hypothesis (H0H_0): A statement of no effect or no difference.
  • Alternative hypothesis (HAH_A): A statement that contradicts the null hypothesis, suggesting an effect or difference.
  • The p-value is the probability of observing data as extreme as, or more extreme than, what was actually observed, assuming the null hypothesis is true.
  • If the p-value is less than the significance level (α\alpha), we reject the null hypothesis.

🔑 Important: A small p-value (<α< \alpha) indicates that the observed data are unlikely if the null hypothesis were true. It does NOT mean the probability that the null hypothesis is true is equal to the p-value 8.

1.10 Power and sample size

  • Power is the probability of correctly rejecting the null hypothesis when it is false (i.e., detecting a true effect).
  • Factors that increase power:
    • Increasing the sample size.
    • Increasing the significance level (α\alpha).
    • Increasing the effect size (the magnitude of the true difference).
  • Replicating a study generally improves confidence in findings and can contribute to a larger effective sample size if results are combined, indirectly increasing power.

1.11 Two-sample comparisons

  • When comparing means of two independent groups (e.g., drug A vs. drug B), a two-sample t-test is often used.
  • The standard error for the difference in means (yˉ1−yˉ2\bar{y}_1 - \bar{y}_2) is calculated using the sample standard deviations and sizes of both groups: s12n1+s22n2\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}.
  • A confidence interval for the difference in means (μ1−μ2\mu_1 - \mu_2) helps determine if there's a statistically significant difference. If the interval contains 0, there is no statistically significant evidence of a difference at that confidence level. 11.

📝 Example: For drug trials comparing reduction in blood pressure, a 95% confidence interval for the difference in means between Drug A and Drug B that is (−1.13,7.22)(-1.13, 7.22) suggests no significant difference, as it includes 0.

🔑 Important: A confidence interval for a difference in means that contains zero indicates no statistically significant evidence of a difference between the groups. 12 13.

1.12 Hypothesis tests for paired data

  • When data are paired (e.g., measurements before and after an intervention on the same subjects), a paired t-test is appropriate. 9.
  • This test analyzes the differences between the paired observations, treating them as a single sample.
  • The null hypothesis is typically that the mean difference is zero (H0:μd=0H_0: \mu_d = 0).

📝 Example: In a study of controlled burns and soil nitrogen, a paired t-test is used to compare nitrogen levels before and after the burn by analyzing the differences.

🔑 Important: For paired data, always use methods that account for the pairing (like a paired t-test) rather than treating the groups as independent 10.

2. Linear regression and correlation

2.1 Correlation

Correlation coefficient (rr) measures the strength and direction of a linear relationship between two numerical variables. It ranges from -1 (perfect negative linear correlation) to +1 (perfect positive linear correlation).

A value of 0 indicates no linear relationship.

  • Calculation: The cor(x, y) command in R computes the correlation coefficient between numeric vectors x and y.
  • Interpretation: A negative correlation means that as one variable increases, the other tends to decrease. A positive correlation means both variables tend to increase or decrease together. The absolute value of rr indicates strength: closer to 1 means stronger, closer to 0 means weaker.

🔑 Important: Correlation does not imply causation. A strong correlation between two variables doesn't mean one causes the other; there might be a lurking variable influencing both.

Example of correlation interpretation:

SituationCorrelation (rr)Description
Early speaking age and later aptitude test scores-0.64Negative: Older children tend to have lower aptitude scores.
Speed of pitch and pitch type (e.g., fastball vs. curve)PositivePositive: Faster pitches tend to be fastballs, while slower pitches might be curveballs or changeups.

[ -16 15.

2.2 Linear regression

Linear regression models the relationship between a response variable (dependent) and one or more predictor variables (independent). It aims to find the line that best fits the data, allowing us to predict the response based on the predictors.

  • Model form: The general linear regression model is expressed as: y=β0+β1x1+β2x2+...+βkxk+ϵy = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + ... + \beta_k x_k + \epsilon

    • yy: The response variable.
    • β0\beta_0: The intercept, representing the expected value of yy when all predictors are zero.
    • βi\beta_i: The coefficient for predictor xix_i, representing the expected change in yy for a one-unit increase in xix_i, holding other predictors constant.
    • ϵ\epsilon: The error term, representing variability not explained by the model.
  • Estimation Method: Regression coefficients (β^\hat{\beta}) are estimated using least squares. This method minimizes the sum of the squared differences between the observed values of the response variable and the values predicted by the model.

📝 Example: For a model predicting aptitude based on age, aptitude = 109.87 - 1.13 * age, the estimated intercept is 109.87 and the slope is -1.13.

[ -17 16.

2.2.1 Interpreting regression coefficients

  • Intercept (β0\beta_0): Represents the predicted value of the response variable when all predictor variables are zero. Its interpretation is only meaningful if x=0x=0 is a plausible and relevant value within the context of the data.
  • Slope (β1\beta_1): Represents the estimated average change in the response variable for a one-unit increase in the predictor variable, assuming all other predictors are held constant.

🔑 Important: When interpreting β1\beta_1 in a simple linear regression, it represents the average change. When interpreting βi\beta_i in multiple linear regression, it represents the average change while holding other predictors constant.

Interpreting coefficients in a linear model:

ModelInterpretation of β0\beta_0Interpretation of β1\beta_1
aptitude = 109.87 - 1.13 * ageExpected aptitude for a child speaking at 0 months. (Often not interpretable if 0 is outside data range).Expected decrease in aptitude by 1.13 points for each additional month of speaking age.
restingheartrate=150−0.75∗bodymassresting heart rate = 150 - 0.75 * body massExpected heart rate for a mammal with 0 kg body mass. (Not biologically meaningful).Expected decrease in heart rate by 0.75 bpm for each 1 kg increase in body mass.
metabolic_rate = 1623.69 - 18.63 * temperature + 52.64 * activityExpected metabolic rate when temperature is 0°C and activity is 0 hours/day. (Interpretable if 0 is in data).Expected decrease in metabolic rate by 18.63 kcal/day for a 1°C increase in temperature, holding activity constant.

[ -14, 17, 20-21 13.

2.2.2 Model assessment

  • R2R^2 (Coefficient of Determination): Represents the proportion of the variance in the response variable that is explained by the predictor variables in the model. It ranges from 0 to 1. A higher R2R^2 indicates a better fit.

    • R2R^2 is the squared correlation between the observed yy values and the predicted y^\hat{y} values.
    • R2R^2 is also the proportion of variance in the outcome variable explained by the predictors.
  • Standard Error of the Regression: Estimates the typical distance between the observed yy values and the regression line. It represents the variability in the observed yy values around the regression line.

  • Hypothesis Testing: Tests whether the coefficients (βi\beta_i) are significantly different from zero.

    • The p-value for β1\beta_1 tests H0:β1=0H_0: \beta_1 = 0 against HA:β1≠0H_A: \beta_1 \neq 0.
    • A small p-value (typically < 0.05) suggests that the predictor variable is significantly related to the response variable.

📝 Example: An R2R^2 of 0.41 means 41% of the variability in aptitude scores is explained by age.

[ 21-22 17.

2.2.3 Confidence and Prediction Intervals

  • Confidence Interval for Mean Response: Provides a range of plausible values for the average response of individuals with specific predictor values. It is generally narrower than a prediction interval.
  • Prediction Interval: Provides a range of plausible values for an individual response for a new observation with specific predictor values. It is always wider than a confidence interval for the mean response because it accounts for both the uncertainty in the estimated regression line and the inherent variability of individual data points.

🔑 Important: Making predictions outside the range of the observed predictor values (extrapolation) is unreliable, as the linear relationship may not hold.

Interval types:

Interval TypePurposeWidth
Confidence Interval for MeanEstimate the average response for a given predictor value.Narrower
Prediction Interval for IndividualEstimate an individual response for a given predictor value.Wider (accounts for individual variability)

[ ] 18.

2.2.4 Multiple Linear Regression

Multiple linear regression extends simple linear regression by including two or more predictor variables. It allows us to assess the effect of each predictor on the response variable while controlling for the effects of the other predictors.

  • Interpretation: Coefficients (βi\beta_i) in multiple regression are interpreted as the expected change in the response variable for a one-unit increase in xix_i, holding all other predictor variables constant.

🔑 Important: Multiple linear regression allows assessment of each predictor's effect while controlling for others. This is crucial for understanding complex relationships where variables interact.

[ -21 19.

🔑 Important: Understanding both correlation and linear regression is key. Correlation describes the linear association between two variables, while regression models this relationship to predict outcomes and understand the impact of predictors, controlling for other factors.

3. Analysis of variance (ANOVA) and chi-squared tests

3.1 Analysis of variance (ANOVA)

ANOVA is used to compare the means of three or more groups. It works by comparing the variance among the group means to the variance within the groups.

  • Null Hypothesis (H0H_0): All group means are equal (μ1=μ2=μ3=⋯=μk\mu_1 = \mu_2 = \mu_3 = \dots = \mu_k).
  • Alternative Hypothesis (HAH_A): At least one group mean is different.

> 🔑 Important: ANOVA tests if any mean differs, not which specific means differ.

The test statistic in ANOVA is the F-value, which follows an F-distribution if the null hypothesis is true. This F-value is calculated by dividing the variance among groups by the variance within groups.

A larger F-value suggests that the group means explain a significant portion of the variation in the data.

  • F-value: Ratio of variance between groups to variance within groups.
  • F-distribution: Used to determine the p-value for the test.
  • Degrees of freedom: Two values are needed: one for the numerator (related to the number of groups) and one for the denominator (related to the total number of observations minus the number of groups).
ComponentCalculation
F-valueMean Sq (type)Mean Sq (Residuals)\frac{\text{Mean Sq (type)}}{\text{Mean Sq (Residuals)}}
df (type)Number of groups - 1
df (Residuals)Total observations - Number of groups

> 🔑 Important: The ANOVA table provides the F-value and degrees of freedom necessary to find the p-value.

To determine which specific group means differ, post-hoc tests like Tukey's Honestly Significant Difference (HSD) are used. These tests compare all possible pairs of group means while accounting for multiple comparisons.

> 📝 Example: TukeyHSD(a_baseball) compares the mean pitch speeds for all pairs of pitch types (curveball, fastball, etc.).

Comparison (Pitch Type)Difference in Means (μ1−μ2\mu_1 - \mu_2)95% Confidence Intervalp-value (adjusted)Interpretation
CU-CH-18.64-19.27 to -18.000.0000000Curveball is significantly slower than Changeup.
FF-CH11.6811.09 to 12.280.0000000Fastball is significantly faster than Changeup.
SL-CH-0.46-1.07 to 0.150.2128146No significant difference between Slider and Changeup speeds.
FF-CU30.3230.04 to 30.600.0000000Fastball is significantly faster than Curveball.
SL-CU18.1817.86 to 18.490.0000000Slider is significantly faster than Curveball.
SL-FF-12.14-12.36 to -11.930.0000000Slider is significantly slower than Fastball.

> 🔑 Important: A p-value less than α\alpha (e.g., 0.01) from ANOVA indicates that not all group means are equal. Tukey's HSD provides pairwise comparisons with adjusted p-values for multiple testing.

3.2 Chi-squared tests

Chi-squared (χ2\chi^2) tests are used to analyze the association between categorical variables. They compare observed frequencies in a contingency table to expected frequencies if the variables were independent.

  • Null Hypothesis (H0H_0): The variables are independent (no association).
  • Alternative Hypothesis (HAH_A): The variables are related (there is an association).

The test statistic is calculated as the sum of squared differences between observed and expected counts, divided by the expected counts:

X2=∑(observed−expected)2expectedX^2 = \sum \frac{(\text{observed} - \text{expected})^2}{\text{expected}}

The expected count for each cell is calculated using the row and column totals:

Expected=row total×column totaltable total\text{Expected} = \frac{\text{row total} \times \text{column total}}{\text{table total}}

> 🔑 Important: The χ2\chi^2 test assumes independence between categorical variables.

The degrees of freedom for a chi-squared test in a contingency table are calculated as: df=(Number of Rows−1)×(Number of Columns−1)df = (\text{Number of Rows} - 1) \times (\text{Number of Columns} - 1).

For exploratory analysis, a p-value less than α\alpha (e.g., 0.05) suggests that the observed data are unlikely if the null hypothesis of independence is true.

> 📝 Example: A chi-squared test can determine if there's an association between diet type (large, moderate, small, never) and prostate cancer status (yes/no) in Swedish men. The p-value from the test indicates if the observed counts are unusual given independence.

3.2.1 Comparing proportions with prop.test and chisq.test

When comparing proportions between two groups, both prop.test and chisq.test can be used. prop.test directly tests the difference in proportions, while chisq.test is a more general test for contingency tables.

  • prop.test Hypotheses:
    • H0:p1−p2=0H_0: p_1 - p_2 = 0 (The true proportions are equal).
    • HA:p1−p2≠0H_A: p_1 - p_2 \neq 0 (The true proportions are different).
  • chisq.test Hypotheses:
    • H0H_0: Variables are independent.
    • HAH_A: Variables are related.

While both tests use similar underlying calculations for 2x2 tables, prop.test is often preferred for directly testing proportion differences, whereas chisq.test is more versatile for larger contingency tables.

> 🔑 Important: Using multiple statistical tests without adjustment (like Bonferroni correction) increases the chance of a Type I error (falsely rejecting the null hypothesis).

> 🔑 Important: Perform multiple tests cautiously. The main danger is an increased chance of a Type I error.

© 2026 Maeve. All rights reserved. This content is protected by copyright.

See also