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 prepared_* object from a prepare function.

par

A matrix-like object (i.e., !is.null(dim(par)))). Each row contains a set of parameter values for which the GCV statistic should be computed. The number of columns of par should match the dimensionality of obj, i.e, should equal length(obj)$n. If missing, the default choices are a row of -20s, a row of 0s, and a row of 20s.

prepare

A logical value. The default is TRUE, indicating that a prepared_data object should be returned. If FALSE, then the results of the call to the optimx function is returned.

loggcv

A logical value indicating whether the log of the GCV statistic should be used. Useful for very large data sets. Default is TRUE.

...

Additional arguments to pass to to the loglambda2gcv function.

cl

A cluster object created by makeCluster, or an integer to indicate number of child-processes (integer values are ignored on Windows) for parallel evaluations (see Details on performance). It can also be "future" to use a future backend (see Details), NULL (default) refers to sequential evaluation.

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)

[Package hero version 0.6 Index]