Description Usage Arguments Details Value Examples
The function finds a data-driven optimal bandwidth using cross-validation. The output is an approximation to \hat{h}_{CV}, which is the minimum of the function
CV(h) = \frac{1}{n}∑_{i=1}^{n} (Y_i-\hat{m}^{(-i)}_h(x_i))^2
where \hat{m}^{(-i)}_h denotes the leave-one-out estimator.
1 |
data |
the data used to fit the estimator, a dataframe with columns |
estimator |
the estimator ( |
hrange |
a vector of length 2 specifying the range of h-values to try |
num_bws |
number of different h-values to try in the range (default 100) |
plot |
if set to |
... |
additional arguments to pass to the estimator (e.g. |
The function is minimized approximately via a grid search.
The user specifies an interval over which to search for h.
The function then constructs a sequence of evenly-spaced trial bandwidths in that interval, of length num_bws
, and computes CV(h) for each.
The best of these trial bandwidths is reported.
By default, the function also produces a plot of the function CV(h). This enables the user to check that a suitable interval has been specified. The interval should be wide enough that it is clear that the identified point is a minimum. However, if it is too wide then the discretization error from the grid search may be substantial.
A list with 4 components:
hcv |
the identified optimal bandwidth |
mincv |
the minimal value of CV(h) |
h |
the vector of bandwidths that have been tried |
cvs |
the values of CV(h) for the trial bandwidths |
1 2 3 4 5 6 7 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.