Xlambdasampler: Joint x-lambda sampler for Poisson and negative binomial...

XlambdasamplerR Documentation

Joint x-lambda sampler for Poisson and negative binomial linear inverse problems

Description

Consider the linear inverse problem y=Ax, where x follows a Poisson or negative binomial distribution with mean lambda = Ex. This function jointly samples lambda and x.

Usage

Xlambdasampler(
  y,
  A,
  lambda.updater,
  lambda.ini,
  U = NULL,
  Method = "MH",
  Reorder = TRUE,
  tune.par = 0.5,
  combine = FALSE,
  x.order = NULL,
  x.ini = NULL,
  Model = "Poisson",
  Proposal = "Unif",
  NB.alpha.ini = 1,
  lambda.additional = NA,
  other.pars = numeric(0),
  ndraws = 10000,
  burnin = 2000,
  verbose = 0,
  THIN = 1
)

Arguments

y

Matrix of sequence of observed count data vectors; each column is an observation.

A

Model configuration matrix, assumed to be binary.

lambda.updater

Function with required arguments x, lambda (and NB.alpha for negative binomial models) which updates lambda.

lambda.ini

Initial mean vector for x.

U

Optional matrix the columns of which should be a Markov (sub)-basis.

Method

"MH" for Metropolis-Hastings sampler, "Gibbs" for Gibbs sampler.

Reorder

Should the columns of A be reordered? Defaults to TRUE.

tune.par

Tuning parameter (alpha) controlling variation in fitness values for lattice bases. Defaults to 0.5.

combine

Should extra moves be included combining lattice basis vectors? Defaults to FALSE, but should usually be set to TRUE if A is not unimodular.

x.order

If Reorder=FALSE, x.order can be used to reorder columns of A to match ordering of entries of x. Defaults to NULL when no such reordering is performed.

x.ini

Matrix of initial values for x, with column orderings matching that for y. Default is NULL, when initial values derived through integer programming.

Model

"Poisson" or "NegBin".

Proposal

"NonUnif" or "Unif" (default).

NB.alpha.ini

Initial value for dispersion parameter for negaqtive-binomial distribution. Defaults to 1.

lambda.additional

Optional object to transfer additional information to lambda.updater.

other.pars

Optional object to provide initial values for other model parameters.

ndraws

Number of iterations to run sampler after burn-in. One iteration comprises cycling through the full basis (possibly augmented by a combined move). Defaults to 10^4.

burnin

Number of iteractions for burn in period. Defaults to 2000, which is usually more than adequate.

verbose

Controls level of detail in recording lattice bases used.

THIN

Thinning parameter for output. Defaults to 1 (no thinning).

Value

A list with components X (an array, for which Xi,j,k is the k-th sampled value of the i-th component of the j-th observation of x), LAMBDA (a matrix, each row corresponding to samples for an entry of lambda), NB.ALPHA (a vector of sampler values of NB.alpha, NA if model is Poisson), OTHER.PARS (a matrix, each row corresponding to an additional parameter; zero rows if there are none) and x.order (a vector describing dynamic selection of lattice bases, if verbose=1).

Examples

data(LondonRoad)
lu <- function(x,lambda,NB.alpha=NA,lambda.tuning=1,lambda.additional=NA) { list(lambda=rgamma(length(lambda),shape=x+0.5*LondonRoad$lambda,rate=1.5),other.pars=numeric(0),NB.alpha=NA) }
Xlambdasampler(y=LondonRoad$y,A=LondonRoad$A,lambda.updater=lu,lambda.ini=LondonRoad$lambda,Model="Poisson",Method="Gibbs",tune.par=0.5,combine=FALSE)

MartinLHazelton/LinInvCount documentation built on March 1, 2024, 3:14 a.m.