Description Objects from the Class Important slots Optional slots Methods Author(s) Examples
This class represents target distributions, that is, probability distributions from which we want to sample using MCMC or Wang-Landau.
Objects should created by calls of the function target
.
Examples are provided that should help implementing any
continuous probability distributions.
dimension
:Object of class "numeric"
: should be an integer specifying the dimension of the state space on which the target distribution is defined.
logdensity
:Object of class "function"
: should be a function taking n points in the state space and parameters, and returning a vector of n real values. See the example below. This function is in most cases the most time-consuming part in a MCMC algorithm, so make sure it runs reasonably fast!
rinit
:Object of class "function"
: this function should take an integer as argument, say n. Then the function should return a matrix of dimension n times d (where d is the dimension of the state space), representing n points in the state space. These n points will be used as starting points of a parallel MCMC algorithm.
parameters
:Object of class "list"
: you can put anything in that list (and nothing, which is the defaults), the important thing is that calls to logdensity(x, parameters)
return sensible values. For example, for a gaussian target distribution, you can put the mean and the variance in the parameters
list (see example below). If need be, you can put a whole data set in there.
type
:Object of class "character"
: could be "continuous" or "discrete"; default is "continuous".
name
:Object of class "character"
: ... if you want to name your distribution (default is "unspecified").
generate
:Object of class "function"
: does not have to be specified, but if it is specified it should be a function to generate from the distribution (like rnorm is to the standard normal distribution).
signature(object = "target")
: provides a little summary of a target object when called (or when print
is called).
Luke Bornn <bornn@stat.harvard.edu>, Pierre E. Jacob <pierre.jacob.work@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 | showClass("target")
# starting points for MCMC algorithms
rinit <- function(size) rnorm(size)
# target log density function: a gaussian distribution N(mean = 2, sd = 3)
parameters <- list(mean = 2, sd = 3)
logdensity <- function(x, parameters) dnorm(x, parameters$mean, parameters$sd, log = TRUE)
# creating the target object
gaussiantarget <- target(name = "gaussian", dimension = 1,
rinit = rinit, logdensity = logdensity,
parameters = parameters)
print(gaussiantarget)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.