sphere.hdr: Computation of HDRs for a spherical density and of general...

View source: R/sphere.hdr.R

sphere.hdrR Documentation

Computation of HDRs for a spherical density and of general level sets for spherical real-valued functions

Description

This function computes HDRs of a spherical density and general level sets for real-valued functions defined on the unit sphere.

Usage

sphere.hdr(f,tau=NULL,level=NULL,nborder=1000,tol=0.1,
           mesh=40,deg=6,plot.hdr=TRUE,col=NULL)

Arguments

f

Object of class "function" that represents a spherical density function or any general real-valued function defined on the unit sphere. Matrix parametrisation of f must be established. Each row of the matrix corresponds to the cartesian coordinates of a point on the unit sphere. Additionally, if f is not a density function, the argument tau cannot be specified and only the value of level must be provided by the user.

tau

Numeric probability. According to Saavedra-Nieves and Crujeiras (2021), 1-tau represents the probability coverage required for HDR. If tau=NULL, a value for the threshold level must be provided.

level

Numeric threshold of the HDR or of the general level set provided by the user. If level is larger than the maximum value of the function f, the HDR or the level set are equal to the emptyset. If level is smaller than the minimum of f, its support is obtained. If level=NULL, f must be a density function and a value for the probability coverage 1-tau of the HDR must be provided.

nborder

Maximum number of HDRs boundary points to be represented. Default nborder= 1000.

tol

Tolerance parameter to determinate the boundary of HDRs. Default tol=0.1.

mesh

A numeric value 10, 20 or 40 indicating the 3D cartesian mesh used for numerical integration on the unit shere. Default mesh=40 considering a total of 32000 triangular cells on the sphere. If mesh=20 or mesh=10, 8000 triangular cells or 2000 are considered, respectively.

deg

Integer string indicating the degree (from 0 to 6) of the quadrature rules for triangles on the sphere for numerical integration. Default deg=6.

plot.hdr

Logical string. If TRUE, the boundary of the level set or the HDR are represented graphically. Default plot.density=TRUE.

col

Color number for plotting the boundary of the HDR. Default "darkgray".

Details

A detailed definition of directional HDRs for a density is given in Saavedra-Nieves and Crujeiras (2021). Note that numerical integration on the sphere is used to compute the threshold of HDR when tau is provided.

Value

If tau is provided, a list with the next components:

hdr

A matrix of rows of points on the HDR boundary.

prob.content

Probability coverage 1-tau.

level

Threshold associated to the probability content 1-tau.

If level is provided, a list with the next components:

levelset

A matrix of rows of points on the level set boundary.

level

Threshold of the level set.

Author(s)

Paula Saavedra-Nieves, Rosa M. Crujeiras and Andrés Prieto.

References

Saavedra-Nieves, P. and Crujeiras, R. M. (2021). Nonparametric estimation of directional highest density regions. Advances in Data Analysis and Classification, 1-36.

Examples


#HDR of model 8 in library HDiR
f1<-function(x){return(dspheremix(x,model=8))}
sphere.hdr(f1,tau=0.5,mesh=20,deg=3)


# Density level set plug-in reconstruction from a sample
# of size 500 (model 8) by using a kernel density
# estimator with uniform kernel
library(DirStats)
f2<-function(x){
  set.seed(1)
  sample<-rspheremix(500, model = 3)
  return(kde_dir(x, data = sample, h = 0.4,
  L = function(x) dunif(x)))
}
sphere.hdr(f2,level=0.3)


HDiR documentation built on Nov. 16, 2022, 5:14 p.m.

Related to sphere.hdr in HDiR...