kissing

references:
- ISI, exploration 3.1, p.164

library(tidyverse)
library(knitr)

hypotheses

\[H_0 : \pi = 0.50\] \[H_0 : \pi > 0.50\]

State \(\pi\) and \(\alpha\).

pi <- 0.50
alpha <- 0.05

observed statistic

x <- 80
n <- 124
(p.hat.observed <- x / n)
## [1] 0.6451613

simulation

kissing124 <- function(){
  samp <- sample(c(0, 1), size = n, replace = TRUE)
  p.hat <- mean(samp)
  test.statistic <- p.hat
  return(test.statistic)
}

10 trials

replicate(10, kissing124())
##  [1] 0.4919355 0.4354839 0.5403226 0.4838710 0.4758065 0.4354839 0.5161290
##  [8] 0.4758065 0.4919355 0.4838710

simulated sampling distribution of \(\widehat{p}\)

n.experiments <- 1000
df1 <- data.frame(p.hat = replicate(n.experiments, kissing124()))
str(df1)
## 'data.frame':    1000 obs. of  1 variable:
##  $ p.hat: num  0.5 0.508 0.54 0.54 0.5 ...
draw.sampling.distribution(df1)