condLocal: Estimate conditional densities using the LGDE

Description Usage Arguments Value Examples

View source: R/multivariate_estimation.R

Description

Estimate conditional densities using the LGDE

Usage

1
2
3
condLocal(data, cond, bandwidths = NULL, gsize = 15,
  grid = apply(as.matrix(data[, 1:(dim(data)[2] - length(cond))]), 2,
  function(x) seq(quantile(x, 0.001), quantile(x, 0.999), length.out = gsize)))

Arguments

data

The data matrix, one row per observation.

cond

A vector of values to be conditioned on.

bandwidths

A matrix of bandwidths. Must be in the same format as is produced by the HLocal-function.

gsize

If grid is not provided, the density will be estimated at gsize points going diagonally through the data.

grid

The grid at which to estimate the density. Must be a matrix with the same number of columns as the data matrix.

Value

A list with 1 element: $f.est.cond is the estimated conditional density.

Examples

1
2
3
4
# Three dimensional example. The conditioning variables must be the last columns in the data matrix.
Estimating the density of X1|X2 = 0, X3 = 0:
data <- cbind(rt(100, df = 10), rt(100, df = 10), rt(100, df = 10))
condLocal(data, cond = c(0,0))

hotneim/lgde documentation built on May 17, 2019, 4:52 p.m.