opt_lin_bw | R Documentation |
This function wraps stats::bw.ucv()
and stats::bw.nrd()
of the 'stats'
package, simplifying their inputs. For more control,
these 'stats' functions could be used directly.
opt_lin_bw(x, method = c("cv", "nrd"))
x |
numeric vector of linear measurements. |
method |
character string describing the method used to find
the optimal bandwidth. Either |
The normal reference distribution (nrd
) method involves
matching a normal distribution to the data using an empirical measure of spread.
The optimal bandwidth for that normal distribution can then be exactly calculated
by minimizing the mean integrated square error.
method="cv"
finds the optimal bandwidth using unbiased cross-validation.
A numeric value, the optimized bandwidth.
stats::bw.ucv()
,
stats::bw.nrd()
opt_lin_bw()
.
require(graphics) set.seed(123) n <- 1000 x <- rweibull(n, shape = 10) bw1 <- opt_lin_bw(x = x, method="nrd") bw2 <- opt_lin_bw(x = x, method="cv") dens1 <- fit_steplength(x = x, parametric = FALSE, bandwidth = bw1) dens2 <- fit_steplength(x = x, parametric = FALSE, bandwidth = bw2) true_dens <- dweibull(seq(0,max(x),length.out = 200), shape = 10) plot(seq(0,max(x),length.out = 200), true_dens, type = "l") lines(dens1$x, dens1$y, col = "red") lines(dens2$x, dens2$y, col = "green")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.