elections

reference:
- Tintle, et al., ISI, example 1.4, p. 54

hypotheses

Define \(\pi\).

SOLUTION:

\[H_0 : \pi = 0.50\] \[H_a : \pi > 0.50\] Assign values to \(\pi\) and \(\alpha\)

pi <- 0.50
alpha <- 0.05

observed statistic

x <- 23                # number of successes
n <- 32                # sample size
(p.hat.observed <- x / n)
## [1] 0.71875

data

elections <- data.frame(response = c("correct prediction", "incorrect prediction"),
                        p = c(p.hat.observed, 1 - p.hat.observed))
elections
##               response       p
## 1   correct prediction 0.71875
## 2 incorrect prediction 0.28125
str(elections)
## 'data.frame':    2 obs. of  2 variables:
##  $ response: Factor w/ 2 levels "correct prediction",..: 1 2
##  $ p       : num  0.719 0.281
ggplot(elections, aes(response, p, fill = response)) +
  geom_bar(stat = "identity") +
  scale_fill_manual(values = c("deepskyblue", "powderblue")) +
  labs(title = "Election")