#| fig-cap: "Rejection regions for one-tailed (left) and two-tailed (right) tests at α = 0.05. In the one-tailed test all 5% is in the right tail; in the two-tailed test 2.5% is allocated to each tail. Shaded red regions are rejection regions; the shaded gray region shows the non-rejection region."
par(mfrow = c(1, 2), mar = c(4, 4, 3, 1))
z <- seq(-3.5, 3.5, length.out = 500)
yz <- dnorm(z)
# --- One-tailed ---
plot(z, yz, type = "l", lwd = 2, col = "navy",
main = "One-Tailed (Right)\nα = 0.05",
xlab = "z", ylab = "Density")
# Gray non-rejection region
z_nr <- z[z <= qnorm(0.95)]
polygon(c(z_nr, rev(z_nr)),
c(dnorm(z_nr), rep(0, length(z_nr))),
col = "lightgray", border = NA)
# Red rejection region
z_rj <- z[z >= qnorm(0.95)]
polygon(c(z_rj, rev(z_rj)),
c(dnorm(z_rj), rep(0, length(z_rj))),
col = rgb(1, 0, 0, 0.5), border = NA)
abline(v = qnorm(0.95), lty = 2, col = "red")
text(qnorm(0.95) + 0.1, 0.20, paste0("z = ", round(qnorm(0.95),2)),
col = "red", cex = 0.75, adj = 0)
text(2.8, 0.05, "α = 0.05", col = "red", cex = 0.75)
# --- Two-tailed ---
plot(z, yz, type = "l", lwd = 2, col = "navy",
main = "Two-Tailed\nα = 0.05",
xlab = "z", ylab = "Density")
# Gray non-rejection region
z_nr2 <- z[z >= qnorm(0.025) & z <= qnorm(0.975)]
polygon(c(z_nr2, rev(z_nr2)),
c(dnorm(z_nr2), rep(0, length(z_nr2))),
col = "lightgray", border = NA)
# Red left tail
z_L <- z[z <= qnorm(0.025)]
polygon(c(z_L, rev(z_L)), c(dnorm(z_L), rep(0, length(z_L))),
col = rgb(1,0,0,0.5), border = NA)
# Red right tail
z_R <- z[z >= qnorm(0.975)]
polygon(c(z_R, rev(z_R)), c(dnorm(z_R), rep(0, length(z_R))),
col = rgb(1,0,0,0.5), border = NA)
abline(v = qnorm(0.025), lty = 2, col = "red")
abline(v = qnorm(0.975), lty = 2, col = "red")
text(qnorm(0.025) - 0.1, 0.20, paste0("z = ", round(qnorm(0.025),2)),
col = "red", cex = 0.72, adj = 1)
text(qnorm(0.975) + 0.1, 0.20, paste0("z = ", round(qnorm(0.975),2)),
col = "red", cex = 0.72, adj = 0)
text(-3, 0.05, "α/2", col = "red", cex = 0.75)
text( 3, 0.05, "α/2", col = "red", cex = 0.75)
par(mfrow = c(1,1))