enhance.grid {hero} | R Documentation |
Enhance penalty value using grid search
Description
enhance.grid
enhances the sandwich smoother by
choosing a optimal penalty value to lower the GCV
statistic. A grid search algorithm is utilized based on
the each row of par
. The penalty values (assumed
to be on the log scale) are passed to the
loglambda2gcv
function. If prepare
is TRUE
, then obj
is returned with the
penalty values that minimize the GCV statistic during the
grid search. Otherwise, the complete results of the grid
search are returned.
Usage
enhance.grid(obj, par, prepare = TRUE, loggcv = FALSE, ..., cl = NULL)
Arguments
obj |
A |
par |
A matrix-like object (i.e.,
|
prepare |
A logical value. The default is |
loggcv |
A logical value indicating whether the log
of the GCV statistic should be used. Useful for very large
data sets. Default is |
... |
Additional arguments to pass to to the
|
cl |
A cluster object created by |
Value
By default, a prepared_*
object with the
optimal loglambda
values that minimize the GCV,
along with an additional component, results
,
that contains the optimization results. Otherwise, the
complete results of the grid search.
Author(s)
Joshua French
Examples
# create b-splines
b1 = bspline(nbasis = 10)
b2 = bspline(nbasis = 12)
# observed data locations
x1 = seq(0, 1, len = 60)
x2 = seq(0, 1, len = 80)
# construct "true" data
mu = matrix(0, nrow = 60, ncol = 80)
for(i in seq_len(60)) {
for(j in seq_len(80)) {
mu[i, j] = sin(2*pi*(x1[i]-.5)^3)*cos(4*pi*x2[j])
}
}
# construct noisy data
data = mu + rnorm(60 * 80)
obj = prepare(data, list(x1, x2), list(b1, b2))
enhance.grid(obj, prepare = FALSE)