scores3D {BMAmevt} | R Documentation |
Logarithmic score and L^2
distance between two densities on the simplex (trivariate case).
Description
Computes the Kullback-Leibler divergence and the L^2
distance between the "true" density (true.dens
) and an estimated density (est.dens
).
Usage
scores3D(true.dens, est.dens, npoints, eps)
Arguments
true.dens |
A |
est.dens |
The estimated density: of the same type as |
npoints |
Number of grid points used to construct the density matrices (see |
eps |
Minimum distance from a grid point to the simplex boundary (see |
Details
The integration is made via rect.integrate
: The discretization grid corresponding to the two matrices must be constructed
with discretize(npoints, eps, equi=FALSE)
.
Value
A list made of
-
check.true
: The result of the rectangular integration oftrue.dens
. It should be equal to one. If not, re size the grid. -
check.true
: Idem, replacingtrue.dens
withest.dens
. -
L2score
: The estimatedL^2
distance. -
KLscore
: The estimated Kullback-Leibler divergence between the two re-normalized densities, usingcheck.true
andcheck.est
as normalizing constants (this ensures that the divergence is always positive).
Examples
dens1=dpairbeta.grid(par=c(0.8,2,5,8),npoints=150,eps=1e-3,
equi=FALSE)
dens2=dnestlog.grid(par=c(0.5,0.8,0.4,0.6),npoints=150,eps=1e-3, equi=FALSE)
scores3D(true.dens=dens1,
est.dens=dens2,
npoints=150, eps=1e-4)