kern.den.circ: Kernel density derivative estimate for circular data

View source: R/kern.den.circ.R

kern.den.circR Documentation

Kernel density derivative estimate for circular data

Description

This function computes the kernel density derivative estimate with the given kernel and bandwidth for circular data.

Usage

kern.den.circ(x,z=NULL,bw="AA",deriv.order=0,kernel="vonmises",na.rm = FALSE,
              from = circular(0), to = circular(2 * pi),n = 512,control.circular=list())

Arguments

x

Data from which the estimate is to be computed. The object is coerced to class circular.

z

Points where the density derivative is estimated. If NULL equally spaced points are used according to the parameters from, to and n.

bw

Smoothing parameter to be used. bw can also be a character string giving a rule to choose the bandwidth. See bw.AA, bw.pi, bw.rt, bw.CV, and bw.boot. The default, 'AA', is the 2-stage solve-the-equation plug-in smoothing selector.

deriv.order

Derivative order. Default deriv.order=0 (density estimation).

kernel

a character string giving the smoothing kernel to be used. This must be one of "vonmises" or "wrappednormal".

na.rm

logical; if TRUE, missing values are removed from x. If FALSE any missing values cause an error.

from, to

the left and right-most points of the grid at which the density is to be estimated. The objects are coerced to class circular.

n

the number of equally spaced points at which the density is to be estimated.

control.circular

the attribute of the resulting objects (x component).

Value

An object with class density.circular whose underlying structure is a list containing the following components.

data

original dataset.

x

the n coordinates of the points where the density is estimated. It is a circular objects with coordinate system setting using control.circular.

y

the estimated density values.

bw

the smoothing parameter used.

N

the sample size after elimination of missing values.

call

the call which produced the result.

data.name

the deparsed name of the x argument.

has.na

logical, for compatibility (always FALSE).

Author(s)

Jose Ameijeiras-Alonso.

References

Ameijeiras-Alonso, J. (2022) A reliable data-based smoothing parameter selection method for circular kernel estimation.

Di Marzio, M., Panzera, A., & Taylor, C. C. (2011). Kernel density estimation on the torus. Journal of Statistical Planning and Inference, 141(6), 2156–2173.

Oliveira, M., Crujeiras R.M. and Rodr?guez-Casal, A. (2014) NPCirc: an R package for nonparametric circular methods. Journal of Statistical Software, 61(9), 1–26. https://www.jstatsoft.org/v61/i09/

See Also

bw.AA, plot.density.circular, lines.density.circular, bw.pi, bw.rt, bw.CV, bw.boot

Examples

set.seed(2022)
n <- 50
x <- rcircmix(n, model=13)
# Using the smoothing parameter by default,
# i.e., 2-stage solve-the-equation plug-in rule
est1 <- kern.den.circ(x,deriv.order=1)
# Selecting the smoothing parameter: 2-stage direct plug-in rule
est2 <- kern.den.circ(x, bw="dpi", deriv.order=1)
# Circular plot
plot(est1, plot.type="circle", points.plot=TRUE, shrink=1.4,
      main="Circular plot",ylab="Density derivative circular")
lines(est2, plot.type="circle", shrink=1.4 ,col=2)
# Linear plot
plot(est1, plot.type="line", main="Linear plot",ylab="Density derivative circular")
lines(est2, plot.type="line", col=2)

NPCirc documentation built on Nov. 10, 2022, 5:48 p.m.