fit_angle {cylcop}R Documentation

Fit a Circular Univariate Distribution

Description

This function finds parameter estimates of the marginal circular distribution (with potentially fixed mean), or gives a kernel density estimate using a von Mises smoothing kernel.

Usage

fit_angle(
  theta,
  parametric = c("vonmises", "wrappedcauchy", "vonmisesmix", FALSE),
  bandwidth = NULL,
  mu = NULL,
  ncomp = 2
)

Arguments

theta

numeric vector of angles in [-\pi, \pi).

parametric

either a character string describing what distribution should be fitted ("vonmises", "wrappedcauchy", or "vonmisesmix"), or the logical FALSE if a non-parametric estimation (kernel density) should be made.

bandwidth

If parametric = FALSE, the numeric value of the kernel density bandwidth. Default is cylcop::opt_circ_bw(theta, "nrd").

mu

(optional) numeric vector, fixed mean direction(s) of the parametric distribution.

ncomp

integer, number of components of the mixed von Mises distribution. Only has an effect if parametric="vonmisesmix".

Value

If a parametric estimate is made, a list is returned containing the estimated parameters, their standard errors (if available), the log-likelihood, the AIC and the name of the distribution. If a non-parametric estimate is made, the output is a 'density.circular' object obtained with the function circular::density.circular() of the 'circular' package.

See Also

circular::density.circular(), fit_angle(), opt_circ_bw().

Examples

set.seed(123)

silent_curr <- cylcop_get_option("silent")
cylcop_set_option(silent = TRUE)

n <- 10 #n (number of samples) is set small for performance.

angles <- rvonmisesmix(n,
  mu = c(0, pi),
  kappa = c(2,1),
  prop = c(0.5, 0.5)
)

bw <- opt_circ_bw(theta = angles,
  method="nrd",
  kappa.est = "trigmoments"
)
dens_non_param <- fit_angle(theta = angles,
  parametric = FALSE,
  bandwidth = bw
)

param_estimate <- fit_angle(theta = angles,
  parametric = "vonmisesmix"
)
param_estimate_fixed_mean <- fit_angle(theta = angles,
  parametric = "vonmisesmix",
  mu = c(0, pi),
  ncomp =2
)

cylcop_set_option(silent = silent_curr)


[Package cylcop version 0.2.0 Index]