ktd_estimate {ktweedie} | R Documentation |
Estimate kernel Tweedie model coefficients
Description
ktd_estimate()
estimates the coefficients of the kernel Tweedie model ktweedie
and the sparse kernel Tweedie model sktweedie
. The log of the expected Tweedie mean is modeled by a function in the reproducing kernel Hilbert space. The sktweedie
has an integrated feature selection component that induces sparsity by applying weights on the features and penalizing the weights.
Usage
ktd_estimate(
x,
y,
kern,
lam1,
rho = 1.5,
ftol = 1e-08,
partol = 1e-08,
abstol = 0,
maxit = 1e+06,
sparsity = FALSE,
lam2 = 0,
innerpartol = 1e-06,
innermaxit = 1e+06,
verbose = FALSE
)
Arguments
x |
Covariate matrix. |
y |
Outcome vector (e.g. insurance cost). |
kern |
Choice of kernel. See |
lam1 |
A vector of regularization coefficients. |
rho |
The power parameter of the Tweedie model. Default is 1.5 and can take any real value between 1 and 2. |
ftol |
Stopping criterion based on objective function value. Default is 1e-8. See Details. |
partol |
Stopping criterion based on the coefficient values. Default is 1e-8. See Details. |
abstol |
Stopping criterion based on absolute value of the objective function. Default is 0. |
maxit |
Maximum number of iterations. |
sparsity |
Logical If true, the |
lam2 |
Regularization coefficient for the sparsity-inducing penalty in the |
innerpartol |
Stopping criterion for the inner loops that update kernel parameters and weights based on the coefficient values. See Details. |
innermaxit |
Maximum number of iterations for the inner loops that update kernel parameters and variable weights. See Details. |
verbose |
Logical indicating whether to show details of each update. |
Details
ktd_estimate()
stops when the absolute difference between the objective function values of the last two updates is smaller than ftol
, or the sum of absolute differences between the coefficients of the last two updates is smaller than partol
, or the objective function values is below abstol
, before maxit
is reached. For the sktweedie
model, there are inner loops for the update of kernel regression coefficients and regularization weights. The innerpartol
and innermaxit
arguments are the counterparts of partol
and maxit
for the inner loops.
Value
A list of three items.
-
estimates
: a list containing the final objective function values and kernel Tweedie regression coefficients for eachlam1
. -
data
: stores the inputs, including the predictor matrix, the kernel function used in the fitting andlam1
. -
sparsity
: a logical variable indicating whether thektweedie
orsktweedie
is fitted.
See Also
ktd_cv
, ktd_cv2d
, ktd_predict
, rbfdot
Examples
###### ktweedie ######
# Provide a sequence of candidate values to the argument lam1.
# Provide a kernel object to the argument kern.
lam1.seq <- c(1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e0, 1e1)
fit.ktd <- ktd_estimate(x = dat$x, y = dat$y,
kern = rbfdot(sigma = 1e-8),
lam1 = lam1.seq)
###### sktweedie ######
# Set sparsity to TRUE and a lam2 to control the level of sparsity
# Decrease lam2 if "WARNING: All weights are zero..."
fit.sktd <- ktd_estimate(x = dat$x,
y = dat$y,
kern = rbfdot(sigma = 0.1),
lam1 = 5,
sparsity = TRUE,
lam2 = 1)
# variables with fitted weight equal to 0 are not selected