This project explores α-errors (Type I errors) in a two-sample t-test under different sample sizes.
The idea: simulate, test, and visualize how often we falsely reject the null hypothesis when the samples actually come from the same normal distribution.
-
Simulation setup
- Define a vector of sample sizes →
sample_sizes - Set significance level →
sign_level - Choose number of simulations →
total_simulations - Specify tests per simulation →
tests_per_simulation
- Define a vector of sample sizes →
-
Within each simulation
- Two samples of equal size are drawn from a normal distribution (
rnorm()with random mean & sd). - A series of t-tests is performed.
- Results are classified as significant / not significant based on
sign_level.
- Two samples of equal size are drawn from a normal distribution (
-
Output
- For each sample size, the ratio of significant tests is computed.
- Results are visualized with boxplots, showing the empirical Type I error vs. the theoretical
sign_level.