
createControl
creates a Cyclops control object for use with fitCyclopsModel
.
createControl(
maxIterations = 1000,
tolerance = 1e-06,
convergenceType = "gradient",
cvType = "auto",
fold = 10,
lowerLimit = 0.01,
upperLimit = 20,
gridSteps = 10,
cvRepetitions = 1,
minCVData = 100,
noiseLevel = "silent",
threads = 1,
seed = NULL,
resetCoefficients = FALSE,
startingVariance = -1,
useKKTSwindle = FALSE,
tuneSwindle = 10,
selectorType = "auto",
initialBound = 2,
maxBoundCount = 5,
algorithm = "ccd",
doItAll = TRUE,
syncCV = FALSE
)
A Cyclops control object of class inheriting from "cyclopsControl"
for use with fitCyclopsModel
.
Integer: maximum iterations of Cyclops to attempt before returning a failed-to-converge error
Numeric: maximum relative change in convergence criterion from successive iterations to achieve convergence
String: name of convergence criterion to employ (described in more detail below)
String: name of cross validation search.
Option "auto"
selects an auto-search following BBR.
Option "grid"
selects a grid-search cross validation
Numeric: Number of random folds to employ in cross validation
Numeric: Lower prior variance limit for grid-search
Numeric: Upper prior variance limit for grid-search
Numeric: Number of steps in grid-search
Numeric: Number of repetitions of X-fold cross validation
Numeric: Minimum number of data for cross validation
String: level of Cyclops screen output ("silent"
, "quiet"
, "noisy"
)
Numeric: Specify number of CPU threads to employ in cross-validation; default = 1 (auto = -1)
Numeric: Specify random number generator seed. A null value sets seed via Sys.time
.
Logical: Reset all coefficients to 0 between model fits under cross-validation
Numeric: Starting variance for auto-search cross-validation; default = -1 (use estimate based on data)
Logical: Use the Karush-Kuhn-Tucker conditions to limit search
Numeric: Size multiplier for active set
String: name of exchangeable sampling unit.
Option "byPid"
selects entire strata.
Option "byRow"
selects single rows.
If set to "auto"
, "byRow"
will be used for all models except conditional models where
the average number of rows per stratum is smaller than the number of strata.
Numeric: Starting trust-region size
Numeric: Maximum number of tries to decrease initial trust-region size
String: name of fitting algorithm to employ; default is ccd
Currently unused
Currently unused
Todo: Describe convegence types
#Generate some simulated data:
sim <- simulateCyclopsData(nstrata = 1, nrows = 1000, ncovars = 2, eCovarsPerRow = 0.5,
model = "poisson")
cyclopsData <- convertToCyclopsData(sim$outcomes, sim$covariates, modelType = "pr",
addIntercept = TRUE)
#Define the prior and control objects to use cross-validation for finding the
#optimal hyperparameter:
prior <- createPrior("laplace", exclude = 0, useCrossValidation = TRUE)
control <- createControl(cvType = "auto", noiseLevel = "quiet")
#Fit the model
fit <- fitCyclopsModel(cyclopsData,prior = prior, control = control)
#Find out what the optimal hyperparameter was:
getHyperParameter(fit)
#Extract the current log-likelihood, and coefficients
logLik(fit)
coef(fit)
#We can only retrieve the confidence interval for unregularized coefficients:
confint(fit, c(0))
Run the code above in your browser using DataLab