mlestimate {bbl}R Documentation

Maximum likelihood estimate

Description

Perform inference of bias and interaction parameters for a single response group

Usage

mlestimate(
  xi,
  weights = NULL,
  qJ = NULL,
  method = "pseudo",
  L = NULL,
  lambda = 1e-05,
  lambdah = 0,
  symmetrize = TRUE,
  eps = 0.9,
  nprint = 100,
  itmax = 1e+05,
  tolerance = 1e-04,
  verbose = 1,
  prior.count = 1,
  naive = FALSE,
  lz.half = FALSE
)

Arguments

xi

Data matrix; expected to be numeric with elements ranging from zero to positive integral upper bound L-1.

weights

Frequency vector of number of times each row of xi is to be repeated. If NULL, defaults to 1. Expected to be non-negative integers.

qJ

Matrix of logicals indicating which predictor pairs are interacting. If NULL, all are allowed.

method

c('pseudo','mf') for pseudo-likelihood maximization or mean field inference.

L

Vector of number of factor levels in each predictor. If NULL, will be inferred from xi.

lambda

Vector of L2 regularization parameters for method = 'pseudo'. Applies to interaction parameters J.

lambdah

L2 parameters for h in 'pseudo'. If NULL, it is set equal to lambda. lambdah = 0 will free h from penalization.

symmetrize

Enforce the symmetry of interaction parameters by taking mean values of the matrix and its trace: J_{ij}^{(y)}(x_1,x_2)=J_{ji}^{(y)}(x_2,x_1).

eps

Vector of regularization parameters for mf. Must be within the range of \epsilon \in [0,1].

nprint

Frequency of printing iteration progress under 'pseudo'.

itmax

Maximum number of iterations for 'pseudo'.

tolerance

Upper bound for fractional changes in pseduo-likelihood values before termiating iteration in 'pseudo'.

verbose

Verbosity level.

prior.count

Prior count for method = 'mf' to reduce numerical instability.

naive

Naive Bayes inference. Equivalent to method = 'mf' together with eps = 0.

lz.half

Divide interaction term in approximation to \ln Z_{iy} in 'pseudo'.

Details

Given numeric data matrix, either pseudo-likelihood of mean-field theory is used to find the maximum likelihood estimate of bias h and interaction J parameters. Normally called by bbl rather than directly.

Value

List of inferred parameters h and J. See bbl for parameter structures.

Examples

set.seed(535)
predictors <- list()
for(i in 1:5) predictors[[i]] <- c('a','c','g','t')
par <- randompar(predictors)
par
xi <- sample_xi(nsample=5000, predictors=predictors, h=par$h, J=par$J,
                code_out=TRUE)
head(xi)
ps <- mlestimate(xi=xi, method='pseudo', lambda=0)
ps$h
ps$J[[1]]
mf <- mlestimate(xi=xi, method='mf', eps=0.9)
plot(x=unlist(par$h), y=unlist(ps$h), xlab='True', ylab='Inferred')
segments(x0=-2, x1=2, y0=-2, y1=2, lty=2)
points(x=unlist(par$J), y=unlist(ps$J), col='red')
points(x=unlist(par$h), y=unlist(mf$h), col='blue')
points(x=unlist(par$J), y=unlist(mf$J), col='green')

[Package bbl version 1.0.0 Index]