halloween

reference:
- Tintle, et al., ISI, example 1.5, p. 64

hypotheses

Define \(\pi\).

SOLUTION:

\[H_0 : \pi = 0.50\] \[H_a : \pi \not= 0.50\]

Assign values to \(\pi\) and \(\alpha\)

pi <- 0.50
alpha <- 0.05

observed statistic

x <- 148                # number of successes
n <- 283                # sample size
(p.hat.observed <- x / n)
## [1] 0.5229682

data

halloween <- data.frame(response = c("candy", "toy"),
                        p = c(p.hat.observed, 1 - p.hat.observed))
halloween
##   response         p
## 1    candy 0.5229682
## 2      toy 0.4770318
str(halloween)
## 'data.frame':    2 obs. of  2 variables:
##  $ response: Factor w/ 2 levels "candy","toy": 1 2
##  $ p       : num  0.523 0.477
ggplot(halloween, aes(response, p, fill = response)) +
  geom_bar(stat = "identity") +
  scale_fill_manual(values = c("orange", "yellow")) +
  labs(title = "Colors")