clg: The locally Gaussian conditional density estimator

Description Usage Arguments Details Value References Examples

View source: R/density_estimation.R

Description

Estimate a conditional density function using locally Gaussian approximations.

Usage

1
2
clg(lg_object, grid = NULL, condition = NULL,
  normalization_points = NULL, fixed_grid = NULL)

Arguments

lg_object

An object of type lg, as produced by the lg_main-function.

grid

A matrix of grid points, where we want to evaluate the density estimate. Number of columns *must* be the same as number of variables in X1.

condition

A vector with conditions for the variables that we condition upon. Length of this vector *must* be the same as the number of variables in X2. The function will throw an error of there is any discrepancy in the dimensions of the grid, condition and data set.

normalization_points

How many grid points for approximating the integral of the density estimate, to use for normalization?

fixed_grid

Not used presently.

Details

This function is the conditional version of the locally Gaussian density estimator (LGDE), described in Otneim & Tjøstheim (2018). The function takes as arguments an lg-object as produced by the main lg_main- function, a grid of points where the density estimate should be estimated, and a set of conditions.

The variables must be sorted before they are supplied to this function. It will always assume that the free variables come before the conditioning variables.

Assume that X is a stochastic vector with two components X1 and X2. This function will thus estimate the conditional density of X1 given a specified value of X2.

Value

A list containing the conditional density estimate as well as all the running parameters that has been used. The elements are:

References

Otneim, Håkon, and Dag Tjøstheim. "Conditional density estimation using the local Gaussian correlation" Statistics and Computing 28, no. 2 (2018): 303-321.

Examples

1
2
3
4
5
6
7
8
  # A 3 variate example
  x <- cbind(rnorm(100), rnorm(100), rnorm(100))

  # Generate the lg-object with default settings
  lg_object <- lg_main(x)

  # Estimate the conditional density of X1|X2 = 0, X3 = 1 on a small grid
  cond_dens <- clg(lg_object, grid = matrix(-4:4, ncol = 1), condition = c(0, 1))

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

Related to clg in lg...