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"
)

Arguments

maxIterations

Integer: maximum iterations of Cyclops to attempt before returning a failed-to-converge error

tolerance

Numeric: maximum relative change in convergence criterion from successive iterations to achieve convergence

convergenceType

String: name of convergence criterion to employ (described in more detail below)

cvType

String: name of cross validation search. Option "auto" selects an auto-search following BBR. Option "grid" selects a grid-search cross validation

fold

Numeric: Number of random folds to employ in cross validation

lowerLimit

Numeric: Lower prior variance limit for grid-search

upperLimit

Numeric: Upper prior variance limit for grid-search

gridSteps

Numeric: Number of steps in grid-search

cvRepetitions

Numeric: Number of repetitions of X-fold cross validation

minCVData

Numeric: Minimum number of data for cross validation

noiseLevel

String: level of Cyclops screen output ("silent", "quiet", "noisy")

threads

Numeric: Specify number of CPU threads to employ in cross-validation; default = 1 (auto = -1)

seed

Numeric: Specify random number generator seed. A null value sets seed via Sys.time.

resetCoefficients

Logical: Reset all coefficients to 0 between model fits under cross-validation

startingVariance

Numeric: Starting variance for auto-search cross-validation; default = -1 (use estimate based on data)

useKKTSwindle

Logical: Use the Karush-Kuhn-Tucker conditions to limit search

tuneSwindle

Numeric: Size multiplier for active set

selectorType

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.

initialBound

Numeric: Starting trust-region size

maxBoundCount

Numeric: Maximum number of tries to decrease initial trust-region size

algorithm

String: name of fitting algorithm to employ; default is `ccd`

Todo: Describe convegence types

Value

A Cyclops control object of class inheriting from "cyclopsControl" for use with fitCyclopsModel.

Examples

