bb.zihmle: Maximum likelihood estimate for zero-inflated or hurdle beta...

Description Usage Arguments Details Value Reference Examples

View source: R/bb.zihmle.r

Description

Calculate maximum likelihood estimate and the corresponding log likelihood value for zero-inflated or hurdle beta binomial, beta negative binomial, negative binomial and Poisson distributions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
bb.zihmle(x, n, alpha1, alpha2, type = c("zi", "h"), lowerbound = 0.01,
  upperbound = 10000)

bnb.zihmle(x, r, alpha1, alpha2, type = c("zi", "h"),
  lowerbound = 0.01, upperbound = 10000)

nb.zihmle(x, r, p, type = c("zi", "h"), lowerbound = 0.01,
  upperbound = 10000)

poisson.zihmle(x, type = c("zi", "h"), lowerbound = 0.01,
  upperbound = 10000)

Arguments

x

A vector of count data. Should be non-negative integers.

n

An initial value of the number of trials. Must be a positive number, but not required to be an integer.

alpha1

An initial value for the first shape parameter of beta distribution. Should be a positive number.

alpha2

An initial value for the second shape parameter of beta distribution. Should be a positive number.

type

The type of distribution used to calculate the sample estimate, where 'zi' and 'h' stand for zero-inflated and hurdle distributions respectively.

lowerbound

A lower searching bound used in the optimization of likelihood function. Should be a small positive number. The default is 1e-2.

upperbound

An upper searching bound used in the optimization of likelihood function. Should be a large positive number. The default is 1e4.

r

An initial value of the number of success before which m failures are observed, where m is the element of x. Must be a positive number, but not required to be an integer.

p

An initial value of the probability of success, should be a positive value within (0,1).

Details

By setting type='zi', bb.zihmle, bnb.zihmle, nb.zihmle and poisson.zihmle calculate the maximum likelihood estimate of zero-inflated beta binomial, beta negative binomial, negative binomial and Poisson distributions, respectively.

By setting type='h', bb.zihmle, bnb.zihmle, nb.zihmle and poisson.zihmle calculate the maximum likelihood estimate of hurdle beta binomial, beta negative binomial, negative binomial and Poisson distributions, respectively.

Please NOTE that the arguments in the four functions are NOT CHECKED AT ALL! The user must be aware of their inputs to avoid getting suspicious results.

For zero-inflated models, zeros occurred by either sampling process or specific structure of data with the structural parameter 0<φ<1. The density function for a zero-inflated model is

P_{zi}(X=k)=φ 1_{k=0}+(1-φ)P(X=k),

where P(X=k) is the probability under standard distributions.

Aldirawi et al. (2019) proposed an estimating procedure for zero-inflated models by optimizing over a reparametrization of the likelihood function where φ and the rest unknown parameters are separable. When X comes from a zero-inflated distribution, the maximum likelihood estimate of parameters except for φ are obtained by minimizing the truncated version of negative log likelihood function. However, in the zero-deflated case, φ=0 and the sample estimate of other parameters are identical to those for its corresponding standard distributions. Meanwhile, an warning message is shown on the screen such that 'cannot obtain mle with the current model type, the output estimate is derived from general ... distribution'.

For hurdle models, all zeros occurred purely by the structure of data with the structural parameter 0<φ<1. The density function for a hurdle model is

P_{h}(X=k)=φ 1_{k=0}+(1-φ)P_{tr}(X=k),

where P_{tr}(X=k) is the truncated probability under standard distributions, where P_{tr}(X=0)=0 and P_{tr}(X=k)=P(X=k)/(1-P(X=0)). Since φ and other unknown parameters are separable in the joint likelihood function, φ can be estimated by a value with respect to the number of positive samples. The sample estimate of other parameters can be obtained by the same procedure for zero-inflated model.

A warning message may also occur when the algorithm of optim does not converge and the resulting estimates are not valid. In this case, the results from the corresponding general distribution are output instead.

Value

A row vector containing the maximum likelihood estimate of unknown parameters and the corresponding value of log likelihood.

With bb.zihmle, the following values are returned:

With bnb.zihmle, the following values are returned:

With nb.zihmle, the following values are returned:

With poisson.zihmle, the following values are returned:

Reference

Examples

1
2
3
4
5
6
7
8
9
t1=sample.h(N=2000,phi=0.2,distri='Poisson',lambda=5)  ##hurdle poisson random values
t2=sample.h(N=2000,phi=0.2,distri='nb',r=10,p=0.6)   ##hurdle negative binomial
t3=sample.zi(N=2000,phi=0.2,distri='bb',alpha1=8,alpha2=9,n=10)   ##zero-inflated beta binomial
##zero-inflated beta negative binomial.
t4=sample.zi(N=2000,phi=0.2,distri='bnb',r=10,alpha1=8,alpha2=9)
bb.zihmle(t3,3,1,1,type='h')
bnb.zihmle(t4, 3.3, 1, 1,type='h')
nb.zihmle(t2, 7, 0.5,type='zi')
poisson.zihmle(t1,type='zi')

Example output

        n   alpha1  alpha2 phi   loglik
[1,] 9.99 1.186407 2.04323   0 10381.39
Warning message:
In bb.zihmle(t3, 3, 1, 1, type = "h") :
  cannot obtain mle with the current model type, the output estimate is derived from general beta binomial distribution.
         r alpha1 alpha2    phi    loglik
[1,] 10000  10000   0.01 0.2065 413077713
            r         p       phi    loglik
[1,] 9.967746 0.5962024 0.1923397 -5116.386
       lambda       phi    loglik
[1,] 5.005268 0.2006423 -4466.521

iZID documentation built on Nov. 6, 2019, 5:08 p.m.