[R] how to use R for Beta Negative Binomial
Duncan Murdoch
murdoch at stats.uwo.ca
Sun Jan 6 16:01:15 CET 2008
On 06/01/2008 9:36 AM, Nasser Abbasi wrote:
> I think I should have posted this question here as well. I am posting my
> question here since it is R related. Please see below. I originally posted
> this to sci.stat.math
>
>
> "Nasser Abbasi" <nma at 12000.org> wrote in message
> news:Mm4gj.28843$R92.4987 at newsfe16.phx...
>> I think R documentation is a bit hard for me to sort out at this time.
>>
>> I was wondering if someone who knows R better than I do could please let
>> me know the command syntax to find the mean of Beta Negative Binomial
>> Distribution for the following parameters:
>>
>> n=3
>> alpha=0.5
>> beta=3
>>
>> Here is the documenation page for R which mentions this distribution
>>
>> http://rweb.stat.umn.edu/R/library/SuppDists/html/ghyper.html
>>
>> Using Mathematica, I get (-18) for the mean and -150 for the variance,
>> and wanted to verify this with R, since there is a negative sign which is
>> confusing me.
A variance could not be negative, so clearly Mathematica has it wrong.
>>
>> Mathematica says the formula for the mean is n*beta/(alpha-1) and that
>> is why the negative sign comes up.
>> alpha, beta, n can be any positive real numbers.
>>
>> If someone can just show me the R command for this, that will help, I have
>> the R package SuppDists installed, I am just not sure how to use it for
>> this distribution.
>>
>> thanks,
>> Nasser
>>
>
> I thought I should show what I did, this is R 2.6.1:
>
> tghyper(a=-1, k=-1, N=5) %I think this makes it do Beta Negative Binomail
It reports itself as
> tghyper(a=-1, k=-1, N=5)
[1] "type = IV -- x = 0,1,2,..."
which I believe indicates Beta-negative-binomial.
>
> and now I used summary command, right?
>
> sghyper(3, .5, 3)
Why did you change the parameters? If you used the same ones as above,
you get
> sghyper(a=-1, k=-1, N=5)
$title
[1] "Generalized Hypergeometric"
$a
[1] -1
$k
[1] -1
$N
[1] 5
$Mean
[1] 0.2
$Median
[1] 0
$Mode
[1] 0
$Variance
[1] 0.36
$SD
[1] 0.6
$ThirdCentralMoment
[1] 1.176
$FourthCentralMoment
[1] 8.9712
$PearsonsSkewness...mean.minus.mode.div.SD
[1] 0.3333333
$Skewness...sqrtB1
[1] 5.444444
$Kurtosis...B2.minus.3
[1] 66.22222
I don't know if those values are correct, but at least they aren't
nonsensical like the ones you report from Mathematica.
Duncan Murdoch
>
> But I do not think this is correct.Tried few other permitations. Hard for me
> to see how to set the parameters correctly for this distribution.
>
> thanks,
> Nasser
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list