[R] Fitting the negative hypergeometric distribution

Wilson, Andrew a.wilson at lancaster.ac.uk
Wed Aug 31 09:53:01 CEST 2011


I'd like to fit the (1-displaced) negative hypergeometric distribution
to data samples such as the following:-

x <- c(370, 311, 299, 266, 265, 232, 197, 198, 170, 154, 133, 123, 120,
103, 80, 72, 69, 67, 67, 50, 36, 35, 26, 23, 15, 11, 9, 6, 5, 3, 3, 2,
2, 2)

i.e., I want to estimate the parameter values of K and M (with my data,
n would usually be the same as the length of the data vector) and then
test for goodness of fit.  However, a search of the R website and R-Help
archives threw up only a couple of mentions of the negative
hypergeometric...

Could anyone be of any help?  I thought I might be able to use the
fitdistr function in MASS with a densfun something like:

dneghyper <-
function(x,M,K,n){(choose(M+x,x-1)*choose(K-M+n-x,n-x+1))/choose(K+n-1,n
)}

but it throws up errors ("initial value in 'vmmin' is not finite") even
when I use the actual parameter values or similar, as estimated by
another program, for the start values...

Maybe I am doing something obviously wrong here, or perhaps there is a
better solution.

Many thanks,

Andrew Wilson



More information about the R-help mailing list