det2: Density Estimation for Bivariate Data Based on Distribution...

Description Usage Arguments Examples

View source: R/det2.R

Description

Two-dimensional piecewise linear or constant probability density estimator based on distribution element trees (DETs).

Usage

1
2
3
det2(dta, mode = 2, bounds = list(NA, NA), alphag = 0.001,
  alphad = 0.001, main = NULL, nc = 20, dtalim = Inf, cores = 1,
  color = grDevices::colorRamp(c("white", "black")))

Arguments

dta

matrix with two rows containing data (samples in columns).

mode

order of distribution elements applied, default is mode = 2. Use +/-1 for constant or +/-2 for linear elements. mode > 0 and mode < 0 lead to equal-size and -score splits, respectively, in the element-refinement process.

bounds

list(lb,ub), where lb and ub are vectors representing the lower and upper bounds of the probability space. If both bounds are set to NA (default) or 0, the bounds are determined based on the data dta. Additionally, if the bounds are set to 0, pre-whitening is not applied to the data.

alphag, alphad

significance levels for goodness-of-fit and independence tests, respectively, in element refinement or splitting process. Default is alphag = alphad = 1.0e-3.

main

an overall plot title, see title. If main = NULL (default), the density range is provided as a title.

nc

number of contour levels (default is 20).

dtalim

allows to limit the number of samples used in tests guiding the element splitting process. Default is dtalim = Inf, which corresponds to using all available samples, see det.construct.

cores

number of cores for parallel tree construction. Default is cores = 1 for serial processing, see cores in det.construct.

color

function to assign plot colors that is generated, e.g., by colorRamp. color returns a color based on an argument in [0,1].

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## uniform
require(stats)
det2(rbind(runif(5e3),1+2*runif(5e3)), mode = 1, bounds = list(c(-0.1,0),c(1.1,4)))
det2(rbind(1:100,101:200+runif(100)), mode = 2) # data on a line

## Gaussian
require(stats); require(graphics); require(grDevices)
n <- 5e3; x <- rnorm(n)
x <- matrix(c(x, x+rnorm(n,0,0.5)), ncol = 2)
split.screen(c(2,2))
color = colorRamp(c("#FFFFFF","#E6E680","#E6BF1A",
                    "#E68000","#FF4026","#993380",
                    "#4D26BF","#262680","#000000"))
screen(3); plot(x, type = "p", pch = ".", main = "data")
screen(1); det2(t(x), mode = 1, main = "constant det estimator", color = color)
screen(2); det2(t(x), main = "linear det estimator", color = color)
screen(4)
det2(t(x), mode = 1, bounds = list(0,0), main = "const. det, no pre-white", color = color)

detpack documentation built on July 24, 2019, 5:03 p.m.

Related to det2 in detpack...