ktd_cv {ktweedie} | R Documentation |
Cross validation for tuning the regularization coefficient in the kernel Tweedie model
Description
ktd_cv()
performs cross-validation to determine the optimal regularization coefficient of the ktweedie
model.
Usage
ktd_cv(x, y, kern, lambda, nfolds = 5, rho = 1.5, loss = "LL", ...)
Arguments
x |
Covariate matrix. |
y |
Outcome vector (e.g. insurance cost). |
kern |
Choice of kernel. See |
lambda |
A vector of candidate regularization coefficients used in cross-validation. |
nfolds |
Number of folds in cross-validation. Default is 5. |
rho |
The power parameter of the Tweedie model. Default is 1.5 and can take any real value between 1 and 2. |
loss |
Criterion used in cross-validation. "LL" for log likelihood, "RMSE" for root mean squared error, "MAD" for mean absolute difference. Default is "LL". |
... |
Optional arguments to be passed to |
Details
ktd_cv()
is a built-in wrapper for cross-validation for the choice of regularization coefficient.
Value
A list of two items.
LL or RMSE or MAD: a vector of validation error based on the user-specified
loss
, named by the correspondinglambda
values;Best_lambda: the
lambda
value in the pair that generates the best loss;
See Also
ktd_cv2d
, ktd_estimate
, ktd_predict
Examples
# Provide a sequence of candidate values to the argument lambda.
# ktd_cv() will perform cross-validation to determine which is the best.
( cv1d <- ktd_cv(x = dat$x, y = dat$y,
kern = rbfdot(sigma = 1e-8),
lambda = 10^(-8:-1),
nfolds = 5) )