find.scheme {GRCdata} | R Documentation |
Search for the global optimal grouping scheme of grouped and/or right-censored count data
Description
Given the prior distribution (or values) of parameters, and the total/maximum number of groups (N) allowed for grouping schemes, this function finds the global optimal grouping scheme that makes the sampling process most informative.
Usage
find.scheme(N,
densityFUN, lambda.lwr, lambda.upr, p.lwr, p.upr,
probs, lambdas, ps,
is.0.isolated = TRUE, model = c("Poisson", "ZIP"),
matSc = c("A", "D", "E"), M = "auto")
Arguments
N |
(maximum) number of groups allowed for all grouping schemes. A non-integral value will be coerced to an integer. |
densityFUN , lambda.lwr , lambda.upr , p.lwr , p.upr |
prior information of parameters in a continuous form.
These parameters denote the prior probability density function (optional),
the lower bound of |
probs , lambdas , ps |
prior information of the parameters in a discrete form.
These parameters are vectors denoting the mass probabilities, the corresponding values of |
is.0.isolated |
a logical value indicating whether zero is contained and only contained in a single group. |
model |
underlying Poisson models to be used for optimal designs: |
matSc |
A character indicating types of optimality functions of the Fisher information (matrix).
It must be one from the three letters:
|
M |
a sufficiently large integer needed to facilitate the search, or a character |
Details
This function tries to find the N-group scheme maximizing Fisher information (matrix).
If model
is specified as Poisson, p.lwr
or p.upr
will be ignored.
When the prior distribution is discrete, lambdas
specify discrete values that \lambda
may take,
and probs
specify probabilities associated with p
.
In the ZIP model, lambdas
and ps
specify discrete values that \lambda
and p may take, respectively.
probs
denotes joint mass probabilities associated with (\lambda
, p). The values of
(p.lwr, p.upr) cannot be (0, 1) as the algorithm will not converge. Instead, approximate values, such as
(0.000001, 0.999999), can be used.
A sufficiently large integer M
should be provided by the user so that infinitely many grouping schemes
could be handled by the search algorithm. M
is in theory the lowest integer to be contained in the last
right-censored group of the global optimal grouping scheme. In practice, the choice of M
should be slightly higher than
its theoretical value because the search algorithem is designed in a way that it prevents any acceptance of a false optimal
solution at the cost of tolerating false rejection of the correct optimal grouping scheme. This idea is implemented by
a logical indicator succeed
in the output. Its value will be TRUE
if the real optimal grouping scheme is identified.
Otherwise, a FALSE
output means that M
is not large enough to gurantee that the grouping scheme yielded by
the search algorithm is the global optimal grouping scheme. Researchers then need to select a larger M
and repeat this
process until the logical indicator succeed
becomes TRUE
. Alternatively, users may use the "auto"
option so that
this iterative process will be automatically implemented.
Value
The returned value is a list with components.
best.scheme.compact , best.scheme.loose , best.scheme.innerCode |
the same optimal grouping scheme is printed in various forms. |
succeed |
see Details. This is a logical variable. The global optimal grouping scheme is obtained if it is |
Author(s)
Xin Guo <x.guo@polyu.edu.hk>, Qiang Fu <qiang.fu@ubc.ca>
References
Qiang Fu, Xin Guo and Kenneth C. Land. Conditionally accepted. "Optimizing Count Responses in Surveys: A Machine-Learning Approach." Sociological Methods & Research.
Examples
# Example 1 ####################################
# M=7, N=3, 0 is not required to be contained
# in a separate group of grouping schemes.
# Poisson model, lambda takes 4 and 5 and each value has a probability of 0.5.
find.scheme(probs = c(0.5, 0.5), lambdas = c(4,5),
M = 7, N = 3, is.0.isolated = FALSE, model = "Poisson")
# Example 2 ####################################
# N=3, 0 is required to be contained in a separate group of grouping schemes.
# Poisson model, lambda takes 4 and 5 and each value has a probability of 0.5.
# M is not given, so it will be selected automatically.
find.scheme(probs = c(0.5, 0.5), lambdas = c(4,5),
N = 3, is.0.isolated = TRUE, model = "Poisson")
# Example 3 ####################################
# M=7, N=3, 0 is not required to be contained in a separate group.
# ZIP model, (lambda, p) take (4, 0.3) and (5, 0.4)
# with their probabilities denoted by c(0.5, 0.5)
find.scheme(probs = c(0.5, 0.5), lambdas = c(4,5), ps = c(0.3, 0.5),
M = 7, N = 3, is.0.isolated = FALSE, model = "ZIP")
# Example 4 ####################################
# N=3, 0 is not required to be contained in a separate group.
# Poisson model, lambda takes a normal distribution truncated to [1, 10]
# M is not given, so it will be selected automatically.
find.scheme(densityFUN = function(lambda)
dnorm(lambda, mean = 3, sd = 1),
lambda.lwr = 1, lambda.upr = 10,
N = 3, is.0.isolated = FALSE, model = "Poisson")
# Example 5 ####################################
# M=7, N=3, 0 is required to be contained in a separate group.
# Poisson model, lambda takes a normal distribution truncated to [1, 10]
find.scheme(densityFUN = function(lambda)
dnorm(lambda, mean = 3, sd = 1),
lambda.lwr = 1, lambda.upr = 10,
M = 7, N = 3, is.0.isolated = TRUE, model = "Poisson")
# Example 6 ####################################
# N=3, 0 is required to be contained in a separate group.
# Poisson model, lambda takes an uniform distribution on [1, 10]
# M is not given, so it will be selected automatically.
find.scheme(densityFUN = function(lambda)
dunif(lambda, min = 1, max = 10),
lambda.lwr = 1, lambda.upr = 10,
N = 3, is.0.isolated = TRUE, model = "Poisson")
# Example 7 #################################
# M=7, N=3, 0 is required to be contained in a separate group.
# ZIP model, (lambda, p) has an uniform distribution with
# lambda on [1,10] and p on [0.1, 0.9]
find.scheme(densityFUN = function(...) 1,
lambda.lwr = 1, lambda.upr = 10, p.lwr = 0.0001, p.upr = 0.9999,
M = 7, N = 3, is.0.isolated = TRUE, model = "ZIP")
# Example 8 ####################################
# M=7, N=3, 0 is required to be contained in a separate group.
# ZIP model, (lambda, p) has a normal distribution centered
# at (5.5, 0.5) with a covariance matrix showing their correlation
# / \
# | 11/3 3 |
# | 3 11/3 |
# \ /.
# This normal distribution is also truncated to
# [1, 10] X [0.1, 0.9]
# Note: this example may take several minutes to converge,
# depending on your computer configuration.
dsty <- function(lambda, p){
vec <- c(lambda - 5.5, p - 0.5)
mat <- matrix(c(11/3,3,3,11/3), nrow = 2, ncol = 2)
pw <- -0.5 * sum(vec * solve(mat, vec))
return(exp(pw))
}
find.scheme(densityFUN = dsty,
lambda.lwr = 1, lambda.upr = 10, p.lwr = 0.1, p.upr = 0.9,
M = 7, N = 3, is.0.isolated = TRUE, model = "ZIP")