enhance | R Documentation |
enhance
enhances the sandwich smoother by choosing
the optimal penalty value that minimizes the GCV
statistic. The optimx
function
is used to do the optimization.
enhance(
obj,
par = rep(0, length(obj$n)),
lower = rep(-20, length(par)),
upper = rep(20, length(par)),
method = "L-BFGS-B",
control = list(),
prepare = TRUE,
loggcv = FALSE,
...
)
obj |
A |
par |
a vector of initial values for the parameters for which optimal values are to be found. Names on the elements of this vector are preserved and used in the results data frame. |
lower, upper |
Bounds on the variables for methods such as |
method |
The method to be used for optimization. The
default is |
control |
A list of control parameters. See ‘Details’. |
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
|
Internally, the loglambda2gcv
is used as
the objective function for the
optimx
function. Many different
optimization methods are available. The default is
L-BFGS-B
, which allows for constraints on the
parameters to optimize. Another excellent choice is the
nlminb
algorithm, which also allows for parameter
constraints.
By default, a prepared_data
object with
the optimal loglambda
values that minimize the
GCV, along with an additional component,
results
, that contains the optimization results.
Joshua French
# create b-splines
x1 = bspline(nbasis = 10)
x2 = bspline(nbasis = 12)
# observed data locations
evalarg1 = seq(0, 1, len = 60)
evalarg2 = 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*(evalarg1[i]-.5)^3)*cos(4*pi*evalarg2[j])
}
}
# construct noisy data
data = mu + rnorm(60 * 80)
obj = prepare(data, list(evalarg1, evalarg2), list(x1, x2))
enhance(obj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.