Computes the L^2 inner product of multivariate probability densities, estimated from samples.
1 
x1 
a matrix or data frame of n1 rows (observations) and p columns (variables) or a vector of length n1. 
x2 
matrix or data frame of n2 rows and p columns or vector of length n1. 
method 
string. It can be:

check 
logical. When 
varw1, varw2 
a p \times psymmetric matrix: the smoothing bandwidth for the estimation of the probability densities. If they are omitted, the smoothing bandwidth are computed using the normal reference rule matrix bandwidth (see details). 
If method = "gaussiand"
, the mean vectors (m1 and m2) and the variance matrices (v1 and v2) of the two samples are computed, and they are used to compute the inner product equal to:
(2 pi)^{p/2} v1+v2^{1/2} exp((1/2)(m1m2)'(v1+v2)^{1}(m1m2))
If method = "kern"
, the densities of both samples are estimated using the Gaussian kernel method.
These estimations are then used to compute an estimation of the inner product.
if varw1
and varw2
arguments are omitted, the smoothing bandwidths are computed using the normal reference rule matrix bandwidth:
h_1 v_1^{1/2}
where
h_1 = (4/(n_1(p+2)))^{1/(p+4)}
for the first density. Idem for the second density after making the necessary changes.
Returns the L^2 inner product of the two probability densities.
Be careful! If check = FALSE
and one smoothing bandwidth matrix is degenerate, the result returned can not be considered.
Rachid Boumaza, Pierre Santagostini, Smail Yousfi, Gilles Hunault, Sabine DemotesMainard
Boumaza, R., Yousfi, S., DemotesMainard, S. (2015). Interpreting the principal component analysis of multivariate density functions. Communications in Statistics  Theory and Methods, 44 (16), 33213339.
Wand, M., Jones, M. (1995). Kernel smoothing. Chapman and Hall/CRC, London.
Yousfi, S., Boumaza R., Aissani, D., Adjabi, S. (2014). Optimal bandwith matrices in functional principal component analysis of density functions. Journal of Statistical Computational and Simulation, 85 (11), 23152330.
l2dpar for Gaussian densities, the parameters being given.
1 2 3 4 5 6 7 8 9 10  require(MASS)
m1 < c(0,0)
v1 < matrix(c(1,0,0,1),ncol = 2)
m2 < c(0,1)
v2 < matrix(c(4,1,1,9),ncol = 2)
x1 < mvrnorm(n = 3,mu = m1,Sigma = v1)
x2 < mvrnorm(n = 5, mu = m2, Sigma = v2)
l2d(x1, x2, method = "gaussiand")
l2d(x1, x2, method = "kern")
l2d(x1, x2, method = "kern", varw1 = v1, varw2 = v2)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
Please suggest features or report bugs with the GitHub issue tracker.
All documentation is copyright its authors; we didn't write any of that.