- I will present a short overview of hypothesis testing and p-values with some examples.
- I used basic data sets,
mtcarsandiris.
October 18, 2025
mtcars and iris.Let \(T(X)\) be a test statistic under \(H_0\).
The p-value is \[ {\ p=\Pr(T\geq t\mid H_{0})} \]
for a one-sided right-tail test-statistic distribution.
Let \(\ {\hat {\beta }}\) be an estimator of parameter \(\beta\) in some statistical model.
Then a t-test for this parameter is \[ {\ t_{\hat {\beta }}={\frac {{\hat {\beta }}-\beta _{0}}{\operatorname {s.e.} ({\hat {\beta }})}},} \]
Test if the average fuel efficiency equals 20 MPG
Distribution of MPG with sample mean
Two-sample t-test on iris. Compare mean Petal Width between setosa and versicolor.
## cohens_d ## 1 -6.816068
data(mtcars) test1 <- t.test(mtcars$mpg, mu = 20) mpg_df <- data.frame(mpg = mtcars$mpg) library(ggplot2) p_hist <- ggplot(mpg_df, aes(x = mpg)) + geom_histogram(binwidth = 2) + geom_vline(aes(xintercept = mean(mpg)), linetype = "dashed") print(test1)
## ## One Sample t-test ## ## data: mtcars$mpg ## t = 0.08506, df = 31, p-value = 0.9328 ## alternative hypothesis: true mean is not equal to 20 ## 95 percent confidence interval: ## 17.91768 22.26357 ## sample estimates: ## mean of x ## 20.09062