8.3

The true value of theta affects the variability of the estimator. When a theta value is low, then there is a faster convergences rate to get to 1. While a high theta value is the opposite and has a lower convergences rate to get to one like 0.8.

library(tidyverse)
Warning: package 'tidyverse' was built under R version 4.4.3
Warning: package 'ggplot2' was built under R version 4.4.3
Warning: package 'tidyr' was built under R version 4.4.3
Warning: package 'readr' was built under R version 4.4.3
Warning: package 'purrr' was built under R version 4.4.3
Warning: package 'dplyr' was built under R version 4.4.3
Warning: package 'stringr' was built under R version 4.4.3
Warning: package 'forcats' was built under R version 4.4.3
Warning: package 'lubridate' was built under R version 4.4.3
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   4.0.1     ✔ tibble    3.2.1
✔ lubridate 1.9.4     ✔ tidyr     1.3.1
✔ purrr     1.0.4     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(purrrfect)

Attaching package: 'purrrfect'

The following objects are masked from 'package:base':

    replicate, tabulate
epsilon <- 0.1
theta_grid <- c(0.2, 0.5, 0.8)

(theta_many_runs <- parameters(
            ~theta,~n,
            theta_grid,
             seq(50,1000, by = 50))%>%
  add_trials(5000)%>%
mutate(theta_hat = map2_dbl(n, theta, \(n, theta) {
  y <- rbeta(n, shape1 = theta, shape2 = 3)
  (2/n) * sum(y/(1-y))
}))%>%
  mutate(within_epsilon = ifelse(abs(theta_hat-theta) < epsilon, 1, 0))%>%
  group_by(theta, n)%>%
   summarise(prob = mean(within_epsilon), .groups='drop')
  )
# A tibble: 60 × 3
   theta     n  prob
   <dbl> <dbl> <dbl>
 1   0.2    50 0.820
 2   0.2   100 0.928
 3   0.2   150 0.953
 4   0.2   200 0.970
 5   0.2   250 0.980
 6   0.2   300 0.985
 7   0.2   350 0.989
 8   0.2   400 0.993
 9   0.2   450 0.994
10   0.2   500 0.995
# ℹ 50 more rows
ggplot(theta_many_runs)+
  geom_line(aes(x = n, y = prob, color = factor(theta)))+
  labs(
    x = "n",
    y = expression(P(abs(hat(theta) - theta) < epsilon)),
    color = expression(theta)
  )+ 
  theme_classic(base_size =16)