Semi-automated hyperparameter estimation
autoHyper
finds a single hyperparameter estimate using an algorithm
that evaluates results from multiple starting points (see
exploreHypers
). The algorithm verifies that the optimization
converges within the bounds of the parameter space and that the chosen
estimate (smallest negative log-likelihood) is similar to at least
one (see min_conv
argument) of the other convergent solutions.
autoHyper( data, theta_init, squashed = TRUE, zeroes = FALSE, N_star = 1, tol = c(0.05, 0.05, 0.2, 0.2, 0.025), min_conv = 1, param_limit = 100, max_pts = 20000, conf_ints = FALSE, conf_level = c("95", "80", "90", "99") )
data |
A data frame from |
theta_init |
A data frame of initial hyperparameter guesses with columns ordered as: α_1, β_1, α_2, β_2, P. |
squashed |
A scalar logical ( |
zeroes |
A scalar logical specifying if zero counts are included. |
N_star |
A positive scalar whole number value for the minimum count
size to be used for hyperparameter estimation. If zeroes are used, set
|
tol |
A numeric vector of tolerances for determining how close the
chosen estimate must be to at least |
min_conv |
A scalar positive whole number for defining the minimum
number of convergent solutions that must be close to the convergent
solution with the smallest negative log-likelihood. Must be at least one
and at most one less than the number of rows in |
param_limit |
A scalar numeric value for the largest acceptable value for the α and β estimates. Used to help protect against unreasonable/erroneous estimates. |
max_pts |
A scalar whole number for the largest number of data points allowed. Used to help prevent extremely long run times. |
conf_ints |
A scalar logical indicating if confidence intervals and standard errors should be returned. |
conf_level |
A scalar string for the confidence level used if confidence intervals are requested. |
Since this function runs multiple optimization procedures, it is
best to start with 5 or less initial starting points (rows in
theta_init
). If the function runs in a reasonable amount of time,
this number can be increased.
This function should not be used with very large data sets since
each optimization call will take a long time. squashData
can
be used first to reduce the size of the data.
It is recommended to use N_star = 1
when practical. Data
squashing (see squashData
) can be used to further reduce the
number of data points.
Asymptotic normal confidence intervals, if requested, use standard errors calculated from the observed Fisher information matrix as discussed in DuMouchel (1999).
A list containing the following elements:
method: A scalar character string for the method used to
find the hyperparameter estimate (possibilities are
“nlminb
”, “nlm
”, and
“bfgs
”).
estimates: A named numeric vector of length 5 for the hyperparameter estimate corresponding to the smallest log-likelihood.
conf_int: A data frame including the standard errors and
confidence limits. Only included if conf_ints = TRUE
.
num_close: A scalar integer for the number of other convergent solutions that were close (within tolerance) to the chosen estimate.
theta_hats: A data frame for the estimates corresponding
to the initial starting points defined by theta_init
. See
exploreHypers
.
DuMouchel W (1999). "Bayesian Data Mining in Large Frequency Tables, With an Application to the FDA Spontaneous Reporting System." The American Statistician, 53(3), 177-190.
squashData
for data preparation
Other hyperparameter estimation functions:
exploreHypers()
,
hyperEM()
#Start with 2 or more guesses theta_init <- data.frame( alpha1 = c(0.2, 0.1), beta1 = c(0.1, 0.1), alpha2 = c(2, 10), beta2 = c(4, 10), p = c(1/3, 0.2) ) data(caers) proc <- processRaw(caers) squashed <- squashData(proc, bin_size = 100, keep_pts = 100) squashed <- squashData(squashed, count = 2, bin_size = 10, keep_pts = 20) suppressWarnings( autoHyper(squashed, theta_init = theta_init) )
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.