Description Usage Arguments Details Value See Also Examples
1d local density estimate.
1 2 |
x |
a numeric vector of x positions |
weight |
|
nn |
span, or nearest neighbour fraction, the proportion of the total observations used in predict |
h |
constant bandwidth. Use if you want a constant bandwith, rather
than a bandwidth that varies. If both |
kernel |
Weight function, default is tricubic. Other choices are
|
degree |
degree of polynomial used for smoothing |
bounded |
if |
scale |
if |
na.rm |
If |
This convenience function wraps up the important
arguments of locfit
and
lp
, and hopefully provides enough
documentation so that you don't need to refer to the
original documentation and book.
Adaptive penalties are not available in this convenience function because they typically require a two-stage fit, where the first fit is used to estimate the local variance.
If you recieve an error newsplit: out of vertex
space
, that indicates that your bandwidth is too small.
a function of a single that returns the density at that location
"Local Regression and Likelihood," C. Loader. Springer, 1999.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | data(baseball, package = "plyr")
dens <- local_density_1d(baseball$g)
plot(dens)
# nn is like span in loess - it's a proportion
plot(local_density_1d(baseball$g, nn = 0.1))
plot(local_density_1d(baseball$g, nn = 0.2))
plot(local_density_1d(baseball$g, nn = 0.5))
plot(local_density_1d(baseball$g, nn = 1))
# when bounded = TRUE assumes that there are no possible values outside
# of the data range
plot(local_density_1d(baseball$g, nn = 0.2))
plot(local_density_1d(baseball$g, nn = 0.2, bounded = TRUE))
# When scale = FALSE, the bandwidth is specified in terms of the
# range of the original data. When scale = TRUE, the data has been
# scaled to have sd 1
plot(local_density_1d(baseball$g, h = 0.5, nn = 0, scale = TRUE))
plot(local_density_1d(baseball$g, h = 0.5, nn = 0, scale = FALSE))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.