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

fit.zinb(y, z, phi, pi, 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 parameter: positive numeric, or NULL

pi

zero-inflation parameter: numeric between 0 and 1, 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) y[sample(1:n,size=0.2*n)] <- 0 z[(n/4):n] <- NA # model fitting fit.zinb(y,z,phi=0.05,pi=0.2,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.4745088 0.3849719 0.2367033 0.2259922 #> [29] 0.3954310 0.4663193 0.5196231 0.7864903 0.4125233 0.5215445 0.5161391 #> [36] 0.2317268 0.1355782 0.1971069 0.6017222 0.8650338 0.3029398 0.5219294 #> [43] 0.6826137 0.5232789 0.3564425 0.2770948 0.6576865 0.4062710 0.5118061 #> [50] 0.5164786 0.6034428 0.8380046 0.8808029 0.2637538 0.4412035 0.5543150 #> [57] 0.5210616 0.3508070 0.3195567 0.6106415 0.7545084 0.8406757 0.7170549 #> [64] 0.5213914 0.9140256 0.5212828 0.5045097 0.4419191 0.8294370 0.7471768 #> [71] 0.4575041 0.6077860 0.8778039 0.5828577 0.6665075 0.4413399 0.3870283 #> [78] 0.4969614 0.6469323 0.6350311 0.5074297 0.6886089 0.5169919 0.3135620 #> [85] 0.4943940 0.8522521 0.8063031 0.4026432 0.7456598 0.4928697 0.4600804 #> [92] 0.4748252 0.4423020 0.4887393 0.7797694 0.9846115 0.1286571 0.5026099 #> [99] 0.4730457 0.9090177 #> #> $converge #> [1] -229.5492 -228.7537 -228.8761 #> #> $estim0 #> p0 mu0 p1 mu1 phi pi #> 1 1 5.727673 0 NaN 0.05 0.2 #> #> $estim1 #> p0 mu0 p1 mu1 phi pi #> 1 0.4779014 4.593986 0.5220986 7.451096 0.05 0.2 #> #> $loglik0 #> [1] -230.9897 #> #> $loglik1 #> [1] -228.8761 #> #> $lrts #> [1] 4.227145 #>