This function fits the semi-supervised negative binomial mixture model. It is called by fit.wrap.

fit.nbinom(y, z, phi, gamma, it.em, epsilon)

Arguments

y

observations: numeric vector of length n

z

class labels: integer vector of length n, with entries 0, 1 and NA

phi

dispersion parameters: numeric vector of length q, or NULL

gamma

offset: numeric vector of length n, or NULL

it.em

(maximum) number of iterations in the EM algorithm: positive integer (defaults to 100)

epsilon

convergence criterion for the EM algorithm: non-negative numeric (defaults to 1e-04)

Value

This function returns the parameter estimates, the posterior probabilities, and the likelihood.

See also

This is an internal function. The user functions are mixtura and scrutor.

Examples

# data simulation n <- 100 z <- rep(0:1,each=n/2) gamma <- runif(n=n,min=0,max=2) y <- rnbinom(n=n,mu=gamma*(5+2*z),size=1/0.05) z[(n/4):n] <- NA # model fitting fit.nbinom(y,z,phi=0.05,gamma=gamma, it.em=100,epsilon=1e-04)
#> $posterior #> [1] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 #> [8] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 #> [15] 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 #> [22] 0.0000000 0.0000000 0.0000000 0.4272218 0.1971945 0.1784949 0.6797872 #> [29] 0.5827033 0.3881271 0.7592542 0.3800978 0.4927769 0.5403270 0.6017071 #> [36] 0.7828652 0.3747363 0.2738928 0.4858736 0.3136111 0.5630341 0.4953729 #> [43] 0.1559673 0.4780165 0.5382005 0.3920399 0.4018382 0.5832809 0.4714774 #> [50] 0.6298026 0.4812459 0.7265057 0.6397368 0.4302865 0.5987076 0.4901308 #> [57] 0.4633622 0.4614612 0.6168897 0.3544068 0.4290878 0.9361323 0.6609553 #> [64] 0.3425675 0.4687305 0.7660202 0.4545031 0.4063723 0.2518509 0.6005453 #> [71] 0.8315004 0.5674790 0.6533375 0.6668755 0.4032816 0.3712008 0.5196532 #> [78] 0.4174262 0.5794661 0.4229386 0.2749729 0.4890809 0.4383905 0.5575059 #> [85] 0.4877148 0.4566996 0.6428904 0.4301137 0.5926693 0.3151017 0.5229379 #> [92] 0.4373451 0.2960536 0.5468342 0.8021488 0.5878471 0.7453391 0.4507426 #> [99] 0.7114041 0.4081892 #> #> $converge #> [1] -223.4938 -223.2694 -223.2149 -223.2384 #> #> $estim0 #> p0 mu0 p1 mu1 phi #> 1 1 5.8902 0 NaN 0.05 #> #> $estim1 #> p0 mu0 p1 mu1 phi #> 1 0.4999 5.114535 0.5001 7.155351 0.05 #> #> $loglik0 #> [1] -224.6152 #> #> $loglik1 #> [1] -223.2384 #> #> $lrts #> [1] 2.753622 #>