Re: [R] how to use R for Beta Negative Binomial

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Sun, 06 Jan 2008 10:01:15 -0500

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.



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. Received on Sun 06 Jan 2008 - 15:05:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jan 2008 - 05:30:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive