Hypothesis Testing and Statistical Analysis
Formulating Hypotheses
In statistical analysis, the first step is often formulating hypotheses. These are statements about population parameters that we aim to test using sample data.
- Null Hypothesis (H₀): This is the default assumption, typically stating that there's no effect or no difference between groups.
- Alternative Hypothesis (H₁): This is what we're testing for, often suggesting a difference or effect exists.
For a study on a new teaching method: H₀: The new method has no effect on test scores. H₁: The new method improves test scores.
NoteThe alternative hypothesis can be one-tailed (specifying a direction) or two-tailed (any difference).
Significance Levels and p-values
- Significance Level (α): The probability of rejecting H₀ when it's actually true (Type I error).
- Common levels: 0.05, 0.01, 0.001
- p-value: The probability of obtaining results at least as extreme as the observed results, assuming H₀ is true.
A p-value less than α leads to rejecting H₀.
Chi-Squared Tests
Expected and Observed Frequencies
- Observed Frequencies: The actual counts in your data.
- Expected Frequencies: What you'd expect if H₀ were true.
Chi-Squared Test for Independence
This test determines if there's a significant relationship between two categorical variables.
- Create a contingency table of observed frequencies.
- Calculate expected frequencies for each cell.
- Calculate the chi-squared statistic: $$ \chi^2 = \sum \frac{(O - E)^2}{E} $$ where O is observed frequency and E is expected frequency.
- Determine degrees of freedom: (rows - 1) × (columns - 1)
- Compare $\chi^2$ to critical value or use p-value.
Testing if gender and preference for math are independent:
Calculated $\chi^2=2.78, \mathrm{df}=1$ For $\alpha=0.05$, critical value $=3.84$
Since $2.78<3.84$, fail to reject $\mathrm{H}_{\mathrm{o}}$.
Chi-Squared Goodness of Fit Test
- This test compares observed frequencies to a theoretical distribution.
- Steps are similar to the independence test, but expected frequencies come from the theoretical distribution.
t-Test
The t-test compares means of two groups, assuming normal distributions.
Types of t-Tests
- One-sample t-test: Compares a sample mean to a known population mean.
- Independent two-sample t-test: Compares means of two independent groups.
- Paired t-test: Compares means of two related groups.
Performing a t-Test
- Calculate the t-statistic: For two-sample test:$$t=\frac{\bar{x}_1-\bar{x}_2}{\sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}}}$$ where $\bar{x}$ is sample mean, $s^2$ is sample variance, and $n$ is sample size.
- Determine degrees of freedom (varies by test type).
- Compare t-statistic to critical value or use p-value.
Why Use the t-Test?
The t-test is used in hypothesis testing when comparing the means of two groups to determine if there is a significant difference between them. It is particularly useful when:
- The sample size is small ($n < 30$).
- The population standard deviation ($\sigma$) is unknown.
- The data is approximately normally distributed.
There are different types of t-tests based on the comparison being made:
- One-sample t-test: Compares the sample mean to a known population mean.
- Independent (two-sample) t-test: Compares the means of two independent groups.
- Paired t-test: Compares the means of two related groups (e.g., before-and-after measurements).
A company wants to test whether a new training program improves employee productivity. They randomly select 15 employees and measure the number of tasks they complete per day before and after the training.
The hypotheses are:
- Null Hypothesis ($H_0$): The training has no effect on productivity (mean before = mean after).
- Alternative Hypothesis ($H_1$): The training improves productivity (mean after > mean before).
Using a paired t-test, the test statistic is calculated as:
$$t = \frac{\bar{X}_d}{\frac{s_d}{\sqrt{n}}}$$
Where:
- $\bar{X}_d$ is the mean difference between before-and-after scores.
- $s_d$ is the standard deviation of the differences.
- $n$ is the number of employees.
If the computed t-value exceeds the critical t-value from the t-table (based on degrees of freedom and chosen significance level $\alpha$), we reject $H_0$ and conclude that the training improved productivity.