# Unemployment percent solution


Find this notebook on the web at
<a class="quarto-xref" href="https://resampling-stats.github.io/edition-3-r/exercise_solutions.html#nte-unemployment_percent_solution">Note <span>A.3</span></a>.

```{r}
n_trials <- 10000
results <- numeric(n_trials)

for (i in 1:n_trials) {
    fake_people <- sample(c('no job', 'job'),
                          size=200,
                          replace=TRUE,
                          prob=c(0.07, 0.93))
    p_unemployed <- sum(fake_people == 'no job') / 200
    results[i] <- p_unemployed
}

hist(results, breaks=25,
     main='Bootstrap distribution p unemployed',
     xlab='Bootstrap p unemployed')

p_limits <- quantile(results, c(0.025, 0.975))
rounded <- round(p_limits, 3)
message('95% percent limits for p differences: ', rounded[1], ' ', rounded[2])
```
