Description Usage Arguments Value See Also Examples
View source: R/ZINB_two_gamma.R
This ZINB_two_gamma
function finds hyperparameter estimates by implementing the Expectation-Maximization (EM) algorithm and zero-inflated negative binomial model with two gamma components. nlminb
function is used to maximize the loglikelihood function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ZINB_two_gamma(
alpha1,
beta1,
alpha2,
beta2,
pi,
omega,
N,
E,
weight,
iteration,
Loglik = FALSE,
zeroes = FALSE,
N_star = 1
)
|
alpha1 |
initial shape parameter value of the first gamma distribution for implementing the EM algprithm |
beta1 |
initial rate parameter value of the first gamma distribution for implementing the EM algprithm |
alpha2 |
initial shape parameter value of the second gamma distribution for implementing the EM algprithm |
beta2 |
initial rate parameter value of the second gamma distribution for implementing the EM algprithm |
pi |
initial mixing proportion guess of the two gamma distributions |
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 |
a list of estimated parameters and their corresponding loglikelihood if Nij = 0 is included in the input dataset
theta_EM
Estimate of hyperparameters for each EM iteration
llh
logliklihood for each EM iteration (optional)
if the minimum Nij count size included in the input dataset is not 0"
theta_EM
Estimate of hyperparameters for each EM iteration
openEBGM, nlminb
1 2 3 4 | Nij = rnbinom(100, size = 2, prob = 0.3)
Eij = runif(100, 0, 2)
par_estimated = ZINB_two_gamma(0.2, 0.1, 2, 4, 0.33, 0.3, N = squashed$N, E = squashed$E, weight = squashed$weight, 10, Loglik = TRUE, zeroes = FALSE, N_star = 1)
par_estimated$theta_EM
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.