dlg_bivariate {lg} | R Documentation |
Bivariate density estimation
Description
dlg_bivariate
returns the locally Gaussian density estimate of a
bivariate distribution on a given grid.
Usage
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 |
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 " |
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
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)