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

### 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 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 L^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).

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



[Package BMAmevt version 1.0.5 Index]