bwn {ridgetorus} | R Documentation |
Density evaluation, sampling, and parameter estimation of the bivariate wrapped normal distribution
Description
Computation of the density of the bivariate wrapped normal.
Simulation of pairs of samples from a bivariate wrapped normal.
Maximum likelihood estimation of the parameters
(\boldsymbol{\mu}, \boldsymbol{\Sigma})
.
Usage
d_bwn(x, mu, Sigma, kmax = 2)
r_bwn(n, mu, Sigma)
fit_bwn_mle(
x,
kmax = 2,
lower = c(-pi, -pi, 0.001, 0.001, -1),
upper = c(pi, pi, 20, 20, 1),
...
)
Arguments
x |
matrix of size |
mu |
circular means of the density, a vector of length |
Sigma |
covariance matrix of size |
kmax |
integer number up to truncate the wrapped normal series in
|
n |
sample size. |
lower , upper |
vector of length |
... |
further parameters passed to
|
Value
-
d_bwn
: a vector of lengthnx
with the density evaluated atx
. -
r_bwn
: a matrix of sizec(n, 2)
with the random sample. -
fit_bwn_mle
: a list with the parameters(\boldsymbol{\mu}, \boldsymbol{\Sigma})
and the objectopt
containing the optimization summary.
Examples
## Density evaluation
mu <- c(0, 0)
Sigma <- 3 * matrix(c(1.5, 0.75, 0.75, 1), nrow = 2, ncol = 2)
nth <- 50
th <- seq(-pi, pi, l = nth)
x <- as.matrix(expand.grid(th, th))
d <- d_bwn(x = x, mu = mu, Sigma = Sigma)
filled.contour(th, th, matrix(d, nth, nth), col = viridisLite::viridis(31),
levels = seq(0, max(d), l = 30))
## Sampling and estimation
n <- 100
samp <- r_bwn(n = 100, mu = mu, Sigma = Sigma)
(param_mle <- fit_bwn_mle(samp)$par)