<jupyter_start><jupyter_text>Analysis Part I<jupyter_code>import numpy as np
from cibin import tau_twosided_ci
from cibin import hypergeom_conf_interval<jupyter_output><empty_output><jupyter_text>One-sided confidence intervals  Upper one-sided bounds<jupyter_code># Regeneron data
n=753
m=752
N=n+m
n01 = 59
n11 = 11
n00 = m-n01
n10 = n-n11
alpha=0.05
# retrieve upper one-sided bounds via simultaneous Bonferroni confidence bounds for N_+1 and N_1+ 
Ndot_1 = hypergeom_conf_interval(n11*N/n, n11, N, 1-alpha/2, alternative="upper")
N1_dot = hypergeom_conf_interval(n01*N/70, n01, N, 1-alpha/2, alternative="lower")
upp = (Ndot_1[1] - N1_dot[0])/N
lower = (Ndot_1[0] - N1_dot[1])/N
ci = [lower, upp]
ci<jupyter_output><empty_output><jupyter_text>Lower one-sided bounds<jupyter_code># retrieve lower one-sided bounds via simultaneous Bonferroni confidence bounds for N_+1 and N_1+
Ndot_1 = hypergeom_conf_interval(n11*N/n, n11, N, 1-alpha/2, alternative="lower")
N1_dot = hypergeom_conf_interval(n01*N/70, n01, N, 1-alpha/2, alternative="upper")
upp = (Ndot_1[1] - N1_dot[0])/N
lower = (Ndot_1[0] - N1_dot[1])/N
ci = [lower, upp]
ci<jupyter_output><empty_output><jupyter_text>Two-sided confidence intervals  Two-sided bounds with Sterne method<jupyter_code># retrieve two-sided bounds via Sterne's method
Ndot_1 = hypergeom_conf_interval(round(n11*N/n), n11, N, 1-alpha, alternative="two-sided")
N1_dot = hypergeom_conf_interval(round(n01*N/70), n01, N, 1-alpha, alternative="two-sided")
lower = (Ndot_1[0] - N1_dot[1])/N
upp = (Ndot_1[1] - N1_dot[0])/N
ci=[lower,upp]
ci<jupyter_output><empty_output><jupyter_text>Two-sided bounds with Li and Ding's method 3<jupyter_code># retrieve two-sided bounds via method 3 in Li and Ding
ci = tau_twosided_ci(n11, n10, n01, n00, 0.05,exact=False, reps=1)[0]
ci<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13278688524590163, 'fraction_numerical': 0.06229508196721312, 'mean_word_length': 6.758474576271187, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '155102', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 823, 'n_tokens_neox': 752, 'n_words': 163, 'path': 'analysis-I.ipynb', 'repo_name': 'UCB-stat-159-s21/homework-8-group-3-1', 'size': '1830'}