lg {lg} | R Documentation |
lg
: A package for calculating the local Gaussian correlation in
multivariate applications.
Description
The lg
package provides implementations for the multivariate density
estimation and the conditional density estimation methods using local
Gaussian correlation as presented in Otneim & Tjøstheim (2017) and Otneim &
Tjøstheim (2018).
Details
The main function is called lg_main
, and takes as argument a data set
(represented by a matrix or data frame) as well as various (optional)
configurations that is described in detail in the articles mentioned above,
and in the documentation of this package. In particular, this function
will calculate the bandwidths used for estimation, using either a plugin
estimate (default), or a cross validation estimate. If x
is the data
set, then the following line of code will create an lg
object using
the default configuration, that can be used for density estimation
afterwards:
lg_object <- lg_main(x)
You can change estimation method, bandwidth selection method and other
parameters by using the arguments of the lg_main
function.
You can evaluate the multivariate density estimate on a grid
as
described in Otneim & Tjøstheim (2017) using the dlg
-function as
follows:
dens_est <- dlg(lg_object, grid = grid).
Assuming that the data set has p variables, you can evaluate the conditional density of the p - q first variables (counting from column 1), given the remaining q variables being equal to condition = c(v1, ..., vq)
, on a grid
, by running
conditional_dens_est <- clg(lg_object, grid = grid, condition = condition)
.
References
Otneim, Håkon, and Dag Tjøstheim. "The locally gaussian density estimator for multivariate data." Statistics and Computing 27, no. 6 (2017): 1595-1616.
Otneim, Håkon, and Dag Tjøstheim. "Conditional density estimation using the local Gaussian correlation" Statistics and Computing 28, no. 2 (2018): 303-321.