scores3D function

Logarithmic score and L2L^2 distance between two densities on the simplex (trivariate case).

Logarithmic score and L2L^2 distance between two densities on the simplex (trivariate case).

Computes the Kullback-Leibler divergence and the L2L^2 distance between the "true" density (true.dens) and an estimated density (est.dens).

scores3D(true.dens, est.dens, npoints, eps)

Arguments

  • true.dens: A npoints*npoints matrix: The reference density, typically the distribution from which data was simulated. Must be a valid density argument to be passed to dgridplot, with equi=FALSE.
  • est.dens: The estimated density: of the same type as true.dens.
  • npoints: Number of grid points used to construct the density matrices (see discretize).
  • eps: Minimum distance from a grid point to the simplex boundary (see discretize).

Returns

A list made of

  • check.true: The result of the rectangular integration of true.dens. It should be equal to one. If not, re size the grid.
  • check.true: Idem, replacing true.dens with est.dens.
  • L2score: The estimated L2L^2 distance.
  • KLscore: The estimated Kullback-Leibler divergence between the two re-normalized densities, using check.true and check.est as normalizing constants (this ensures that the divergence is always positive).

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).

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)
  • Maintainer: Leo Belzile
  • License: GPL (>= 2)
  • Last published: 2023-04-21

Useful links