fim_nb: Calculate FIM of NB

Description Usage Arguments

View source: R/fim_nb.R

Description

This function calculates the expected fisher information matrix of a Naive Bayes model. Analytical solutions of the hessian of the nll have been numerically verified using the hessian() function in library(numDeriv). The expected hessian are not too far from the observed. In fact, only diagonal entries of the hessian contain y, so expectations need to be calculated. But the learned fim can still have negative determinant (very small negative determinant, such as -1e-20). Maybe this is due to underflow? FIM of NB doesn't seem to be positive definite like FIM of logit, so can't use cholesky decomposition.

Usage

1
2
fim_nb(probSign, prodPij1, prodPij0, px, probsMatrix, py1, py0, arities,
  xIndices, yIndex)

Arguments

probSign

A data frame with 1 and -1, which corresponds to the 1st and 2nd level of a varaible. It is used for computing the FIM of Naive Bayes.

prodPij1

A vector of \prod_j p(x_ij|y=1).

prodPij0

A vector of \prod_j p(x_ij|y=0).

px

A vector of py1 * prodPij1 + py0 * prodPij0.

probsMatrix

A matrix of p(x_j|y=1) and p(x_j|y=0)

py1

p(y=T)

py0

p(y=F)

arities

A vector of variable arities.

xIndices

A vector of input variables indices.

yIndex

The index of the output variable.


kelvinyangli/mbmml documentation built on June 29, 2020, 3:12 a.m.