[R] [SPAM](Aktien) Re: Chi-square distribution probability density function:
David Winsemius
dwinsemius at comcast.net
Wed Jul 21 19:01:50 CEST 2010
On Jul 21, 2010, at 12:36 PM, Knut Krueger wrote:
> David Winsemius schrieb:
>>
>>
>> On Jul 21, 2010, at 6:52 AM, Knut Krueger wrote:
>>
>>> Hi to all I found
>>> an formular of an **
>>> ***p-Value Calculator for the Chi-Square test*
>>> *http://www.danielsoper.com/statcalc/calc11.aspx*
>>> *with the formula*
>>> <http://www.danielsoper.com/statkb/topic11.aspx>
>>> *what's the gamma function of this formula in r?*
>>> *df=5*
>>> *ch2=25.50878*
>>> *the following code does not give the result <0.001 for the
>>> values above *
>>> *p= ((0.5^(df/2))/gamma(df))*(ch2^((df/2)-1))* (2.718281828459^(-
>>> ch2/2))
>>> or is there any other error?
>>
>> Check your implementation of that formula. You made an error in the
>> gamma argument.
>>
> Sorry a copy and paste error but gamma(df/2) does not solve the
> problem
> I am not able to get the implementation of the function working :-(
>
>> See also:
>>
>> ?Chisquare
>> ?gamma
>
> there is also a different result using this function from the helpf
> files and the function
> /f_n(x) = 1 / (2^(n/2) Gamma(n/2)) x^(n/2-1) e^(-x/2)
That is (perhaps) because you are confusing a density function with a
cumulative probability function. The expression above should give the
same result as a (proper) R transcription of the formula on the page
you offered above and should be what dchisq referenced on the ?
Chisquare page returns as well.
Sure enough...
> dchisq(25.50878, 5)
[1] 4.951e-05
> p= ((0.5^(df/2))/gamma(df/2))*(ch2^((df/2)-1))* (2.718281828459^(-
ch2/2))
> p
[1] 4.951e-05
Those formulae only differ in how they use grouping of the constant
terms. (In R the function is gamma, not Gamma.) You should be able to
get the P(X^2|x>25.508, df=5) from an integration of that function.
>
> Knut
>
> /
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list