I currently try to transform a Gamma into a Chi-square (X2) and calculate a 95% confidence interval.
So, let's say I have a Gamma distribution of $$Gamma(4.5, 4)$$
Given the answer in
https://math.stackexchange.com/questions/1575050/transforming-gamma-into-chi-squared-distribution
I can transform the gamma into a chi-square by
To get theta, I do
$$\frac{1}{2\theta}=4$$ $$\theta = \frac{1}{8}$$
Then, I would get
$$8Y = \chi^2(2*4.5) = \chi^2(9)$$
I can get the constants from a X2-table for 9 degrees of freedom with
$$lower = 2.70$$
$$upper = 19.02$$
I would then multiply by 8 to get $$P(8*lower < Y < 8*upper)$$ for the desired interval for the gamma, which is way too large.
However, when I use R to calculate the upper and lower bounds by using
alpha <- 4.5
beta <- 4
alpha_conf <- 0.05
q_lower <- qgamma(alpha_conf / 2, alpha, beta)
q_upper <- qgamma(1 - alpha_conf / 2, alpha, beta)
c(q_lower, q_upper)
I get $$P(0.3375487 < Y < 2.3778460)$$ which makes much more sense looking at the data. I realized that the constants I got from the X2-table will give me the same result, if I do $$P(\frac{1}{8}*lower < Y < \frac{1}{8}*upper)$$
If I use the formula given in Probability Interval for Gamma Distribution I get yet another solution (alpha and beta are reverse to my syntax, so in that case it would be Gamma(4, 4.5)). With
$$\frac{2*Y}{4} \sim \chi^2(9)$$ $$\frac{1}{2}*Y \sim \chi^2(9)$$,
which, again, would not give me the correct result.
Assuming that the calculations in R are correct, I don't know where my mistake is. Thanks for the help!
