Reputation: 508
I'm looking for a function which do the same thing as excel's CHIINV. From Microsoft documentation, the definition of CHIINV is Returns the inverse of the right-tailed probability of the chi-squared distribution
For example
=CHIINV(0.2,2)
return 3.21
The closest function I can found in R is geoR's dinvchisq However,
dinvchisq(0.2,2)
return 1.026062
Please help!
Upvotes: 2
Views: 2080
Reputation: 11903
What you want is ?qchisq. This takes a probability and a degrees of freedom, and outputs the associated quantile. Consider:
> qchisq(p=0.2, df=2, lower.tail=FALSE)
[1] 3.218876
Furthermore, according the the documentation, dinvchisq()
is the density function (the height of the pdf at a given quantile) of the inverse of the chi-squared distribution. That is, 1/dchisq(). You need the quantile function, not the density function, and you don't want the inverse of the chi-squared distribution (although the confusion seems natural coming from Excel's function).
Upvotes: 4