Skip to content

Commit

Permalink
Add comment about computation to clr_critical_value_function (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlondschien authored Jun 7, 2024
1 parent 9aa042d commit d758176
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ivmodels/tests/conditional_likelihood_ratio.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,22 @@ def conditional_likelihood_ratio_critical_value_function(
if method in ["numerical_integration"]:
alpha = (q - p) / 2.0
beta = p / 2.0
a = s_min / (z + s_min)

# We wish to integrate
# beta = beta(alpha, beta); chi2 = chi2(q)
# int_0^1 chi2.cdf(z / (1 - a * x)) * beta.pdf(x, (q - p) / 2, p / 2) dx
#
# use
# beta(alpha, beta).pdf = 1/B(alpha, beta) * x^{alpha - 1} * (1 - x)^{beta - 1}
# and
# chi2(q).cdf(x) = 1/Gamma(k/2) * gamma(k/2, x/2)
# = scipy.special.gammainc(k/2, x/2).
# substitute y <- 1 - a * x and use the QUADPACK routine qawse
# (see scipy.special.gammainc)
k = q / 2.0
z_over_2 = z / 2.0

a = s_min / (z + s_min)
const = np.power(a, -alpha - beta + 1) / scipy.special.beta(alpha, beta)

def integrand(y):
Expand Down

0 comments on commit d758176

Please sign in to comment.