Actually, the most general interface in YADAS for converting arguments
into logs of densities is called Likelihood. This is a poor name,
since these are used in prior terms as well as likelihood terms, and they
actually computes the logs of densities rather than the densities themselves.
A better name would have been LogDensity, and possibly making things
worse, we now use that name to describe a subtype of ``Likelihood''s
that operate row-wise on rectangular arrays.
A small number of Likelihoods (most of them log-densities)
enable the bulk of analyses. For example, consider the Gaussian
log-density (see the code in Gaussian.java). A log-density's
vital characteristic is its compute method, which takes a
two-dimensional array of reals and an integer as input and returns a
single real. In Gaussian, the first ``column'' in the input array is
the vector of ``data'' (call them ), the second column is the
vector of means (call them ), and the third column is the
vector of standard deviations (call them ). The log-density
computes the function
, and the
``likelihood'' is responsible for summing over .
In Gaussian, the function requires the same number of data points,
means, and standard deviations, and most LogDensitys behave similarly,
even though in many problems, all the means or standard deviations
are identical.
``Constants'' are typically computed in LogDensity functions. This
leads to some loss in performance, but that is the price of
generality. In the Gaussian example, if one is considering a change
to the mean parameter, the term involving
is the
same for the current parameter set and for the proposed parameter set,
and will just be canceled out, but we compute it anyway. A more
extreme example is if the standard deviation is known, in which case
most Bayesians will think of this term as a constant and will recoil
at the idea of computing it and subtracting it from itself. In
today's analysis, a term may be a function of constants, but in
tomorrow's analysis, some of those constants may be unknown
parameters. Computing these constant terms allows us to get by with
a single Gaussian likelihood function. (Users should feel
free to write your own GaussianFixedSD likelihood function
that refrains from computing the constant term if they wish.)
Here are the log-density functions that users are likely to need. All of
these take rectangular
arrays. We describe the meanings of the columns of the array. The
output of the compute method is the sum, over rows, of the function
applied to the elements in each row.
Gaussian. Three arguments: data , mean , and
standard deviation . Computes
.
Again, we stress that the Gaussian distribution is parameterized in terms
of its standard deviation.
Gamma. The three arguments are data , shape parameter
, and scale parameter , so that the mean of is
. Another version, GammaMeanAlpha, parameterizes the
density in terms of its mean and shape parameter.
Poisson. The two arguments are the data and the mean
. A source of confusion for Poisson and Binomial
is that all likelihood functions expect all their arguments to be real,
not integer, valued. This holds even for Poisson data, and Binomial data
and sample sizes. On the other hand, it is legal to use noninteger
values for these should you feel the urge.
Binomial. The three arguments are, in order, the number of
successes , the sample size , and the probability . See the
note for the Poisson distribution for a warning.
Beta. The three arguments are the data and the two
parameters and . The mean of is .
StudentT. This distribution takes four arguments: the
data , the mean , the scale parameter , and the number
of degrees of freedom . For large , the standard deviation
is approximately . Note that this includes the Cauchy distribution,
when .
Uniform. The first argument is the data , the second
argument is the lower limit , and the second argument is the upper
limit . The uniform likelihood can be used to state that a parameter
is bounded between two values, for example in interval censoring problems.
NegativeBinomial. The negative binomial distribution
can be used to model count data that are overdispersed relative to the
Poisson distribution; see McCullagh and Nelder (1985, §6.2.3 in
the second edition) and Graves and
Picard (2002). The first argument is the data , the second
argument is the mean , and the third argument is an index
parameter . The variance of is equal to
.
Weibull. The Weibull takes three arguments: data ,
scale parameter , and index parameter . We also supply a
separate class Weibull3 that allows an additional argument
(the left endpoint of the distribution).
Dirichlet. The Dirichlet distribution takes two arguments:
the vectors of ``data'' (the probabilities) and the exponents in the
Dirichlet prior. See also our SeveralDirichlets class.
InverseGamma. The Inverse Gamma family is often used
in conjugate models. It is here as well: the arguments are the data,
shape and scale parameters. We also have InverseRootGamma, the
density of when has a Gamma distribution.
Hypergeometric. For sampling from finite populations,
the hypergeometric distribution is available. Its arguments are the
number of successes in the sample, the size of the sample, the size of
the population, and the number of successes in the population.
A type of Likelihood that is not a LogDensity is
MultivariateNormal. We have experimented with some
multivariate normal applications, but we have not bundled the code
with this distribution because it uses third party software for matrix
manipulation. Ask the author if you are interested in
MultivariateNormal functionality.