-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DomainError from sqrt in ChisqTest #281
Comments
Having the same problem. julia> approx_contingency = [
(2609 - 325) * .27 325 * .16;
(2609 - 325) * (1-.27) 325 * (1-.16);
]
2×2 Matrix{Float64}:
616.68 52.0
1667.32 273.0
julia> contingency = round.(Int, approx_contingency)
2×2 Matrix{Int64}:
617 52
1667 273
julia> ChisqTest(contingency)
Pearson's Chi-square Test
-------------------------
Population details:
parameter of interest: Multinomial Probabilities
value under h_0: [0.224478, 0.650953, 0.0319419, 0.0926269]
point estimate: [0.236489, 0.638942, 0.019931, 0.104638]
Error showing value of type PowerDivergenceTest:
ERROR: DomainError with -1.4430408161224477:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
julia> MultinomialLRTest(contingency)
Multinomial Likelihood Ratio Test
---------------------------------
Population details:
parameter of interest: Multinomial Probabilities
value under h_0: [0.224478, 0.650953, 0.0319419, 0.0926269]
point estimate: [0.236489, 0.638942, 0.019931, 0.104638]
Error showing value of type PowerDivergenceTest:
ERROR: DomainError with -1.4430408161224477:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)). |
If somebody with access to SAS could try out the SAS macro, it would be a useful data point to know if the SAS macro fails in the same way or if our translation has introduced the issue. |
I don't have access to SAS, but if the specific confidence procedure isn't critical here, I think a Bayesian credible interval with an uninformative prior would be dramatically simpler and work just as well, if not better. The solution is just a conjugate Dirichlet distribution. |
In general, credible intervals are no confidence intervals and don't satisfy any coverage guarantees. |
Not in general, but they do asymptotically for simple problems like this one. For binomial confidence intervals there's not really any popular interval constructions with exact coverage guarantees; all popular intervals are based on the Central Limit theorem. The uninformative prior credible interval is widely-used here, even by frequentists, because the frequentist coverage of the procedure is good even for very small samples--see e.g. this paper. |
Continued from @joshday's comment #125 (comment) in this new issue since the underlying bug is different. The reproducer is
The issue is with this function
HypothesisTests.jl/src/power_divergence.jl
Lines 133 to 182 in a891451
which is based on the SAS script from https://www.jstatsoft.org/index.php/jss/article/view/v005i06/621. I'm not sure what the issue is.
The text was updated successfully, but these errors were encountered: