dlg_bivariate: Bivariate density estimation

Description Usage Arguments Details Value Examples

View source: R/density_estimation.R

Description

dlg_bivariate returns the locally Gaussian density estimate of a bivariate distribution on a given grid.

Usage

1
2
3
dlg_bivariate(x, eval_points = NA, grid_size = 15, bw = c(1, 1),
  est_method = "1par", tol = .Machine$double.eps^0.25/10^4,
  run_checks = TRUE, marginal_estimates = NA, bw_marginal = NA)

Arguments

x

The data matrix (or data frame). Must have exactly 2 columns.

eval_points

The grid where the density should be estimated. Must have exactly 2 columns.

grid_size

If eval_points is not supplied, then the function will create a suitable grid diagonally through the data, with this many grid points.

bw

The two bandwidths, a numeric vector of length 2.

est_method

The estimation method, must either be "1par" for estimation with just the local correlation, or "5par" for a full locally Gaussian fit with all 5 parameters.

tol

The numerical tolerance to be used in the optimization. Only applicable in the 1-parameter optimization.

run_checks

Logical. Should sanity checks be run on the arguments? Useful to disable this when doing cross-validation for example.

marginal_estimates

Provide the marginal estimates here if estimation method is "5par_marginals_fixed", and the marginal estimates have already been found. Useful for cross-validation. List with two elements as returned by dlg_marginal_wrapper.

bw_marginal

Vector of bandwidths used to estimate the marginal distributions.

Details

This function serves as the backbone in the body of methods concerning local Gaussian correlation. It takes a bivariate data set, x, and a bivariate set of grid points eval_points, and returns the bivariate, locally Gaussian density estimate in these points. We also need a vector of bandwidths, bw, with two elements, and an estimation method est_method

Value

A list including the data set $x, the grid $eval_points, the bandwidths $bw, as well as a matrix of the estimated parameter estimates $par_est and the estimated bivariate density $f_est.

Examples

1
2
3
4
5
  x <- cbind(rnorm(100), rnorm(100))
  bw <- c(1, 1)
  eval_points <- cbind(seq(-4, 4, 1), seq(-4, 4, 1))

  estimate <- dlg_bivariate(x, eval_points = eval_points, bw = bw)

lg documentation built on Dec. 5, 2019, 5:13 p.m.