optK function

Find the optimal number of bins

Find the optimal number of bins

This function automatically finds the optimal number of bins using dynamic programming.

optK(X, Kmethod = "cluster", maxK = 10, beta = 0.2, lambda = 0.3, R = 4, C1 = 2.5, C2 = 7.8, ...)

Arguments

  • X: Numeric vector corresponding to Y.
  • Kmethod: The way to calculate the penalty in automatic binning."cluster" or "kernel".
  • maxK: The maximum number of bins.
  • beta: Additional parameter for automatic binning. For more detailed explanation, see reference.
  • lambda: Additional parameter for automatic binning. For more detailed explanation, see reference.
  • R: Additional parameter for automatic binning. For more detailed explanation, see reference.
  • C1: Additional parameter for automatic binning. For more detailed explanation, see reference.
  • C2: Additional parameter for automatic binning. For more detailed explanation, see reference.
  • ...: Arguments to be passed to methods.

Returns

The optimal number of bins, the result of binning, and the summary of binning including the penalty values up to the maximum number of bins are returned.

Examples

data(origdata) optK(origdata$TIME)

References

Lavielle, M. and Bleakley, K. (2011). Automatic data binning for improved visual diagnosis of pharmacometric models. Journal of pharmacokinetics and pharmacodynamics, 38(6), 861-871.

  • Maintainer: Eun-Kyung Lee
  • License: MIT + file LICENSE
  • Last published: 2022-12-22

Useful links