Learn R Programming

ridgetorus (version 1.0.3)

bwc: Density evaluation, sampling, and parameter estimation of the bivariate wrapped Cauchy distribution

Description

Computation of the density of a bivariate wrapped Cauchy: $$f(\theta_1, \theta_2)=c(\xi_1,\xi_2,\rho)\{c_0(\xi_1,\xi_2,\rho)- c_1(\xi_1,\xi_2,\rho) \cos (\theta_1-\mu_1)- c_2(\xi_1,\xi_2,\rho)\cos (\theta_2-\mu_2)-\\ c_3(\xi_1,\xi_2,\rho) \cos (\theta_1-\mu_1) \cos (\theta_2-\mu_2)- c_4(\xi_1,\xi_2,\rho) \sin (\theta_1-\mu_1) \sin (\theta_2-\mu_2)\}^{-1}.$$

Simulation of samples from a bivariate wrapped Cauchy.

Maximum likelihood and method of moments estimation of the parameters \((\mu_1, \mu_2, \xi_1, \xi_2, \rho)\).

Usage

d_bwc(x, mu, xi)

r_bwc(n, mu, xi)

fit_bwc_mm(x, hom = FALSE, indep = FALSE)

fit_bwc_mle( x, start = NULL, lower = c(-pi, -pi, 0, 0, -1 + 0.001), upper = c(pi, pi, 1 - 0.001, 1 - 0.001, 1 - 0.001), hom = FALSE, indep = FALSE, ... )

Value

  • d_bwc: a vector of length nx with the density evaluated at x.

  • r_bwc: a matrix of size c(n, 2) with the random sample.

  • fit_mme_bwc, fit_mle_bwc: a list with the parameters \((\mu_1, \mu_2, \xi_1, \xi_2, \rho)\) and the object opt containing the optimization summary.

Arguments

x

matrix of size c(nx, 2) with the angles on which the density is evaluated.

mu

circular means of the density, a vector of length 2.

xi

a vector of length 3 with the marginal concentrations \((\xi_1, \xi_2)\), and the dependence parameter \(\rho\).

n

sample size.

hom

assume a homogeneous distribution with equal marginal concentrations? Defaults to FALSE.

indep

set the dependence parameter to zero? Defaults to FALSE.

start

a vector of length 5 with the initial values for the maximum likelihood optimizer. If NULL (default), the method of moments estimates are employed.

lower, upper

vectors of length 5 with the bounds for the likelihood optimizer. Default to c(-pi, -pi, 0, 0, -1 + 1e-3) and c(pi, pi, 1 - 1e-3, 1 - 1e-3, 1 - 1e-3).

...

further parameters passed to mleOptimWrapper.

Author

The original code for r_bwc was supplied by Arthur Pewsey.

References

Kato, S. and Pewsey, A. (2015). A Möbius transformation-induced distribution on the torus. Biometrika, 102(2):359--370. tools:::Rd_expr_doi("10.1093/biomet/asv003")

Examples

Run this code
## Density evaluation

mu <- c(0, 0)
xi <- c(0.3, 0.5, 0.4)
nth <- 50
th <- seq(-pi, pi, l = nth)
x <- as.matrix(expand.grid(th, th))
d <- d_bwc(x = x, mu = mu, xi = xi)
filled.contour(th, th, matrix(d, nth, nth), col = viridisLite::viridis(20),
               levels = seq(0, max(d), l = 20))

## Sampling and estimation

n <- 100
samp <- r_bwc(n = n, mu = mu, xi = xi)
(param_mm <- fit_bwc_mm(samp)$par)
(param_mle <- fit_bwc_mle(samp)$par)

Run the code above in your browser using DataLab