dlg_trivariate {lg} | R Documentation |
Trivariate density estimation
Description
dlg_trivariate
returns the locally Gaussian density estimate of a
trivariate distribution on a given grid.
Usage
dlg_trivariate(x, eval_points = NULL, grid_size = 15, bw = c(1, 1,
1), est_method = "trivariate", run_checks = TRUE)
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. |
run_checks |
Logical. Should sanity checks be run on the arguments? Useful to disable this when doing cross-validation for example. |
Details
In some applications it may be desired to produce a full locally Gaussian fit
of a trivariate density function without having to resort to bivariate
approximations. This function takes a trivariate data set, x
, and a
trivariate set of grid points eval_points
, and returns the trivariate,
locally Gaussian density estimate in these points. We also need a vector of
bandwidths, bw
, with three elements, and an estimation method
est_method
, which in this case is fixed at "trivariate", and
included only to be fully compatible with the other methods in this package.
This function will only work on the marginally standard normal scale! Please
use the wrapper function dlg()
for density estimation. This will
ensure that all parameters have proper values.
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), rnorm(100))
bw <- c(1, 1, 1)
eval_points <- cbind(seq(-4, 4, 1), seq(-4, 4, 1), seq(-4, 4, 1))
estimate <- dlg_trivariate(x, eval_points = eval_points, bw = bw)