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)
y | observations:
numeric vector of length |
---|---|
z | class labels:
integer vector of length |
phi | dispersion parameters:
numeric vector of length |
pi | zero-inflation parameter(s):
numeric vector of length |
gamma | offset:
numeric vector of length |
it.em | (maximum) number of iterations in the |
epsilon | convergence criterion for the |
This function returns the parameter estimates, the posterior probabilities, and the likelihood.
# 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.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 #> [7] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 #> [13] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 #> [19] 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 #> [25] 0.43665607 0.03043302 0.14868213 0.35317531 0.02003036 0.75674036 #> [31] 0.38063892 0.10073425 0.27497526 0.43267282 0.04850432 0.42015055 #> [37] 0.61764568 0.40314244 0.87202413 0.19534947 0.29673266 0.23869088 #> [43] 0.73407620 0.17859569 0.06590985 0.62023517 0.41848091 0.25466039 #> [49] 0.47999959 0.82143396 0.89535080 0.52023866 0.18343216 0.99853364 #> [55] 0.04454932 0.68573570 0.24548020 0.97106744 0.12578540 0.48011862 #> [61] 0.47654609 0.47996559 0.45334529 0.75318260 0.38267997 0.88256314 #> [67] 0.95260794 0.78664225 0.72364420 0.41868837 0.45716366 0.46560896 #> [73] 0.32579468 0.82606319 0.16438526 0.62792393 0.59548199 0.99892416 #> [79] 0.92030215 0.65245365 0.80167813 0.16366540 0.08844169 0.17645589 #> [85] 0.47255144 0.41338056 0.66265403 0.64906224 0.37004820 0.69250615 #> [91] 0.13531568 0.47605617 0.05585104 0.45038005 0.91365591 0.46433810 #> [97] 0.41076437 0.47863099 0.47360349 0.95301474 #> #> $converge #> [1] -243.8384 -240.9841 -239.8933 -239.7681 -239.8118 #> #> $estim0 #> p0 mu0 p1 mu1 phi pi #> 1 1 5.99665 0 NaN 0.05 0.2 #> #> $estim1 #> p0 mu0 p1 mu1 phi pi #> 1 0.5188485 4.329779 0.4811515 8.888117 0.05 0.2 #> #> $loglik0 #> [1] -247.7172 #> #> $loglik1 #> [1] -239.8118 #> #> $lrts #> [1] 15.81082 #>