#Generate some simulated data: sim <- simulateCyclopsData(nstrata = 1, nrows = 1000, ncovars = 2, eCovarsPerRow = 0.5, model = "poisson")
#> Sparseness = 75.2 %
cyclopsData <- convertToCyclopsData(sim$outcomes, sim$covariates, modelType = "pr", addIntercept = TRUE)
#> Sorting covariates by covariateId and rowId
#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)
#> Using cross-validation selector type byRow #> Performing 10-fold cross-validation [seed = 1604638976] with data partitions of sizes 100 100 100 100 100 100 100 100 100 100 #> Using 1 thread(s) #> Starting var = 0.248 (default) #> Running at Laplace(2.83981) None Grid-point #1 at 0.248 Fold #1 Rep #1 pred log like = 380.425 #> Running at Laplace(2.83981) None Grid-point #1 at 0.248 Fold #2 Rep #1 pred log like = 443.495 #> Running at Laplace(2.83981) None Grid-point #1 at 0.248 Fold #3 Rep #1 pred log like = 532.939 #> Running at Laplace(2.83981) None Grid-point #1 at 0.248 Fold #4 Rep #1 pred log like = 539.865 #> Running at Laplace(2.83981) None Grid-point #1 at 0.248 Fold #5 Rep #1 pred log like = 614.918 #> Running at Laplace(2.83981) None Grid-point #1 at 0.248 Fold #6 Rep #1 pred log like = 445.159 #> Running at Laplace(2.83981) None Grid-point #1 at 0.248 Fold #7 Rep #1 pred log like = 464.306 #> Running at Laplace(2.83981) None Grid-point #1 at 0.248 Fold #8 Rep #1 pred log like = 432.631 #> Running at Laplace(2.83981) None Grid-point #1 at 0.248 Fold #9 Rep #1 pred log like = 503.361 #> Running at Laplace(2.83981) None Grid-point #1 at 0.248 Fold #10 Rep #1 pred log like = 366.59 #> AvgPred = 472.369 with stdev = 72.3644 #> Completed at 0.248 #> Next point at 2.48 with value 0 and continue = 1 #> search[ 0.248 ] = 472.369(72.3644) #> #> Running at Laplace(0.898027) None Grid-point #2 at 2.48 Fold #1 Rep #1 pred log like = 380.438 #> Running at Laplace(0.898027) None Grid-point #2 at 2.48 Fold #2 Rep #1 pred log like = 443.499 #> Running at Laplace(0.898027) None Grid-point #2 at 2.48 Fold #3 Rep #1 pred log like = 532.897 #> Running at Laplace(0.898027) None Grid-point #2 at 2.48 Fold #4 Rep #1 pred log like = 539.811 #> Running at Laplace(0.898027) None Grid-point #2 at 2.48 Fold #5 Rep #1 pred log like = 614.929 #> Running at Laplace(0.898027) None Grid-point #2 at 2.48 Fold #6 Rep #1 pred log like = 445.128 #> Running at Laplace(0.898027) None Grid-point #2 at 2.48 Fold #7 Rep #1 pred log like = 464.308 #> Running at Laplace(0.898027) None Grid-point #2 at 2.48 Fold #8 Rep #1 pred log like = 432.602 #> Running at Laplace(0.898027) None Grid-point #2 at 2.48 Fold #9 Rep #1 pred log like = 503.355 #> Running at Laplace(0.898027) None Grid-point #2 at 2.48 Fold #10 Rep #1 pred log like = 366.587 #> AvgPred = 472.356 with stdev = 72.3594 #> Completed at 2.48 #> Next point at 0.0248 with value 0 and continue = 1 #> search[ 0.248 ] = 472.369(72.3644) #> search[ 2.48 ] = 472.356(72.3594) #> #> Running at Laplace(8.98027) None Grid-point #3 at 0.0248 Fold #1 Rep #1 pred log like = 380.307 #> Running at Laplace(8.98027) None Grid-point #3 at 0.0248 Fold #2 Rep #1 pred log like = 443.48 #> Running at Laplace(8.98027) None Grid-point #3 at 0.0248 Fold #3 Rep #1 pred log like = 533.011 #> Running at Laplace(8.98027) None Grid-point #3 at 0.0248 Fold #4 Rep #1 pred log like = 540.025 #> Running at Laplace(8.98027) None Grid-point #3 at 0.0248 Fold #5 Rep #1 pred log like = 614.806 #> Running at Laplace(8.98027) None Grid-point #3 at 0.0248 Fold #6 Rep #1 pred log like = 445.251 #> Running at Laplace(8.98027) None Grid-point #3 at 0.0248 Fold #7 Rep #1 pred log like = 464.311 #> Running at Laplace(8.98027) None Grid-point #3 at 0.0248 Fold #8 Rep #1 pred log like = 432.745 #> Running at Laplace(8.98027) None Grid-point #3 at 0.0248 Fold #9 Rep #1 pred log like = 503.375 #> Running at Laplace(8.98027) None Grid-point #3 at 0.0248 Fold #10 Rep #1 pred log like = 366.597 #> AvgPred = 472.391 with stdev = 72.3688 #> Completed at 0.0248 #> Next point at 0.00248 with value 0 and continue = 1 #> search[ 0.0248 ] = 472.391(72.3688) #> search[ 0.248 ] = 472.369(72.3644) #> search[ 2.48 ] = 472.356(72.3594) #> #> Running at Laplace(28.3981) None Grid-point #4 at 0.00248 Fold #1 Rep #1 pred log like = 379.821 #> Running at Laplace(28.3981) None Grid-point #4 at 0.00248 Fold #2 Rep #1 pred log like = 443.423 #> Running at Laplace(28.3981) None Grid-point #4 at 0.00248 Fold #3 Rep #1 pred log like = 533.208 #> Running at Laplace(28.3981) None Grid-point #4 at 0.00248 Fold #4 Rep #1 pred log like = 540.45 #> Running at Laplace(28.3981) None Grid-point #4 at 0.00248 Fold #5 Rep #1 pred log like = 614.424 #> Running at Laplace(28.3981) None Grid-point #4 at 0.00248 Fold #6 Rep #1 pred log like = 445.486 #> Running at Laplace(28.3981) None Grid-point #4 at 0.00248 Fold #7 Rep #1 pred log like = 464.303 #> Running at Laplace(28.3981) None Grid-point #4 at 0.00248 Fold #8 Rep #1 pred log like = 433.094 #> Running at Laplace(28.3981) None Grid-point #4 at 0.00248 Fold #9 Rep #1 pred log like = 503.29 #> Running at Laplace(28.3981) None Grid-point #4 at 0.00248 Fold #10 Rep #1 pred log like = 366.502 #> AvgPred = 472.4 with stdev = 72.397 #> Completed at 0.00248 #> Next point at 0.000248 with value 0 and continue = 1 #> search[ 0.00248 ] = 472.4(72.397) #> search[ 0.0248 ] = 472.391(72.3688) #> search[ 0.248 ] = 472.369(72.3644) #> search[ 2.48 ] = 472.356(72.3594) #> #> Running at Laplace(89.8027) None Grid-point #5 at 0.000248 Fold #1 Rep #1 pred log like = 379.632 #> Running at Laplace(89.8027) None Grid-point #5 at 0.000248 Fold #2 Rep #1 pred log like = 443.287 #> Running at Laplace(89.8027) None Grid-point #5 at 0.000248 Fold #3 Rep #1 pred log like = 533.459 #> Running at Laplace(89.8027) None Grid-point #5 at 0.000248 Fold #4 Rep #1 pred log like = 541.143 #> Running at Laplace(89.8027) None Grid-point #5 at 0.000248 Fold #5 Rep #1 pred log like = 614.167 #> Running at Laplace(89.8027) None Grid-point #5 at 0.000248 Fold #6 Rep #1 pred log like = 445.322 #> Running at Laplace(89.8027) None Grid-point #5 at 0.000248 Fold #7 Rep #1 pred log like = 464.2 #> Running at Laplace(89.8027) None Grid-point #5 at 0.000248 Fold #8 Rep #1 pred log like = 433.781 #> Running at Laplace(89.8027) None Grid-point #5 at 0.000248 Fold #9 Rep #1 pred log like = 503.079 #> Running at Laplace(89.8027) None Grid-point #5 at 0.000248 Fold #10 Rep #1 pred log like = 366.266 #> AvgPred = 472.434 with stdev = 72.4588 #> Completed at 0.000248 #> Next point at 2.48e-05 with value 0 and continue = 1 #> search[ 0.000248 ] = 472.434(72.4588) #> search[ 0.00248 ] = 472.4(72.397) #> search[ 0.0248 ] = 472.391(72.3688) #> search[ 0.248 ] = 472.369(72.3644) #> search[ 2.48 ] = 472.356(72.3594) #> #> Running at Laplace(283.981) None Grid-point #6 at 2.48e-05 Fold #1 Rep #1 pred log like = 379.632 #> Running at Laplace(283.981) None Grid-point #6 at 2.48e-05 Fold #2 Rep #1 pred log like = 443.287 #> Running at Laplace(283.981) None Grid-point #6 at 2.48e-05 Fold #3 Rep #1 pred log like = 533.459 #> Running at Laplace(283.981) None Grid-point #6 at 2.48e-05 Fold #4 Rep #1 pred log like = 541.143 #> Running at Laplace(283.981) None Grid-point #6 at 2.48e-05 Fold #5 Rep #1 pred log like = 614.167 #> Running at Laplace(283.981) None Grid-point #6 at 2.48e-05 Fold #6 Rep #1 pred log like = 445.322 #> Running at Laplace(283.981) None Grid-point #6 at 2.48e-05 Fold #7 Rep #1 pred log like = 464.2 #> Running at Laplace(283.981) None Grid-point #6 at 2.48e-05 Fold #8 Rep #1 pred log like = 433.781 #> Running at Laplace(283.981) None Grid-point #6 at 2.48e-05 Fold #9 Rep #1 pred log like = 503.079 #> Running at Laplace(283.981) None Grid-point #6 at 2.48e-05 Fold #10 Rep #1 pred log like = 366.266 #> AvgPred = 472.434 with stdev = 72.4588 #> Completed at 2.48e-05 #> Next point at 1.17698e-26 with value 472.6 and continue = 0 #> search[ 2.48e-05 ] = 472.434(72.4588) #> search[ 0.000248 ] = 472.434(72.4588) #> search[ 0.00248 ] = 472.4(72.397) #> search[ 0.0248 ] = 472.391(72.3688) #> search[ 0.248 ] = 472.369(72.3644) #> search[ 2.48 ] = 472.356(72.3594) #> #> #> Maximum predicted log likelihood (472.6) estimated at: #> 1.17698e-26 (variance) #> 1.30356e+13 (lambda) #> #> Fitting model at optimal hyperparameter #> Using prior: Laplace(1.30356e+13) None
#Find out what the optimal hyperparameter was: getHyperParameter(fit)
#> [1] 1.176981e-26
#Extract the current log-likelihood, and coefficients logLik(fit)
#> 'log Lik.' -2056.259 (df=3)
coef(fit)
#> (Intercept) 1 2 #> -3.850744 0.000000 0.000000
#We can only retrieve the confidence interval for unregularized coefficients: confint(fit, c(0))
#> Using 1 thread(s)
#> covariate 2.5 % 97.5 % evaluations #> [1,] 0 -3.877549 -3.824165 24