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 parameter: positive numeric, 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.4150446 0.5524913 0.5605333 0.1444674 #> [29] 0.2468164 0.8879462 0.7715424 0.4638721 0.5394937 0.6118240 0.8842070 #> [36] 0.2308421 0.7649045 0.9595179 0.5479706 0.5386419 0.3064207 0.5862619 #> [43] 0.7669304 0.4868959 0.1143716 0.6467019 0.4485779 0.2625788 0.4156886 #> [50] 0.5677363 0.7110190 0.9512827 0.9473205 0.4178154 0.5556500 0.8346929 #> [57] 0.8698037 0.9311095 0.6301602 0.6919283 0.8155226 0.5834116 0.3147648 #> [64] 0.9829771 0.7037673 0.5774465 0.9693131 0.7888076 0.5808284 0.4885451 #> [71] 0.1396279 0.8401526 0.5625851 0.5700984 0.7687228 0.6534592 0.6963373 #> [78] 0.8878865 0.8307727 0.3619637 0.7980781 0.6154694 0.5519678 0.4851516 #> [85] 0.4189017 0.6605046 0.7904554 0.5205735 0.3835933 0.9568793 0.5807463 #> [92] 0.5031065 0.7862136 0.7009499 0.7517883 0.8671415 0.7728685 0.9926163 #> [99] 0.7278698 0.7461392 #> #> $converge #> [1] -230.3358 -228.9130 -228.3897 -228.3453 -228.4102 #> #> $estim0 #> p0 mu0 p1 mu1 phi #> 1 1 5.805181 0 NaN 0.05 #> #> $estim1 #> p0 mu0 p1 mu1 phi #> 1 0.4028793 4.384323 0.5971207 7.515264 0.05 #> #> $loglik0 #> [1] -233.1072 #> #> $loglik1 #> [1] -228.4102 #> #> $lrts #> [1] 9.393987 #>