ZINB_one_gamma: Zero-Inflated Negative Binomial - One Gamma Component

Description Usage Arguments Value See Also Examples

View source: R/ZINB_one_gamma.R

Description

This ZINB_one_gamma function finds hyperparameter estimates by implementing the Expectation-Maximization (EM) algorithm and zero-inflated negative binomial model with one gamma component. nlminb function is used to maximize the loglikelihood function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
ZINB_one_gamma(
  alpha,
  beta,
  omega,
  N,
  E,
  weight,
  iteration,
  Loglik = FALSE,
  zeroes = FALSE,
  N_star = 1
)

Arguments

alpha

initial shape parameter value of the gamma distribution for implementing the EM algprithm

beta

initial rate parameter value of the gamma distribution for implementing the EM algprithm

omega

initial weight for observing a true zero (according to zero-inflated poission distribution)

N

vector of Nij values

E

vector of Eij values

weight

set weight = rep(1, length(N)) if N and E are not squashed data, or input the weight vector corresponding to the squashed Nij vector.

iteration

number of EM algorithm iterations to run

Loglik

whether to return the loglikelihood of each iteration or not (TRUE or FALSE)

zeroes

A logical scalar specifying if zero counts should be included.

N_star

the minimum Nij count size to be used for hyperparameter estimation. If zeroes are included in Nij vector, please set N_star = NULL

Value

a list including the following: if Nij = 0 is included in the input dataset

if the minimum Nij count size included in the input dataset is not 0"

See Also

openEBGM, nlminb

Examples

1
2
3
4
5
Nij = rnbinom(100, size = 2, prob = 0.3)
Eij = runif(100, 0, 2)
par_estimated = ZINB_one_gamma(0.2, 0.1, 0.33, Nij, Eij, rep(1, length(Nij)), iteration = 10, Loglik = TRUE, zeros = TRUE, N_star = 1)
par_estimated$theta_EM
par_estimated$Loglik

sidiwang/hgzips documentation built on Jan. 19, 2021, 4:09 p.m.