This function infers Poisson or zero-inflated Poisson (ZIP) parameters from grouped and right-censored count data, and conducts a chi-squared goodness-of-fit test. A grouped and right-censored scheme may look like
0, 1, 2--4, 5--8, 9+.
For grouped and right-censored count data collected in a survey, such as frequency of alcohol drinking, number of births or occurrence of crimes, the response category designed as the example above means never, once, 2 to 4 times, 5 to 8 times, 9 times and more. The frequency distribution from a sample corresponding to the example above may look like
3, 15, 168, 155, 15.
grcmle(counts, scheme, method = c("Poisson", "ZIP"),
do.plot = T, init.guess = NULL,
optimizing.algorithm.index = 2, lambda.extend.ratio = 3,
conf.level = 0.95)specifies the frequency distribution of the grouped and right-censored count data. For the example above, one may input
counts = c(3, 15, 168, 155, 15).
specifies the grouping scheme. It should be a vector of integers containing the starting point (or the lowest integer) of each group. For example, to input the scheme above
0, 1, 2--4, 5--8, 9+,
one may use
scheme = c(0, 1, 2, 5, 9).
a string parameter specifies which statistical model to use. Currently there are two options
"Poisson" and "ZIP". The default value is "Poisson".
It can be abbreviated.
a logical variable indicating whether or not to plot the log likelihood.
The default is T.
the initial value used for the optimization procedure of the likelihood estimation. The default value
is NULL, which instructs the function grcmle to select the initial value automatically.
defines which optimization algorithm to use. Currently the possible values are 1,2,3,4,5,6,7 and 8,
representing the following algorithms, respectively:
NLOPT_GN_DIRECT_L
NLOPT_GN_DIRECT
NLOPT_GN_DIRECT_L_RAND
NLOPT_GN_DIRECT_NOSCAL
NLOPT_GN_DIRECT_L_NOSCAL
NLOPT_GN_DIRECT_L_RAND_NOSCAL
NLOPT_GN_ORIG_DIRECT
NLOPT_GN_ORIG_DIRECT_L
For details of these algorithms, please see the manual of the R package "nloptr".
The default value is 2.
specifies the searching interval of possible \(\lambda\) as \([0, nr]\), where \(n\) is the left end (i.e., the lowest integer)
of the last right-censored group, and \(r\) is lambda.extend.ratio. By default,
we set
lambda.extend.ratio=3.
confidence level of the confidence interval(s) for the parameter(s) inferred
The returned value is a list containing
the parameter(s) inferred. For Poisson model, it is the estimate of \(\lambda\). For ZIP model, it shows a vector of length 2: the first element is the estimate of \(p\) and the second element is the estimate of \(\lambda\).
the p-value of the chi-squared test of goodness-of-fit.
the degree(s) of freedom of the chi-squared test of goodness-of-fit.
the confidence interval of \(\lambda\) obtained by normal approximation
the confidence interval of \(p\) obtained by normal approximation
the confidence level
the standard error of \(\lambda\) or the standard errors of \((p, \lambda)\), if a ZIP model is specified
Maximum likelihood estimation is used for the inference.
# NOT RUN {
grcmle(counts=c(6, 15, 168, 155, 15), scheme = c(0, 1, 2, 5, 9))
# }
# NOT RUN {
grcmle(counts=c(6, 15, 168, 155, 15), scheme = c(0, 1, 2, 5, 9), method = "ZIP")
# }
Run the code above in your browser using DataLab