I tried the function flexmix() with the driver FLXMRnegbin() with two components first, in order to compare its results with those provided by my function mixnbinom(). In particular, I ran the following code:

fm0 <- flexmix(y ~ 1, data = data.frame(y), k = 2, model = FLXMRnegbin())


where "y" is my vector of counts. The previous function provided me the following parameters:


                   Comp.1   Comp.2
coef.(Intercept) 1.2746536 1.788578
theta            0.1418201 5.028766


with priors 0.342874 and 0.657126, respectively. I assume that the coefficients "Intercept" represent the two means of the model (mu1 and mu2), while the "theta" coefficients are the size parameters (size1 and size2).

Unfortunately, unlike my function mixnbinom(), the model computed with flexmix() did not provide a good fit to my data (p-value ~0).

Is there something wrong in the process above?



Achim Zeileis <achim.zeil...@uibk.ac.at> ha scritto:

On Mon, 7 Nov 2016, danilo.car...@uniparthenope.it wrote:

I need a function for R software which computes a mixture of Negative
Binomial distributions with at least three components.

The package "countreg" on R-Forge provides a driver FLXMRnegbin() that can be combined with the "flexmix" package (i.e., functions flexmix() and stepFlexmix()). The manual page provides some worked illustrations in example("FLXMRnegbin", package = "countreg").

Note that the driver is mainly designed for negative binomial _regression_ models. But if you just regress on a constant (y ~ 1) you can also get negative binomial mixture distributions without covariates.


-------------------------------------------------------------
Danilo Carità

PhD Candidate
University of Naples "Parthenope"
Dipartimento di Studi Aziendali e Quantitativi
via G. Parisi, 13, 80132 Napoli - Italy

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to